diff --git a/jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java b/jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java index 7850a4c462..ef2e4c21fe 100644 --- a/jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java +++ b/jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java @@ -39,6 +39,24 @@ */ public class AstubxGenerator { + /** Used to strip only top-level nullness annotations from a parameter type signature */ + private static final Pattern TOP_LEVEL_NULLNESS_ANNOTATION_PATTERN = + buildTopLevelNullnessAnnotationPattern(); + + /** + * Matches annotations immediately before the "[]" for array parameters. Does not properly handle + * explicit {@code @NonNull} annotations; see https://github.com/uber/NullAway/issues/1498 + */ + private static final Pattern ARRAY_NULLNESS_ANNOTATION_PATTERN = + Pattern.compile("@[\\w.]+(?=\\s*\\[])"); + + /** + * Matches annotations immediately before the "..." for varargs parameters Does not handle + * explicit {@code @NonNull} annotations; see https://github.com/uber/NullAway/issues/1498 + */ + private static final Pattern VARARGS_ARRAY_NULLNESS_ANNOTATION_PATTERN = + Pattern.compile("@[\\w.]+(?=\\.\\.\\.)"); + /** * Contains all information that will be added to the astubx file. * @@ -258,25 +276,12 @@ private static void getMethodRecords( for (int i = 0; i < argumentList.length; i++) { // remove generic annotations on arguments String typeSignature = removeGenericAnnotations(argumentList[i].trim()); - // remove annotations - if (typeSignature.contains("@")) { - String[] signatureTokens = typeSignature.split(" "); - typeSignature = ""; - for (String token : signatureTokens) { - if (token.contains("@")) { - if (token.contains("@org.jspecify.annotations.Nullable")) { - argAnnotation.put(i, ImmutableSet.of("Nullable")); - } - typeSignature += token.substring(0, token.indexOf('@')); - } else { - typeSignature += token; - } - } - } else { - // remove any spaces in Array types - typeSignature = typeSignature.replace(" []", "[]"); + if (hasTopLevelNullableAnnotation(typeSignature)) { + argAnnotation.put(i, ImmutableSet.of("Nullable")); } - argumentList[i] = typeSignature; + // Remove top-level annotations before writing the method signature key, while preserving + // the varargs ellipsis so the generated key still matches the erased bytecode signature. + argumentList[i] = stripTopLevelNullnessAnnotations(typeSignature).replace(" []", "[]"); } ImmutableSetMultimap.Builder nestedAnnotations = new ImmutableSetMultimap.Builder<>(); @@ -373,4 +378,46 @@ private static String removeGenericAnnotations(String typeSignature) { } return typeSignature; } + + /** + * Checks if the given parameter type has a top-level {@code @Nullable} annotation. Assumes there + * are no annotations on any generic type arguments in the type. We only handle JSpecify + * {@code @Nullable} annotations for now, as those are the only type present in the JSpecify JDK. + * + * @param parameterType the parameter type. + * @return true if the type has a top-level {@code @Nullable} annotation, false otherwise + */ + private static boolean hasTopLevelNullableAnnotation(String parameterType) { + if (!(parameterType.contains("@org.jspecify.annotations.Nullable") + || parameterType.contains("@Nullable"))) { + return false; + } + if (!parameterType.contains("...")) { + if (parameterType.contains("[")) { + // Arrays need special handling: + // @Nullable String[] -> nullable elements, not a nullable array parameter + // String @Nullable [] -> nullable array parameter + // Only the latter is a top-level annotation + return ARRAY_NULLNESS_ANNOTATION_PATTERN.matcher(parameterType).find(); + } + return true; + } + // Varargs need special handling: + // @Nullable Object... -> nullable elements, not a nullable array parameter + // Object @Nullable ... -> nullable array parameter + // Only the latter is a top-level annotation + return VARARGS_ARRAY_NULLNESS_ANNOTATION_PATTERN.matcher(parameterType).find(); + } + + private static String stripTopLevelNullnessAnnotations(String typeSignature) { + return TOP_LEVEL_NULLNESS_ANNOTATION_PATTERN.matcher(typeSignature).replaceAll(""); + } + + private static Pattern buildTopLevelNullnessAnnotationPattern() { + String annotationWithSpace = "@[\\w.]+\\s"; + // top-level varargs array annotations (for the array itself) are rendered directly before the + // ellipsis. + String annotationOfVarargsArray = "@[\\w.]+(?=\\.\\.\\.)"; + return Pattern.compile(annotationWithSpace + "|" + annotationOfVarargsArray); + } } diff --git a/jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java b/jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java index 62cee31d25..b0b0e82723 100644 --- a/jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java +++ b/jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java @@ -259,6 +259,51 @@ public void nullableArrayTypeParameter() { runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("NullableParameters")); } + @Test + public void arrayParametersNullableArrayVsElements() { + compilationHelper + .addSourceLines( + "ArrayParameters.java", + "import org.jspecify.annotations.NullMarked;", + "import org.jspecify.annotations.Nullable;", + "@NullMarked", + "public class ArrayParameters {", + " public static void arrayNullable(String @Nullable [] arr) {}", + " public static void elementsNullable(@Nullable String[] arr) {}", + " public static void bothNullable(@Nullable String @Nullable [] arr) {}", + "}") + .doTest(); + ImmutableMap expectedMethodRecords = + ImmutableMap.of( + "ArrayParameters:void arrayNullable(java.lang.String[])", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(0, ImmutableSet.of("Nullable")), + ImmutableSetMultimap.of()), + "ArrayParameters:void elementsNullable(java.lang.String[])", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(), + ImmutableSetMultimap.of( + 0, + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of(new TypePathEntry(Kind.ARRAY_ELEMENT, -1))))), + "ArrayParameters:void bothNullable(java.lang.String[])", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(0, ImmutableSet.of("Nullable")), + ImmutableSetMultimap.of( + 0, + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of(new TypePathEntry(Kind.ARRAY_ELEMENT, -1)))))); + runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("ArrayParameters")); + } + @Test public void genericParameter() { compilationHelper @@ -425,6 +470,80 @@ public void methodTypeParameter() { runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("Test")); } + @Test + public void varargsNullableArrayOnly() { + compilationHelper + .addSourceLines( + "Test.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Test {", + " public static int varargs(Object @Nullable ... args) { return 0; }", + "}") + .doTest(); + ImmutableMap expectedMethodRecords = + ImmutableMap.of( + "Test:int varargs(java.lang.Object...)", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(0, ImmutableSet.of("Nullable")), + ImmutableSetMultimap.of())); + runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("Test")); + } + + @Test + public void varargsNullableElementsOnly() { + compilationHelper + .addSourceLines( + "Test.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Test {", + " public static int varargs(@Nullable Object... args) { return 0; }", + "}") + .doTest(); + ImmutableMap expectedMethodRecords = + ImmutableMap.of( + "Test:int varargs(java.lang.Object...)", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(), + ImmutableSetMultimap.of( + 0, + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of(new TypePathEntry(Kind.ARRAY_ELEMENT, -1)))))); + runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("Test")); + } + + @Test + public void varargsNullableArrayAndElements() { + compilationHelper + .addSourceLines( + "Test.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Test {", + " public static int varargs(@Nullable Object @Nullable ... args) { return 0; }", + "}") + .doTest(); + ImmutableMap expectedMethodRecords = + ImmutableMap.of( + "Test:int varargs(java.lang.Object...)", + MethodAnnotationsRecord.create( + ImmutableSet.of(), + ImmutableSet.of(), + ImmutableMap.of(0, ImmutableSet.of("Nullable")), + ImmutableSetMultimap.of( + 0, + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of(new TypePathEntry(Kind.ARRAY_ELEMENT, -1)))))); + runTest(expectedMethodRecords, ImmutableMap.of(), ImmutableSet.of("Test")); + } + private void runTest( ImmutableMap expectedMethodRecords, ImmutableMap> expectedNullableUpperBounds, diff --git a/jdk-annotations/jdk-integration-test/README.md b/jdk-annotations/jdk-integration-test/README.md new file mode 100644 index 0000000000..a018a5c12b --- /dev/null +++ b/jdk-annotations/jdk-integration-test/README.md @@ -0,0 +1,7 @@ +These integration tests for the javac plugin work as follows. We have two versions of code used as a "library" for +input, in the sibling `test-annotated` and `test-unannotated` modules. For the `test-annotated` code, we generate an +astubx using the javac plugin (to generate JSON) and the astubx generator (to generate astubx from the JSON). Then, +when building the jar for the `test-unannotated` code, we include the generated astubx in the jar file. This module +depends only on the `test-unannotated` module, so the tests are run against the unannotated code, but with the astubx +available on the classpath. This allows us to test that the javac plugin is correctly generating the astubx and that +the astubx is correctly being loaded and used by NullAway. diff --git a/jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java b/jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java index 63a18ca453..3692fb9370 100644 --- a/jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java +++ b/jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java @@ -248,6 +248,48 @@ public void nullableArrayTest() { .doTest(); } + @Test + public void arrayParametersNullableArrayVsElements() { + compilationHelper + .setArgs( + JSpecifyJavacConfig.withJSpecifyModeArgs( + Arrays.asList( + "-d", + temporaryFolder.getRoot().getAbsolutePath(), + "-XepOpt:NullAway:AnnotatedPackages=com.uber", + "-XepOpt:NullAway:JarInferEnabled=true"))) + .addSourceLines( + "Test.java", + "package com.uber;", + "import org.jspecify.annotations.Nullable;", + "import com.uber.nullaway.jdkannotations.ParameterAnnotation;", + "class Test {", + " String[] nonNullArray = new String[] {\"value\"};", + " @Nullable String[] nullableElements = new String[] {\"value\", null};", + " String @Nullable [] nullableArray = null;", + " @Nullable String @Nullable [] nullableArrayAndElements = new String[] {\"value\", null};", + " void testCall() {", + " ParameterAnnotation.takesNullableArray(nonNullArray);", + " ParameterAnnotation.takesNullableArray(nullableArray);", + " // BUG: Diagnostic contains: incompatible types", + " ParameterAnnotation.takesNullableArray(nullableElements);", + " // BUG: Diagnostic contains: incompatible types", + " ParameterAnnotation.takesNullableArray(nullableArrayAndElements);", + " ParameterAnnotation.takesNullableElements(nonNullArray);", + " ParameterAnnotation.takesNullableElements(nullableElements);", + " // BUG: Diagnostic contains: passing @Nullable parameter 'nullableArray' where @NonNull is required", + " ParameterAnnotation.takesNullableElements(nullableArray);", + " // BUG: Diagnostic contains: passing @Nullable parameter 'nullableArrayAndElements' where @NonNull is required", + " ParameterAnnotation.takesNullableElements(nullableArrayAndElements);", + " ParameterAnnotation.takesNullableArrayAndElements(nonNullArray);", + " ParameterAnnotation.takesNullableArrayAndElements(nullableElements);", + " ParameterAnnotation.takesNullableArrayAndElements(nullableArray);", + " ParameterAnnotation.takesNullableArrayAndElements(nullableArrayAndElements);", + " }", + "}") + .doTest(); + } + @Test public void nullableGenericArrayTest() { compilationHelper @@ -330,6 +372,84 @@ public void genericParameterTest() { .doTest(); } + @Test + public void varargsNullableArrayOnly() { + compilationHelper + .setArgs( + JSpecifyJavacConfig.withJSpecifyModeArgs( + Arrays.asList( + "-d", + temporaryFolder.getRoot().getAbsolutePath(), + "-XepOpt:NullAway:AnnotatedPackages=com.uber", + "-XepOpt:NullAway:JarInferEnabled=true"))) + .addSourceLines( + "Test.java", + "package com.uber;", + "import com.uber.nullaway.jdkannotations.ParameterAnnotation;", + "class Test {", + " static void testPositive() {", + " // BUG: Diagnostic contains: passing @Nullable parameter '(Object) null' where @NonNull is required", + " ParameterAnnotation.varargsArrayNullable((Object) null);", + " }", + " static void testNegative() {", + " Object[] args = null;", + " ParameterAnnotation.varargsArrayNullable(args);", + " }", + "}") + .doTest(); + } + + @Test + public void varargsNullableElementsOnly() { + compilationHelper + .setArgs( + JSpecifyJavacConfig.withJSpecifyModeArgs( + Arrays.asList( + "-d", + temporaryFolder.getRoot().getAbsolutePath(), + "-XepOpt:NullAway:AnnotatedPackages=com.uber", + "-XepOpt:NullAway:JarInferEnabled=true"))) + .addSourceLines( + "Test.java", + "package com.uber;", + "import com.uber.nullaway.jdkannotations.ParameterAnnotation;", + "class Test {", + " static void testPositive() {", + " Object[] args = null;", + " // BUG: Diagnostic contains: passing @Nullable parameter 'args' where @NonNull is required", + " ParameterAnnotation.varargsElementsNullable(args);", + " }", + " static void testNegative() {", + " ParameterAnnotation.varargsElementsNullable(null, null);", + " }", + "}") + .doTest(); + } + + @Test + public void varargsNullableArrayAndElements() { + compilationHelper + .setArgs( + JSpecifyJavacConfig.withJSpecifyModeArgs( + Arrays.asList( + "-d", + temporaryFolder.getRoot().getAbsolutePath(), + "-XepOpt:NullAway:AnnotatedPackages=com.uber", + "-XepOpt:NullAway:JarInferEnabled=true"))) + .addSourceLines( + "Test.java", + "package com.uber;", + "import com.uber.nullaway.jdkannotations.ParameterAnnotation;", + "class Test {", + " static void testNegative() {", + " ParameterAnnotation.varargs(null, null);", + " Object[] args = null;", + " ParameterAnnotation.varargs(args);", + " }", + "}") + .doTest(); + } + @Test public void libraryLoadMethodParserReturn() { compilationHelper diff --git a/jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java b/jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java index df9f4a0544..62ad1c3423 100644 --- a/jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java +++ b/jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java @@ -24,15 +24,15 @@ public static void printObjectString(@NonNull Object object) { System.out.println(object.toString()); } - @SuppressWarnings("ArrayToString") - public static void takesNullArray(Object @Nullable [] objects) { - System.out.println(objects); - } + public static void takesNullArray(Object @Nullable [] objects) {} - @SuppressWarnings("ArrayToString") - public static void takesNonNullArray(Object[] objects) { - String unused = objects.toString(); - } + public static void takesNullableArray(String @Nullable [] strings) {} + + public static void takesNullableElements(@Nullable String[] strings) {} + + public static void takesNullableArrayAndElements(@Nullable String @Nullable [] strings) {} + + public static void takesNonNullArray(Object[] objects) {} public static class Generic { @@ -45,15 +45,9 @@ public void printObjectString(T t) { } } - @SuppressWarnings("ArrayToString") - public static void takesNullGenericArray(Generic @Nullable [] objects) { - System.out.println(objects); - } + public static void takesNullGenericArray(Generic @Nullable [] objects) {} - @SuppressWarnings("ArrayToString") - public static void takesNonNullGenericArray(Generic[] objects) { - System.out.println(objects); - } + public static void takesNonNullGenericArray(Generic[] objects) {} public static T nullableTypeParam(K k, T t) { return t; @@ -70,4 +64,10 @@ public static void nestedAnnotations( List<@Nullable String> typeArg, @Nullable String[] array, @Nullable List<@Nullable Integer>[] mixed) {} + + public static void varargsArrayNullable(Object @Nullable ... args) {} + + public static void varargsElementsNullable(@Nullable Object... args) {} + + public static void varargs(@Nullable Object @Nullable ... args) {} } diff --git a/jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java b/jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java index 28f6f54a78..51c37d07b8 100644 --- a/jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java +++ b/jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java @@ -19,15 +19,15 @@ public static void printObjectString(Object object) { System.out.println(object.toString()); } - @SuppressWarnings("ArrayToString") - public static void takesNullArray(Object[] objects) { - System.out.println(objects); - } + public static void takesNullArray(Object[] objects) {} - @SuppressWarnings("ArrayToString") - public static void takesNonNullArray(Object[] objects) { - String unused = objects.toString(); - } + public static void takesNullableArray(String[] strings) {} + + public static void takesNullableElements(String[] strings) {} + + public static void takesNullableArrayAndElements(String[] strings) {} + + public static void takesNonNullArray(Object[] objects) {} public static class Generic { @@ -40,15 +40,9 @@ public void printObjectString(T t) { } } - @SuppressWarnings("ArrayToString") - public static void takesNullGenericArray(Generic[] objects) { - System.out.println(objects); - } + public static void takesNullGenericArray(Generic[] objects) {} - @SuppressWarnings("ArrayToString") - public static void takesNonNullGenericArray(Generic[] objects) { - System.out.println(objects); - } + public static void takesNonNullGenericArray(Generic[] objects) {} public static T nullableTypeParam(K k, T t) { return t; @@ -62,4 +56,10 @@ public static void nonNullTypeParam(T t) {} public static void nestedAnnotations( List typeArg, String[] array, List[] mixed) {} + + public static void varargsArrayNullable(Object... args) {} + + public static void varargsElementsNullable(Object... args) {} + + public static void varargs(Object... args) {} } diff --git a/jdk-javac-plugin/src/test/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializerTest.java b/jdk-javac-plugin/src/test/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializerTest.java index c035708b51..760f700510 100644 --- a/jdk-javac-plugin/src/test/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializerTest.java +++ b/jdk-javac-plugin/src/test/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializerTest.java @@ -215,6 +215,182 @@ public void typeParameters() { Map.of())))))); } + @Test + public void varargsNullableArrayOnly() { + compilationTestHelper + .addSourceLines( + "Foo.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Foo {", + " public static int hash(Object @Nullable ... args) { return 0; }", + "}") + .doTest(); + Map> moduleClasses = getParsedJSON(); + assertThat(moduleClasses) + .containsExactlyEntriesOf( + Map.of( + "unnamed", + List.of( + new ClassInfo( + "Foo", + "Foo", + true, + false, + List.of(), + List.of( + new MethodInfo( + "int", + "hash(java.lang.Object@org.jspecify.annotations.Nullable...)", + false, + false, + List.of(), + Map.of())))))); + } + + @Test + public void varargsNullableElementsOnly() { + compilationTestHelper + .addSourceLines( + "Foo.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Foo {", + " public static int hash(@Nullable Object... args) { return 0; }", + "}") + .doTest(); + Map> moduleClasses = getParsedJSON(); + assertThat(moduleClasses) + .containsExactlyEntriesOf( + Map.of( + "unnamed", + List.of( + new ClassInfo( + "Foo", + "Foo", + true, + false, + List.of(), + List.of( + new MethodInfo( + "int", + "hash(java.lang.@org.jspecify.annotations.Nullable Object...)", + false, + false, + List.of(), + Map.of( + 0, + Set.of( + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of( + new TypePathEntry( + TypePathEntry.Kind.ARRAY_ELEMENT, -1))))))))))); + } + + @Test + public void varargsNullableArrayAndElements() { + compilationTestHelper + .addSourceLines( + "Foo.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Foo {", + " public static int hash(@Nullable Object @Nullable... args) { return 0; }", + "}") + .doTest(); + Map> moduleClasses = getParsedJSON(); + assertThat(moduleClasses) + .containsExactlyEntriesOf( + Map.of( + "unnamed", + List.of( + new ClassInfo( + "Foo", + "Foo", + true, + false, + List.of(), + List.of( + new MethodInfo( + "int", + "hash(java.lang.@org.jspecify.annotations.Nullable Object@org.jspecify.annotations.Nullable...)", + false, + false, + List.of(), + Map.of( + 0, + Set.of( + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of( + new TypePathEntry( + TypePathEntry.Kind.ARRAY_ELEMENT, -1))))))))))); + } + + @Test + public void arrayParametersNullableArrayVsElements() { + compilationTestHelper + .addSourceLines( + "Foo.java", + "import org.jspecify.annotations.*;", + "@NullMarked", + "public class Foo {", + " public static void arrayNullable(String @Nullable [] arr) {}", + " public static void elementsNullable(@Nullable String[] arr) {}", + " public static void bothNullable(@Nullable String @Nullable [] arr) {}", + "}") + .doTest(); + Map> moduleClasses = getParsedJSON(); + assertThat(moduleClasses) + .containsExactlyEntriesOf( + Map.of( + "unnamed", + List.of( + new ClassInfo( + "Foo", + "Foo", + true, + false, + List.of(), + List.of( + new MethodInfo( + "void", + "arrayNullable(java.lang.String @org.jspecify.annotations.Nullable [])", + false, + false, + List.of(), + Map.of()), + new MethodInfo( + "void", + "elementsNullable(java.lang.@org.jspecify.annotations.Nullable String[])", + false, + false, + List.of(), + Map.of( + 0, + Set.of( + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of( + new TypePathEntry( + TypePathEntry.Kind.ARRAY_ELEMENT, -1)))))), + new MethodInfo( + "void", + "bothNullable(java.lang.@org.jspecify.annotations.Nullable String @org.jspecify.annotations.Nullable [])", + false, + false, + List.of(), + Map.of( + 0, + Set.of( + new NestedAnnotationInfo( + Annotation.NULLABLE, + ImmutableList.of( + new TypePathEntry( + TypePathEntry.Kind.ARRAY_ELEMENT, -1))))))))))); + } + @Test public void skipNonAnnotatedClasses() { compilationTestHelper