Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates method signature serialization for Nonull formal parameters #213

Merged
merged 5 commits into from
Nov 17, 2023
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
19 changes: 19 additions & 0 deletions annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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");
}
Expand Down
Loading