build: bump google-java-format to 1.28.0 for JDK 22+ compatibility#862
Merged
bestbeforetoday merged 1 commit intoJun 10, 2026
Merged
Conversation
Spotless' google-java-format 1.23.0 calls com.sun.tools.javac internals that changed after JDK 21, so `spotlessCheck` fails with NoSuchMethodError (cascading to a Guava NoClassDefFoundError) when the Gradle daemon runs on JDK 22+. CI and JDK 17 developers are unaffected, which is why this only reproduced for some contributors locally. - Bump the Java step's google-java-format 1.23.0 -> 1.28.0. 1.28.0 is the newest release that still runs on JDK 17 (1.29.0+ require JDK 21), matching the daemon/CI toolchain, so it works across JDK 17-25. It produces identical formatting (no reformatting needed). - Pin build-logic's kotlin-dsl compilation to a Java 17 toolchain so the generated precompiled-script-plugin classes load on the daemon regardless of its JDK. Previously they were emitted as JDK 21 bytecode that a JDK 17 daemon could not load (UnsupportedClassVersionError). - Size build-logic's Kotlin compile daemon heap. build-logic is an included build and does not inherit the root gradle.properties, so a cold compile otherwise OOMs.
bestbeforetoday
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
./gradlew spotlessCheckfails for some contributors with lint errors like:It does not reproduce in CI or for everyone — only for developers whose Gradle daemon runs on a newer JDK.
Root cause
google-java-format 1.23.0 (pinned to match ktfmt 0.61's bundled version) calls
com.sun.tools.javacinternals whose signature changed after JDK 21 (e.g.Log$DeferredDiagnosticHandler.getDiagnostics()). When Spotless runs the formatter on JDK 22+, it throwsNoSuchMethodError, which cascades into theNoClassDefFoundErroron a Guava class as the partially-initialized formatter classes are re-referenced. Guava is fully present on the classpath — it's an initialization failure, not a missing dependency. CI and JDK 17 developers are unaffected because 1.23.0 still works on JDK ≤ 21.Verified directly against the cached jars:
NoSuchMethodErrorChanges
googleJavaFormat1.23.0 → 1.28.0. 1.28.0 is the newest release that still runs on JDK 17 (1.29.0+ require JDK 21), so it works across JDK 17–25 and keeps matching the daemon/CI toolchain. It produces identical formatting —spotlessApplyyields no reformatting diff. This step has its own formatter classpath, independent of ktfmt's bundled copy (used only for Kotlin), so the two versions need not match.build-logic's kotlin-dsl compilation to a Java 17 toolchain. Otherwise it emits bytecode for whatever JDK the daemon runs on (e.g. Java 21, class file 65), which a Java 17 daemon cannot load (UnsupportedClassVersionError). Pinning to 17 yields class-61 bytecode that loads on any daemon JVM.build-logic's Kotlin compile-daemon heap.build-logicis an included build and does not inherit the rootgradle.properties, so a cold compile otherwise fails with an OOM / internal compiler error.Testing
spotlessCheckpasses on JDK 17, 21, and 25 daemons.🤖 Generated with AI