Closed Goooler closed 2 months ago
The formatter needs to be running on JDK 21 or newer to format Java 21 features.
$ java -version
openjdk version "21.0.4" 2024-07-16 LTS
$ java -jar google-java-format-1.23.0-all-deps.jar Java21Example.java
public class Java21Example {
record Point(int x, int y) {}
public static int recordPattern(Object obj) {
if (obj instanceof Point(int x, int y)) {
return x + y;
}
return 0;
}
}
Oooops, I missed switching my local Java version. Thanks!
Using GJF
1.23.0
and rungoogle-java-format src/main/java/com/shutch/spotless/Java21Example.java
we can see an error:You can repro this in https://github.com/sihutch/spotless-toolchains.