Fix spotless:apply failure on modern JDKs#777
Merged
Divyansh-db merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
Pin google-java-format to 1.22.0 explicitly so the code-generator's post-generate step no longer crashes with NoSuchMethodError on JDK 25. The spotless-maven-plugin 2.30.0 default GJF (1.15.0) calls a javac internal (Log$DeferredDiagnosticHandler.getDiagnostics) whose signature changed in JDK 21+. 1.22.0 is the last GJF release that still supports JRE 11, keeping local dev and the JDK 11 fmt CI job working. Add scripts/mvn-spotless-apply.sh as a drop-in wrapper that exports --add-exports MAVEN_OPTS for jdk.compiler internals on JDK 16+, which GJF needs to access javac's tokenizer/parser under the module system. The wrapper detects the JDK version so older JDKs are untouched. .codegen.json's post_generate step now invokes the wrapper. One-time reformat of 6 files (16 blank lines added) under GJF 1.22.0's stricter rules around documented fields; no semantic changes. Co-authored-by: Isaac
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
parthban-db
approved these changes
Apr 23, 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.
Summary
google-java-formatto 1.22.0 in the rootpom.xmlsomvn spotless:applystops crashing on modern JDKs(the code generator runs on JDK 25, where spotless-maven-plugin 2.30.0's bundled GJF 1.15.0 throws
NoSuchMethodErroragainst the renamedcom.sun.tools.javac.util.Log$DeferredDiagnosticHandler.getDiagnostics()signature). 1.22.0 is the last GJF release that still supports JRE 11, keeping local dev and the JDK 11
fmtCI jobworking.
scripts/mvn-spotless-apply.sh, a drop-in wrapper that exportsMAVEN_OPTSwith the--add-exports=jdk.compiler/com.sun.tools.javac.*=ALL-UNNAMEDflags required by GJF on JDK 16+. It detects the JDKmajor version and only sets the flags when needed, so older JDKs (including the JDK 8 CI matrix rows) are untouched.
.codegen.json'spost_generatenow invokes the wrapper instead ofmvn spotless:applydirectly, mirroring theexisting
bash scripts/cleanup-services.shpattern.blank lines between documented fields. No semantic changes.
Why a wrapper script and not
.mvn/jvm.config?.mvn/jvm.configapplies to every Maven invocation, and this repo's CI matrix runsmvn test/ release jobs underJDK 8, where
--add-exportsis an unrecognized arg and Maven would fail to start. Scoping the flags to the onecommand that actually needs them (
spotless:apply) avoids that blast radius.Impact on CI
fmt(JDK 11 →spotless:check): GJF 1.22.0 loads fine on JRE 11.unit-testsmatrix (JDK 8/11/17/20 →mvn test): unaffected, spotless plugin has no<execution>binding so itnever runs during tests.
release-build-check/package(JDK 8): unaffected, same reason.Test plan
mvn spotless:checkpasses on local JDK 11 after the reformatmvn spotless:applyon clean HEAD (after pom bump) produces the expected 6-file reformat only; subsequent runsare no-ops (idempotent)
bash scripts/mvn-spotless-apply.shon JDK 11 correctly skips theMAVEN_OPTSexport (JDK < 16) anddelegates to
mvn spotless:applywithBUILD SUCCESSNO_CHANGELOG=true