diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java index 58373c509..9ce6cc946 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java @@ -556,4 +556,23 @@ public void nestedParameters() { .toDepth(1) .start(); } + + @Test + public void nonnullTypeUseAnnotationOnFormalParameterAcknowledgmentTest() { + coreTestHelper + .onTarget() + .withSourceLines( + "A.java", + "package test;", + "import org.jetbrains.annotations.NotNull;", + "public class A {", + " static void foo(@NotNull Object o) {}", + " static void bar() { foo(null); }", + "}") + .expectNoReport() + .toDepth(5) + .start(); + // No annotation should be added even though it can reduce the number of errors. + Assert.assertEquals(coreTestHelper.getLog().getInjectedAnnotations().size(), 0); + } } diff --git a/annotator-core/src/test/resources/templates/nullable-multi-modular/build.gradle b/annotator-core/src/test/resources/templates/nullable-multi-modular/build.gradle index c4c50a559..ab8094733 100644 --- a/annotator-core/src/test/resources/templates/nullable-multi-modular/build.gradle +++ b/annotator-core/src/test/resources/templates/nullable-multi-modular/build.gradle @@ -53,6 +53,8 @@ subprojects { // to add @Initializer compileOnly 'com.uber.nullaway:nullaway-annotations:0.10.10' + // to add jetbrains annotations (testing type use vs type declaration) + compileOnly 'org.jetbrains:annotations:24.0.0' compileOnly "org.jspecify:jspecify:0.3.0" compileOnly "com.google.code.findbugs:jsr305:3.0.2" errorprone "com.google.errorprone:error_prone_core:2.3.2" diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java index d62d6b8c8..9bc5e9fcf 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java @@ -24,6 +24,7 @@ import com.google.common.base.Preconditions; import com.sun.tools.javac.code.Symbol; +import edu.ucr.cs.riple.scanner.Serializer; import javax.lang.model.element.ElementKind; /** @@ -66,8 +67,8 @@ public String tabSeparatedToString() { "\t", type.toString(), enclosingClass.flatName(), - enclosingMethod.toString(), - paramSymbol.toString(), + Serializer.serializeSymbol(enclosingMethod), + Serializer.serializeSymbol(paramSymbol), String.valueOf(index), path != null ? path.toString() : "null"); }