File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations
test-annotated/src/main/java/com/uber/nullaway/jdkannotations
test-unannotated/src/main/java/com/uber/nullaway/jdkannotations Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,32 @@ public void nullableArrayTest() {
247247 .doTest ();
248248 }
249249
250+ @ Test
251+ public void nullableGenericArrayTest () {
252+ compilationHelper
253+ .setArgs (
254+ Arrays .asList (
255+ "-d" ,
256+ temporaryFolder .getRoot ().getAbsolutePath (),
257+ "-XepOpt:NullAway:AnnotatedPackages=com.uber" ,
258+ "-XepOpt:NullAway:JSpecifyMode=true" ,
259+ "-XepOpt:NullAway:JarInferEnabled=true" ))
260+ .addSourceLines (
261+ "Test.java" ,
262+ "package com.uber;" ,
263+ "import com.uber.nullaway.jdkannotations.ParameterAnnotation;" ,
264+ "class Test {" ,
265+ " static void testPositive() {" ,
266+ " // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required" ,
267+ " ParameterAnnotation.takesNonNullGenericArray(null);" ,
268+ " }" ,
269+ " static void testNegative() {" ,
270+ " ParameterAnnotation.takesNullGenericArray(null);" ,
271+ " }" ,
272+ "}" )
273+ .doTest ();
274+ }
275+
250276 @ Test
251277 public void genericParameterTest () {
252278 compilationHelper
Original file line number Diff line number Diff line change @@ -43,4 +43,14 @@ public void printObjectString(T t) {
4343 System .out .println (t .toString ());
4444 }
4545 }
46+
47+ @ SuppressWarnings ("ArrayToString" )
48+ public static void takesNullGenericArray (Generic <String > @ Nullable [] objects ) {
49+ System .out .println (objects );
50+ }
51+
52+ @ SuppressWarnings ("ArrayToString" )
53+ public static void takesNonNullGenericArray (Generic <String >[] objects ) {
54+ System .out .println (objects );
55+ }
4656}
Original file line number Diff line number Diff line change 11package com .uber .nullaway .jdkannotations ;
22
3+ import org .jspecify .annotations .Nullable ;
4+
35public class ParameterAnnotation {
46 public static Integer add (Integer a , Integer b ) {
57 return a + b ;
@@ -37,4 +39,14 @@ public void printObjectString(T t) {
3739 System .out .println (t .toString ());
3840 }
3941 }
42+
43+ @ SuppressWarnings ("ArrayToString" )
44+ public static void takesNullGenericArray (Generic <String > @ Nullable [] objects ) {
45+ System .out .println (objects );
46+ }
47+
48+ @ SuppressWarnings ("ArrayToString" )
49+ public static void takesNonNullGenericArray (Generic <String >[] objects ) {
50+ System .out .println (objects );
51+ }
4052}
You can’t perform that action at this time.
0 commit comments