Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.google.common.collect.Iterables;
import com.google.errorprone.ErrorProneFlags;
import com.google.errorprone.util.ASTHelpers;
import com.sun.tools.javac.code.Symbol;

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build junit-framework with snapshot

package com.sun.tools.javac.code does not exist

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build junit-framework with snapshot

package com.sun.tools.javac.code is not visible

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-framework with snapshot

package com.sun.tools.javac.code does not exist

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-framework with snapshot

package com.sun.tools.javac.code is not visible

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-boot with snapshot

package com.sun.tools.javac.code does not exist

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-boot with snapshot

package com.sun.tools.javac.code is not visible

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build caffeine with snapshot

package com.sun.tools.javac.code does not exist

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build caffeine with snapshot

package com.sun.tools.javac.code is not visible

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build and test on ubuntu-latest

package com.sun.tools.javac.code does not exist

Check failure on line 31 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build and test on ubuntu-latest

package com.sun.tools.javac.code is not visible
import com.uber.nullaway.fixserialization.FixSerializationConfig;
import com.uber.nullaway.fixserialization.adapters.SerializationAdapter;
import java.util.Collections;
Expand Down Expand Up @@ -61,6 +61,7 @@
static final String FL_GENERATED_UNANNOTATED = EP_FL_NAMESPACE + ":TreatGeneratedAsUnannotated";
static final String FL_ACKNOWLEDGE_ANDROID_RECENT = EP_FL_NAMESPACE + ":AcknowledgeAndroidRecent";
static final String FL_JSPECIFY_MODE = EP_FL_NAMESPACE + ":JSpecifyMode";
static final String FL_JSPECIFY_EXPERIMENTAL = EP_FL_NAMESPACE + ":JSpecifyExperimental";
static final String FL_EXCLUDED_FIELD_ANNOT = EP_FL_NAMESPACE + ":ExcludedFieldAnnotations";
static final String FL_INITIALIZER_ANNOT = EP_FL_NAMESPACE + ":CustomInitializerAnnotations";
static final String FL_NULLABLE_ANNOT = EP_FL_NAMESPACE + ":CustomNullableAnnotations";
Expand Down Expand Up @@ -268,6 +269,7 @@
private final FixSerializationConfig fixSerializationConfig;

ErrorProneCLIFlagsConfig(ErrorProneFlags flags) {
boolean jspecifyExperimental = flags.getBoolean(FL_JSPECIFY_EXPERIMENTAL).orElse(false);
boolean annotatedPackagesPassed = flags.get(FL_ANNOTATED_PACKAGES).isPresent();
boolean onlyNullMarked = flags.getBoolean(FL_ONLY_NULLMARKED).orElse(false);
// exactly one of AnnotatedPackages or OnlyNullMarked should be passed in
Expand Down Expand Up @@ -306,7 +308,8 @@
treatGeneratedAsUnannotated = flags.getBoolean(FL_GENERATED_UNANNOTATED).orElse(false);
acknowledgeAndroidRecent = flags.getBoolean(FL_ACKNOWLEDGE_ANDROID_RECENT).orElse(false);
jspecifyMode = flags.getBoolean(FL_JSPECIFY_MODE).orElse(false);
handleWildcardGenerics = flags.getBoolean(FL_HANDLE_WILDCARD_GENERICS).orElse(false);
handleWildcardGenerics =
flags.getBoolean(FL_HANDLE_WILDCARD_GENERICS).orElse(jspecifyExperimental);
assertsEnabled = flags.getBoolean(FL_ASSERTS_ENABLED).orElse(false);
fieldAnnotPattern =
getPackagePattern(
Expand All @@ -329,7 +332,8 @@

/* --- JarInfer configs --- */
jarInferEnabled = flags.getBoolean(FL_JI_ENABLED).orElse(false);
jspecifyJDKModelsEnabled = flags.getBoolean(FL_JSPECIFY_JDK_ENABLED).orElse(false);
jspecifyJDKModelsEnabled =
flags.getBoolean(FL_JSPECIFY_JDK_ENABLED).orElse(jspecifyExperimental);
if (jspecifyJDKModelsEnabled && !jspecifyMode) {
throw new IllegalStateException(
"-XepOpt:%s should only be set in JSpecify mode".formatted(FL_JSPECIFY_JDK_ENABLED));
Expand Down Expand Up @@ -443,7 +447,7 @@
}

@Override
public boolean isUnannotatedClass(Symbol.ClassSymbol symbol) {

Check failure on line 450 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build junit-framework with snapshot

package Symbol does not exist

Check failure on line 450 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-framework with snapshot

package Symbol does not exist

Check failure on line 450 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-boot with snapshot

package Symbol does not exist

Check failure on line 450 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build caffeine with snapshot

package Symbol does not exist

Check failure on line 450 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build and test on ubuntu-latest

package Symbol does not exist
if (unannotatedClasses == null) {
return false;
}
Expand Down Expand Up @@ -487,7 +491,7 @@
}

@Override
public boolean isKnownInitializerMethod(Symbol.MethodSymbol methodSymbol) {

Check failure on line 494 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build junit-framework with snapshot

package Symbol does not exist

Check failure on line 494 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-framework with snapshot

package Symbol does not exist

Check failure on line 494 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build spring-boot with snapshot

package Symbol does not exist

Check failure on line 494 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build caffeine with snapshot

package Symbol does not exist

Check failure on line 494 in nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java

View workflow job for this annotation

GitHub Actions / Build and test on ubuntu-latest

package Symbol does not exist
Symbol.ClassSymbol enclosingClass = ASTHelpers.enclosingClass(methodSymbol);
if (enclosingClass == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.errorprone.CompilationTestHelper;
import com.google.errorprone.ErrorProneFlags;
import java.util.List;
import java.util.Map;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -83,4 +85,18 @@ public void jspecifyJDKOutsideJSpecifyMode() {
AssertionError e = assertThrows(AssertionError.class, () -> compilationTestHelper.doTest());
assertTrue(e.getMessage().contains("should only be set in JSpecify mode"));
}

@Test
public void jspecifyExperimentalEnablesExperimentalFeatures() {
ErrorProneCLIFlagsConfig config =
new ErrorProneCLIFlagsConfig(
ErrorProneFlags.fromMap(
Map.of(
"NullAway:AnnotatedPackages", "foo",
"NullAway:JSpecifyMode", "true",
"NullAway:JSpecifyExperimental", "true")));

assertTrue(config.isJSpecifyJDKModels());
assertTrue(config.handleWildcardGenerics());
}
Comment on lines +89 to +101

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover explicit per-feature overrides.

This test only verifies the experimental true fallback. Add a case with JSpecifyExperimental=true, JSpecifyJDKModels=false, and HandleWildcardGenerics=false, asserting both accessors remain false. This protects the contract that the individual flags continue to override the umbrella flag.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nullaway/src/test/java/com/uber/nullaway/ErrorProneCLIFlagsConfigTest.java`
around lines 89 - 101, Add a test case alongside
jspecifyExperimentalEnablesExperimentalFeatures using JSpecifyExperimental=true
with JSpecifyJDKModels=false and HandleWildcardGenerics=false, then assert
isJSpecifyJDKModels() and handleWildcardGenerics() both return false, confirming
explicit per-feature flags override the experimental fallback.

}
Loading