diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameter.java b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameter.java index bca48066a80..74fff8e8713 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameter.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameter.java @@ -248,7 +248,7 @@ private boolean enclosingAnnotationDefaultsNonTypeVariablesToNonNull( if (hasAnnotation(sym, "com.google.protobuf.Internal$ProtoNonnullApi", state)) { return true; } - if (hasAnnotation(sym, "org.jspecify.nullness.NullMarked", state) + if (hasAnnotation(sym, "org.jspecify.annotations.NullMarked", state) && weTrustNullMarkedOn(sym, state)) { return true; } diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullnessUtils.java b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullnessUtils.java index 90f8ce83125..3782c145541 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullnessUtils.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/NullnessUtils.java @@ -129,7 +129,7 @@ static boolean nullnessChecksShouldBeConservative(ErrorProneFlags flags) { static boolean isInNullMarkedScope(Symbol sym, VisitorState state) { for (; sym != null; sym = sym.getEnclosingElement()) { - if (hasAnnotation(sym, "org.jspecify.nullness.NullMarked", state)) { + if (hasAnnotation(sym, "org.jspecify.annotations.NullMarked", state)) { return true; } } @@ -353,7 +353,7 @@ private static NullableAnnotationToUse pickNullableAnnotation(VisitorState state .orElse( state.isAndroidCompatible() ? "androidx.annotation.Nullable" - : "org.jspecify.nullness.Nullable"); + : "org.jspecify.annotations.Nullable"); if (sym != null) { ClassSymbol classSym = (ClassSymbol) sym; if (classSym.isAnnotationType()) { @@ -381,8 +381,8 @@ private static boolean isTypeUse(String className) { case "org.checkerframework.checker.nullness.qual.Nullable": case "org.jspecify.annotations.NonNull": case "org.jspecify.annotations.Nullable": - case "org.jspecify.nullness.NonNull": - case "org.jspecify.nullness.Nullable": + case "org.jspecify.annotations.NonNull": + case "org.jspecify.annotations.Nullable": return true; default: // TODO(cpovirk): Detect type-use-ness from the class symbol if it's available? diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/NullableOptionalTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/NullableOptionalTest.java index 8da09a598ab..f4e5ff320b4 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/NullableOptionalTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/NullableOptionalTest.java @@ -79,7 +79,7 @@ public void methodReturnsOptionalWithAnotherNullableAnnotation_showsError() { .addSourceLines( "Test.java", "import java.util.Optional;", - "import org.jspecify.nullness.Nullable;", + "import org.jspecify.annotations.Nullable;", "final class Test {", " @Nullable", " // BUG: Diagnostic contains:", @@ -136,7 +136,7 @@ public void methodReturnsNonOptionalWithAnotherNullableAnnotation_noError() { compilationHelper .addSourceLines( "Test.java", - "import org.jspecify.nullness.Nullable;", + "import org.jspecify.annotations.Nullable;", "final class Test {", " @Nullable", " private Object foo() {", @@ -151,7 +151,7 @@ public void methodHasNullableNonOptionalAsParameter_noError() { compilationHelper .addSourceLines( "Test.java", - "import org.jspecify.nullness.Nullable;", + "import org.jspecify.annotations.Nullable;", "final class Test {", " private void foo(@Nullable Object object) {}", "}") diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/EqualsMissingNullableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/EqualsMissingNullableTest.java index f1eb363284e..ce01e9f8039 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/EqualsMissingNullableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/EqualsMissingNullableTest.java @@ -125,7 +125,7 @@ public void positiveConservativeNullMarked() { conservativeHelper .addSourceLines( "Foo.java", - "import org.jspecify.nullness.NullMarked;", + "import org.jspecify.annotations.NullMarked;", "@NullMarked", "abstract class Foo {", " // BUG: Diagnostic contains: @Nullable", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/FieldMissingNullableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/FieldMissingNullableTest.java index 651d854e6f0..49f85147d76 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/FieldMissingNullableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/FieldMissingNullableTest.java @@ -457,7 +457,7 @@ public void nonAnnotationNullable() { .addOutputLines( "out/Test.java", "class T {", - " private final @org.jspecify.nullness.Nullable Object obj2 = null;", + " private final @org.jspecify.annotations.Nullable Object obj2 = null;", " class Nullable {}", "}") .doTest(); diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java index 362cb557808..8718f94aeae 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java @@ -177,7 +177,7 @@ public void positiveNullMarkedOtherPackageAggressive() { aggressiveHelper .addSourceLines( "Foo.java", - "import org.jspecify.nullness.NullMarked;", + "import org.jspecify.annotations.NullMarked;", "@NullMarked", "class Foo {", " void consume(String s) {}", @@ -194,7 +194,7 @@ public void negativeNullMarkedNonComGoogleCommonPackageConservative() { conservativeHelper .addSourceLines( "Foo.java", - "import org.jspecify.nullness.NullMarked;", + "import org.jspecify.annotations.NullMarked;", "@NullMarked", "class Foo {", " void consume(String s) {}", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/ReturnMissingNullableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/ReturnMissingNullableTest.java index 77a756d17f0..fb85ffc548e 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/ReturnMissingNullableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/ReturnMissingNullableTest.java @@ -840,7 +840,7 @@ public void removeSuppressWarnings_removeNullnessReturnWarning() { .addOutputLines( "com/google/errorprone/bugpatterns/nullness/LiteralNullReturnTest.java", "package com.google.errorprone.bugpatterns.nullness;", - "import org.jspecify.nullness.Nullable;", + "import org.jspecify.annotations.Nullable;", "public class LiteralNullReturnTest {", "", " public @Nullable String getMessage(boolean b) {", @@ -1689,8 +1689,8 @@ public void nonAnnotationNullable() { .addOutputLines( "out/Test.java", "class T {", - " @org.jspecify.nullness.Nullable private final Object method(boolean b) { return b ?" - + " null : 0; }", + " @org.jspecify.annotations.Nullable private final Object method(boolean b) { return b" + + " ? null : 0; }", " class Nullable {}", "}") .doTest(); @@ -1712,7 +1712,7 @@ public void multipleNullReturns() { "}") .addOutputLines( "out/Test.java", - "import org.jspecify.nullness.Nullable;", + "import org.jspecify.annotations.Nullable;", "class T {", " private final @Nullable Object method(boolean b) {", " if (b) {", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullableTest.java index 749c88f9bf6..8cf45b61b60 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullableTest.java @@ -334,7 +334,7 @@ public void positiveConservativeNullMarked() { .addSourceLines( "Test.java", "import javax.annotation.Nullable;", - "import org.jspecify.nullness.NullMarked;", + "import org.jspecify.annotations.NullMarked;", "@NullMarked", "class Test {", " // BUG: Diagnostic contains: @Nullable",