Skip to content

Commit

Permalink
Use the ToolProvider SPI to run google-java-format (#1795)
Browse files Browse the repository at this point in the history
This makes the compile-time dependency on google-java-format optional.
  • Loading branch information
cushon authored and ben-manes committed Nov 7, 2024
1 parent 832ab2c commit 8b835c9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
6 changes: 4 additions & 2 deletions caffeine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sourceSets {
val compileJavaPoetJava by tasks.existing
val jammAgent: Configuration by configurations.creating
val collections4Sources: Configuration by configurations.creating
val javaPoetRuntimeOnly: Configuration = configurations["javaPoetRuntimeOnly"]
val javaPoetImplementation: Configuration = configurations["javaPoetImplementation"]

dependencies {
Expand Down Expand Up @@ -75,7 +76,8 @@ dependencies {
javaPoetImplementation(libs.guava)
javaPoetImplementation(libs.javapoet)
javaPoetImplementation(libs.commons.lang3)
javaPoetImplementation(libs.google.java.format)

javaPoetRuntimeOnly(libs.google.java.format)
}

val compileCodeGenJava by tasks.existing(JavaCompile::class) {
Expand Down Expand Up @@ -244,7 +246,7 @@ tasks.named<CheckForbiddenApis>("forbiddenApisMain").configure {

tasks.named<CheckForbiddenApis>("forbiddenApisJavaPoet").configure {
bundledSignatures.addAll(listOf("jdk-deprecated", "jdk-internal",
"jdk-non-portable", "jdk-reflection", "jdk-system-out", "jdk-unsafe"))
"jdk-non-portable", "jdk-reflection", "jdk-unsafe"))
}

tasks.named<CheckForbiddenApis>("forbiddenApisTest").configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.github.benmanes.caffeine.cache.Specifications.BOUNDED_LOCAL_CACHE;
import static com.github.benmanes.caffeine.cache.Specifications.kTypeVar;
import static com.github.benmanes.caffeine.cache.Specifications.vTypeVar;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
Expand All @@ -34,6 +35,7 @@
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.spi.ToolProvider;
import java.util.stream.Stream;

import com.github.benmanes.caffeine.cache.local.AddConstructor;
Expand All @@ -57,8 +59,6 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.io.Resources;
import com.google.googlejavaformat.java.Formatter;
import com.google.googlejavaformat.java.FormatterException;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.ParameterizedTypeName;
Expand Down Expand Up @@ -87,7 +87,7 @@ private LocalCacheFactoryGenerator(Path directory) {
this.factoryTypes = new ArrayList<>();
}

private void generate() throws FormatterException, IOException {
private void generate() throws IOException {
generateLocalCaches();
writeJavaFile();
reformat();
Expand All @@ -106,20 +106,21 @@ private void writeJavaFile() throws IOException {
}
}

private void reformat() throws FormatterException, IOException {
@SuppressWarnings("SystemOut")
private void reformat() throws IOException {
if (Boolean.parseBoolean(System.getenv("JDK_EA"))) {
return; // may be incompatible for EA builds
}
try (Stream<Path> stream = Files.walk(directory)) {
ImmutableList<Path> files = stream
.filter(path -> path.toString().endsWith(".java"))
ImmutableList<String> files = stream
.map(Path::toString)
.filter(path -> path.endsWith(".java"))
.collect(toImmutableList());
var formatter = new Formatter();
for (Path file : files) {
String source = Files.readString(file);
String formatted = formatter.formatSourceAndFixImports(source);
Files.writeString(file, formatted);
}
ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
int result = formatter.run(System.err, System.out,
Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
checkState(result == 0, "Java formatting failed with %s exit code", result);
});
}
}

Expand Down Expand Up @@ -210,7 +211,7 @@ private static String encode(String className) {
.replaceFirst("_REFRESH_WRITE", "R");
}

public static void main(String[] args) throws FormatterException, IOException {
public static void main(String[] args) throws IOException {
new LocalCacheFactoryGenerator(Path.of(args[0])).generate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.github.benmanes.caffeine.cache.Specifications.PACKAGE_NAME;
import static com.github.benmanes.caffeine.cache.Specifications.kTypeVar;
import static com.github.benmanes.caffeine.cache.Specifications.vTypeVar;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
Expand All @@ -33,6 +34,7 @@
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.spi.ToolProvider;
import java.util.stream.Stream;

import com.github.benmanes.caffeine.cache.node.AddConstructors;
Expand All @@ -52,8 +54,6 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.io.Resources;
import com.google.googlejavaformat.java.Formatter;
import com.google.googlejavaformat.java.FormatterException;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.ParameterizedTypeName;
Expand Down Expand Up @@ -89,7 +89,7 @@ private NodeFactoryGenerator(Path directory) {
this.nodeTypes = new ArrayList<>();
}

private void generate() throws FormatterException, IOException {
private void generate() throws IOException {
generatedNodes();
writeJavaFile();
reformat();
Expand All @@ -108,20 +108,21 @@ private void writeJavaFile() throws IOException {
}
}

private void reformat() throws FormatterException, IOException {
@SuppressWarnings("SystemOut")
private void reformat() throws IOException {
if (Boolean.parseBoolean(System.getenv("JDK_EA"))) {
return; // may be incompatible for EA builds
}
try (Stream<Path> stream = Files.walk(directory)) {
ImmutableList<Path> files = stream
.filter(path -> path.toString().endsWith(".java"))
ImmutableList<String> files = stream
.map(Path::toString)
.filter(path -> path.endsWith(".java"))
.collect(toImmutableList());
var formatter = new Formatter();
for (Path file : files) {
String source = Files.readString(file);
String formatted = formatter.formatSourceAndFixImports(source);
Files.writeString(file, formatted);
}
ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
int result = formatter.run(System.err, System.out,

This comment has been minimized.

Copy link
@kluever

kluever Nov 7, 2024

Collaborator

FYI, ArgumentSelectionDefectChecker flagged these params as possibly being swapped...

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

oh thank you. It didn't show up in my build.

Is this because the JDK distributions don't include parameter names in their byte code, but that is enabled in Google's internal JDK?

I removed any extensions or check disablement, and the warnings don't include ArgumentSelectionDefectChecker. Is there any easy way for me to get this same level of detail in by build?

debug build output
caffeine git:(master) ✗ gradle caffeine:compileJavaPoetJava --rerun --no-build-cache --console plain
executing gradlew instead of gradle
Configuration on demand is an incubating feature.
Parallel Configuration Cache is an incubating feature.
Calculating task graph as configuration cache cannot be reused because an input to plugin class 'org.gradle.kotlin.dsl.plugins.precompiled.PrecompiledScriptPlugins' has changed.
> Task :plugins:checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :plugins:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :plugins:extractPrecompiledScriptPluginPlugins
> Task :plugins:compilePluginsBlocks UP-TO-DATE
> Task :plugins:generatePrecompiledScriptPluginAccessors
> Task :plugins:generateScriptPluginAdapters
> Task :plugins:pluginDescriptors UP-TO-DATE
> Task :plugins:processResources UP-TO-DATE
> Task :plugins:compileKotlin
> Task :plugins:compileJava NO-SOURCE
> Task :plugins:classes UP-TO-DATE
> Task :plugins:jar
[compileJavaPoetJava] isEnabled=true, allDisabledChecksAsWarnings=true
> Task :caffeine:downloadCaffeine

> Task :caffeine:compileJavaPoetJava
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [AndroidJdkLibsChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                                   ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [Java7ApiChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                                   ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [Java8ApiChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                                   ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [AndroidJdkLibsChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                          ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [Java7ApiChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Specifications.java:71: warning: [Java8ApiChecker] java.lang.invoke.VarHandle is not available
  public static final TypeName VAR_HANDLE = ClassName.get(VarHandle.class);
                                                          ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:79: warning: [Java7ApiChecker] java.util.List#<E>of(E,E,E,E,E,E,E,E,E,E) is not available in java.util.List
  private final List<NodeRule> rules = List.of(new AddSubtype(), new AddConstructors(),
                                           ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:79: warning: [Java8ApiChecker] java.util.List#<E>of(E,E,E,E,E,E,E,E,E,E) is not available in java.util.List
  private final List<NodeRule> rules = List.of(new AddSubtype(), new AddConstructors(),
                                           ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
warning: [Java7ApiChecker] java.time.ZoneId is not available
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:100: warning: [Java7ApiChecker] java.time.ZoneId is not available
    var timeZone = ZoneId.of("America/Los_Angeles");
                         ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:100: warning: [Java7ApiChecker] java.time.ZoneId is not available
    var timeZone = ZoneId.of("America/Los_Angeles");
                   ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:103: warning: [Java7ApiChecker] java.time.Year is not available
          .addFileComment(header, Year.now(timeZone))
                                      ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:103: warning: [Java7ApiChecker] java.time.Year is not available
          .addFileComment(header, Year.now(timeZone))
                                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:116: warning: [Java7ApiChecker] java.util.stream.Stream is not available
    try (Stream<Path> stream = Files.walk(directory)) {
         ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:116: warning: [Java7ApiChecker] java.nio.file.Files#walk(java.nio.file.Path,java.nio.file.FileVisitOption...) is not available in java.nio.file.Files
    try (Stream<Path> stream = Files.walk(directory)) {
                                    ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:120: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .collect(toImmutableList());
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:119: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .filter(path -> path.endsWith(".java"))
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:118: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .map(Path::toString)
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.Optional is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                                                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:121: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:122: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:122: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:122: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
            ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:123: warning: [Java7ApiChecker] java.util.Collection#stream() is not available in com.google.common.collect.ImmutableList
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                                ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:131: warning: [Java7ApiChecker] java.util.Map#forEach(java.util.function.BiConsumer<? super K,? super V>) is not available in java.util.NavigableMap
    classNameToFeatures.forEach((className, features) -> {
                       ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:193: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var keyStrengths = Set.of(Feature.STRONG_KEYS, Feature.WEAK_KEYS);
                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:193: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var keyStrengths = Set.of(Feature.STRONG_KEYS, Feature.WEAK_KEYS);
                          ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:194: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E,E) is not available in java.util.Set
    var valueStrengths = Set.of(Feature.STRONG_VALUES, Feature.WEAK_VALUES, Feature.SOFT_VALUES);
                            ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:194: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E,E) is not available in java.util.Set
    var valueStrengths = Set.of(Feature.STRONG_VALUES, Feature.WEAK_VALUES, Feature.SOFT_VALUES);
                            ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:195: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var expireAfterAccess = Set.of(false, true);
                               ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:195: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var expireAfterAccess = Set.of(false, true);
                               ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:196: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var expireAfterWrite = Set.of(false, true);
                              ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:196: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var expireAfterWrite = Set.of(false, true);
                              ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:197: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var refreshAfterWrite = Set.of(false, true);
                               ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:197: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var refreshAfterWrite = Set.of(false, true);
                               ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:198: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var maximumSize = Set.of(false, true);
                         ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:198: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var maximumSize = Set.of(false, true);
                         ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:199: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var weighed = Set.of(false, true);
                     ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:199: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    var weighed = Set.of(false, true);
                     ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:222: warning: [Java7ApiChecker] java.nio.file.Path#of(java.lang.String,java.lang.String...) is not available in java.nio.file.Path
    new NodeFactoryGenerator(Path.of(args[0])).generate();
                                 ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:222: warning: [Java8ApiChecker] java.nio.file.Path#of(java.lang.String,java.lang.String...) is not available in java.nio.file.Path
    new NodeFactoryGenerator(Path.of(args[0])).generate();
                                 ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Feature.java:63: warning: [Java7ApiChecker] java.util.stream.Stream is not available
        .collect(joining("_"));
        ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Feature.java:62: warning: [Java7ApiChecker] java.util.stream.Stream is not available
        .map(Feature::name)
        ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Feature.java:63: warning: [Java7ApiChecker] java.util.stream.Collectors is not available
        .collect(joining("_"));
                 ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:52: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:65: warning: [Java7ApiChecker] java.util.function.Consumer is not available
  final List<Consumer<CodeBlock.Builder>> varHandles;
             ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:86: warning: [AvoidObjectArrays] Avoid returning a Modifier[]; consider an ImmutableList<Modifier> instead
  public Modifier[] publicFinalModifiers() {
                 ^
    (see https://errorprone.info/bugpattern/AvoidObjectArrays)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [AndroidJdkLibsChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                                    ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [Java7ApiChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                                    ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [Java8ApiChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                                    ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [AndroidJdkLibsChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                           ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [Java7ApiChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                           ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:131: warning: [Java8ApiChecker] java.lang.invoke.VarHandle is not available
    nodeSubtype.addField(FieldSpec.builder(VarHandle.class, fieldName,
                                           ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeContext.java:133: warning: [Java7ApiChecker] java.util.function.Consumer is not available
    Consumer<CodeBlock.Builder> statement = builder -> builder
    ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:77: warning: [Java7ApiChecker] java.util.List#<E>of(E...) is not available in java.util.List
  private final List<LocalCacheRule> rules = List.of(new AddSubtype(), new AddConstructor(),
                                                 ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:77: warning: [Java8ApiChecker] java.util.List#<E>of(E...) is not available in java.util.List
  private final List<LocalCacheRule> rules = List.of(new AddSubtype(), new AddConstructor(),
                                                 ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
warning: [Java7ApiChecker] java.time.ZoneId is not available
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:98: warning: [Java7ApiChecker] java.time.ZoneId is not available
    var timeZone = ZoneId.of("America/Los_Angeles");
                         ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:98: warning: [Java7ApiChecker] java.time.ZoneId is not available
    var timeZone = ZoneId.of("America/Los_Angeles");
                   ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:100: warning: [AndroidJdkLibsChecker] java.lang.Class#getPackageName() is not available in java.lang.Class
      JavaFile.builder(getClass().getPackageName(), typeSpec)
                                 ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:100: warning: [Java7ApiChecker] java.lang.Class#getPackageName() is not available in java.lang.Class
      JavaFile.builder(getClass().getPackageName(), typeSpec)
                                 ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:100: warning: [Java8ApiChecker] java.lang.Class#getPackageName() is not available in java.lang.Class
      JavaFile.builder(getClass().getPackageName(), typeSpec)
                                 ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:101: warning: [Java7ApiChecker] java.time.Year is not available
          .addFileComment(header, Year.now(timeZone))
                                      ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:101: warning: [Java7ApiChecker] java.time.Year is not available
          .addFileComment(header, Year.now(timeZone))
                                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:114: warning: [Java7ApiChecker] java.util.stream.Stream is not available
    try (Stream<Path> stream = Files.walk(directory)) {
         ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:114: warning: [Java7ApiChecker] java.nio.file.Files#walk(java.nio.file.Path,java.nio.file.FileVisitOption...) is not available in java.nio.file.Files
    try (Stream<Path> stream = Files.walk(directory)) {
                                    ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:118: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .collect(toImmutableList());
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:117: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .filter(path -> path.endsWith(".java"))
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:116: warning: [Java7ApiChecker] java.util.stream.Stream is not available
          .map(Path::toString)
          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [Java7ApiChecker] java.util.Optional is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                                                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
                  ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:119: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
      ToolProvider.findFirst("google-java-format").ifPresent(formatter -> {
      ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:120: warning: [AndroidJdkLibsChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/AndroidJdkLibsChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:120: warning: [Java7ApiChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:120: warning: [Java8ApiChecker] java.util.spi.ToolProvider is not available
        int result = formatter.run(System.err, System.out,
                              ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                  ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
            ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.stream.Stream is not available
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                          ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:121: warning: [Java7ApiChecker] java.util.Collection#stream() is not available in com.google.common.collect.ImmutableList
            Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
                                                ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:129: warning: [Java7ApiChecker] java.util.Map#forEach(java.util.function.BiConsumer<? super K,? super V>) is not available in java.util.NavigableMap
    classNameToFeatures.forEach((className, features) -> {
                       ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:165: warning: [Java7ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    List<Set<Boolean>> sets = Collections.nCopies(featureByIndex.length, Set.of(true, false));
                                                                            ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:165: warning: [Java8ApiChecker] java.util.Set#<E>of(E,E) is not available in java.util.Set
    List<Set<Boolean>> sets = Collections.nCopies(featureByIndex.length, Set.of(true, false));
                                                                            ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:215: warning: [Java7ApiChecker] java.nio.file.Path#of(java.lang.String,java.lang.String...) is not available in java.nio.file.Path
    new LocalCacheFactoryGenerator(Path.of(args[0])).generate();
                                       ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:215: warning: [Java8ApiChecker] java.nio.file.Path#of(java.lang.String,java.lang.String...) is not available in java.nio.file.Path
    new LocalCacheFactoryGenerator(Path.of(args[0])).generate();
                                       ^
    (see https://errorprone.info/bugpattern/Java8ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/LocalCacheContext.java:31: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/LocalCacheContext.java:59: warning: [AvoidObjectArrays] Avoid returning a Modifier[]; consider an ImmutableList<Modifier> instead
  public Modifier[] publicFinalModifiers() {
                 ^
    (see https://errorprone.info/bugpattern/AvoidObjectArrays)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/LocalCacheContext.java:65: warning: [AvoidObjectArrays] Avoid returning a Modifier[]; consider an ImmutableList<Modifier> instead
  public Modifier[] protectedFinalModifiers() {
                 ^
    (see https://errorprone.info/bugpattern/AvoidObjectArrays)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddExpirationTicker.java:27: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddMaximum.java:29: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddStats.java:28: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddPacer.java:27: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/Finalize.java:23: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddDeques.java:29: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddExpireAfterWrite.java:25: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddExpireAfterAccess.java:28: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddRefreshAfterWrite.java:25: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddKeyValueStrength.java:29: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddRemovalListener.java:27: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/AddFastPath.java:25: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author [email protected] (Ben Manes)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
warning: [Java7ApiChecker] java.util.function.Consumer is not available
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/Finalize.java:63: warning: [Java7ApiChecker] java.util.function.Consumer is not available
      varHandle.accept(codeBlock);
               ^
    (see https://errorprone.info/bugpattern/Java7ApiChecker)
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/AddFactoryMethods.java:35: warning: [MissingSummary] A summary line is required on public/protected Javadocs.
 * @author github.com/jvassev (Julian Vassev)
   ^
    (see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment)
124 warnings
[Incubating] Problems report is available at: file:///Users/ben/projects/caffeine/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.11-rc-2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 8s
11 actionable tasks: 7 executed, 4 up-to-date

Publishing build scan...
https://caffeine.gradle-enterprise.cloud/s/3rthp4jfn22v6

Configuration cache entry stored.

This comment has been minimized.

Copy link
@kluever

kluever Nov 7, 2024

Collaborator

Hmm, not entirely sure. @cushon might know?

https://errorprone.info/docs/inlineme has some instructions on how to enable the -parameters flag in diff builds...maybe that would help?

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

yeah, I tried that locally but that applies to the byte code produced for my jars. This would require -parameters on the jdk classes, which does not appear to be enabled in the common distributions. Since Google has its own internally my guess is that does so its caught. (just a theory)

This comment has been minimized.

Copy link
@cushon

cushon Nov 7, 2024

Author Contributor

I think the JDK doesn't include MethodParameters attributes (even for our internal build), but that javac can sometimes use the local variable table to figure out parameter names.

I'm able to get ArgumentSelectionDefectChecker errors for java.util.spi.ToolProvider using stock OpenJDK 21, but only when passing -parameters to the javac invocation for Error Prone. I think that javac is only filling in param names from class files if -parameters is enabled for the current compilation.

Does enabling -parameters for caffeine allow that diagnostic to be produced?

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

Does enabling -parameters for caffeine allow that diagnostic to be produced?

not in my experimenting when I tried adding it to the compiler flags.

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

oh its because I'm using jdk 11 as my default --release target, whereas if I override that to jdk 21 then it shows up once -parameters is included. Does it make sense to enable -parameters everywhere, e.g. for the produced jar? I know it adds some small byte code bloat, and am unsure if its a net benefit or not otherwise.

caffeine git:(v3.dev) ✗ JAVA_VERSION=21 gradle caffeine:compileJavaPoetJava --rerun --no-build-cache --console plain
executing gradlew instead of gradle
Configuration on demand is an incubating feature.
Parallel Configuration Cache is an incubating feature.
Calculating task graph as configuration cache cannot be reused because an input to plugin class 'org.gradle.kotlin.dsl.plugins.precompiled.PrecompiledScriptPlugins' has changed.
> Task :plugins:checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :plugins:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :plugins:extractPrecompiledScriptPluginPlugins
> Task :plugins:compilePluginsBlocks UP-TO-DATE
> Task :plugins:generatePrecompiledScriptPluginAccessors
> Task :plugins:generateScriptPluginAdapters
> Task :plugins:pluginDescriptors UP-TO-DATE
> Task :plugins:processResources UP-TO-DATE
> Task :plugins:compileKotlin
> Task :plugins:compileJava NO-SOURCE
> Task :plugins:classes UP-TO-DATE
> Task :plugins:jar
> Task :caffeine:downloadCaffeine

> Task :caffeine:compileJavaPoetJava
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java:122: warning: [ArgumentSelectionDefectChecker] The following arguments may have been swapped: 'System.err' for formal parameter 'out', 'System.out' for formal parameter 'err'. Either add clarifying `/* paramName= */` comments, or swap the arguments if that is what was intended
        int result = formatter.run(System.err, System.out,
                                  ^
    (see https://errorprone.info/bugpattern/ArgumentSelectionDefectChecker)
  Did you mean 'int result = formatter.run(/* out= */System.err, /* err= */System.out,' or 'int result = formatter.run(System.out, System.err,'?
/Users/ben/projects/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java:120: warning: [ArgumentSelectionDefectChecker] The following arguments may have been swapped: 'System.err' for formal parameter 'out', 'System.out' for formal parameter 'err'. Either add clarifying `/* paramName= */` comments, or swap the arguments if that is what was intended
        int result = formatter.run(System.err, System.out,
                                  ^
    (see https://errorprone.info/bugpattern/ArgumentSelectionDefectChecker)
  Did you mean 'int result = formatter.run(/* out= */System.err, /* err= */System.out,' or 'int result = formatter.run(System.out, System.err,'?
2 warnings

> Task :caffeine:processJavaPoetResources UP-TO-DATE
> Task :caffeine:javaPoetClasses
> Task :caffeine:generateNodes
> Task :caffeine:generateLocalCaches
[Incubating] Problems report is available at: file:///Users/ben/projects/caffeine/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.11-rc-2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 12s
14 actionable tasks: 9 executed, 5 up-to-date

Publishing build scan...
https://caffeine.gradle-enterprise.cloud/s/2k2jnxglb4btc

Configuration cache entry stored.

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

There is a slight increase (64kb) to the jar due to the generated classes, which are compiled separately. Those already disable the debug details in the byte code (-g:none), and if I only remove -parameters from that task then the size changes are noise, so it seems like a nice improvement.

This comment has been minimized.

Copy link
@cpovirk

cpovirk Nov 7, 2024

Collaborator

No one complained to us when we added -parameters for Guava two years ago: google/guava@59d174c

Not that that guarantees anything :)

This comment has been minimized.

Copy link
@cushon

cushon Nov 7, 2024

Author Contributor

I think the downsides are the bytecode size, and also that the parameter names are now easier for clients to depend on (e.g. if they wrote an annotation processor to inspect them). So renaming parameters is now slightly more of a breaking change.

In practice my opinion is that the bytecode size increase is pretty minor, and that I wouldn't let enabling -parameters stop me from renaming parameters.

This comment has been minimized.

Copy link
@ben-manes

ben-manes Nov 7, 2024

Owner

perfect, this is merged to master. Thanks @kluever for flagging!

Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new));
checkState(result == 0, "Java formatting failed with %s exit code", result);
});
}
}

Expand Down Expand Up @@ -217,7 +218,7 @@ private static String encode(String className) {
.replaceFirst("_SIZE", "S");
}

public static void main(String[] args) throws FormatterException, IOException {
public static void main(String[] args) throws IOException {
new NodeFactoryGenerator(Path.of(args[0])).generate();
}
}

0 comments on commit 8b835c9

Please sign in to comment.