Skip to content

Commit 955f679

Browse files
committed
Run NullAway in JSpecify mode
Outside it NullAway takes Guava's @ParametricNullness for @nullable: PeekingIterator.peek() and next(), Iterables.getLast and getOnlyElement, Iterators.getLast. Every token taken from a PeekingIterator<Token> was reported as possibly null. JSpecify mode reads Guava's type parameters instead, and of NullAway's 102 findings 60 remain. On javac 21 the mode needs -XDaddTypeAnnotationsToSymbol=true to see type-use annotations, @nullable among them, on classes read from jars.
1 parent 0c5bc4a commit 955f679

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎buildSrc/src/main/groovy/open-java-format.error-prone-conventions.gradle‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ dependencies {
1212

1313
nullaway {
1414
annotatedPackages.add('com.palantir')
15+
jspecifyMode = true
1516
}
1617

1718
tasks.withType(JavaCompile).configureEach {
19+
// JSpecify mode reads @Nullable on types from class files, which javac 21 does only with this flag.
20+
options.compilerArgs.add('-XDaddTypeAnnotationsToSymbol=true')
1821
options.errorprone {
1922
// Annotation processor output (Immutables) is not ours to fix.
2023
excludedPaths = '.*/build/generated/.*'

0 commit comments

Comments
 (0)