Skip to content

Commit

Permalink
include method parameters in class file for use by static analyzers
Browse files Browse the repository at this point in the history
This allows errorprone to now detects ArgumentSelectionDefectChecker
and ParameterName warnings, which are now resolved. The jar size
changes are negligible because we exclude this addition in our
generated code where it is not necessary.
  • Loading branch information
ben-manes committed Nov 7, 2024
1 parent 8b835c9 commit ad540e3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
18 changes: 11 additions & 7 deletions caffeine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ dependencies {
val compileCodeGenJava by tasks.existing(JavaCompile::class) {
classpath = sourceSets["main"].runtimeClasspath + sourceSets["main"].output
dependsOn(tasks.compileJava)
options.isDebug = false

options.errorprone {
disable("FieldMissingNullable")
disable("MissingOverride")
disable("MemberName")
disable("Varifier")
nullaway.disable()
options.apply {
compilerArgs.remove("-parameters")
isDebug = false

errorprone {
disable("FieldMissingNullable")
disable("MissingOverride")
disable("MemberName")
disable("Varifier")
nullaway.disable()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void reformat() throws IOException {
.filter(path -> path.endsWith(".java"))
.collect(toImmutableList());
ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
int result = formatter.run(System.err, System.out,
int result = formatter.run(System.out, System.err,
Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
checkState(result == 0, "Java formatting failed with %s exit code", result);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void reformat() throws IOException {
.filter(path -> path.endsWith(".java"))
.collect(toImmutableList());
ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
int result = formatter.run(System.err, System.out,
int result = formatter.run(System.out, System.err,
Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
checkState(result == 0, "Java formatting failed with %s exit code", result);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ default void handleCompletion(K key, CompletableFuture<? extends V> valueFuture,
long startTime, boolean recordMiss) {
var completed = new AtomicBoolean();
valueFuture.whenComplete((value, error) -> {
if (!completed.compareAndSet(false, true)) {
if (!completed.compareAndSet(/* expectedValue= */ false, /* newValue= */ true)) {
// Ignore multiple invocations due to ForkJoinPool retrying on delays
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ tasks.withType<JavaCompile>().configureEach {
}

options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-auxiliaryclass", "-Xlint:-classfile",
"-Xlint:-exports", "-Xlint:-processing", "-Xlint:-removal", "-Xlint:-requires-automatic"))
"-Xlint:-exports", "-Xlint:-processing", "-Xlint:-removal", "-Xlint:-requires-automatic",
"-parameters"))
if (javaVersion.canCompileOrRun(21)) {
options.compilerArgs.add("-proc:full")
}
Expand Down

0 comments on commit ad540e3

Please sign in to comment.