Skip to content

Bump google-java-format to 1.27.0 and fmt CI JDK to 17#778

Merged
Divyansh-db merged 3 commits intomainfrom
fix-formatter-jdk25
Apr 30, 2026
Merged

Bump google-java-format to 1.27.0 and fmt CI JDK to 17#778
Divyansh-db merged 3 commits intomainfrom
fix-formatter-jdk25

Conversation

@Divyansh-db
Copy link
Copy Markdown
Contributor

@Divyansh-db Divyansh-db commented Apr 24, 2026

Summary

Two-part fix that gets mvn spotless:apply working on the JDK 25 code-generator environment and keeps it ergonomic for contributors whose default JDK is still 11.

1. Upgrade google-java-format and the fmt CI JDK

Follow-up to #777. That PR pinned GJF to 1.22.0 under the assumption it had the JDK 25 fix — it doesn't. GJF 1.22.0 still calls the old Queue-returning Log$DeferredDiagnosticHandler.getDiagnostics() signature that OpenJDK removed in JDK 23+, so the code generator (JDK 25) continued crashing with the same NoSuchMethodError.

  • Bump GJF to 1.27.0 in pom.xml — first release with the DeferredDiagnosticHandler API-change fix (Google's commit 96f114c, shipped 2025-05-06).
  • Bump fmt CI job to JDK 17 in .github/workflows/push.yml — GJF 1.25.0+ requires JRE 17 to run, so any version that supports JDK 25 forces a JDK floor bump for the one job that invokes spotless. No GJF version supports both JRE 11 and JDK 25.

2. Local-dev ergonomics

Because GJF 1.27.0 needs JRE 17 to load, mvn spotless:apply on a JDK 11 default crashes with UnsupportedClassVersionError. To keep make fmt working transparently for contributors still on JDK 11:

  • make fmt-jdk17 — new target, runs JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 mvn spotless:apply.
  • make fmt — now falls back to fmt-jdk17 automatically if the default-JDK attempt fails. The first attempt still runs visibly (so a genuine non-JDK error wouldn't be hidden), then a clear ==> Retrying with JDK 17... message before the fallback.

Contributors on JDK 17+ as their default see no behavioral change. Contributors on JDK 11 don't have to learn the new JDK pinning incantation — make fmt just works.

Scope of the JDK bump

Only the fmt job moves. The rest of CI is untouched:

  • unit-tests matrix (JDK 8/11/17/20 running mvn test): unaffected. Spotless has no <execution> binding, so mvn test never loads GJF.
  • release-build-check.yml / package.yml (JDK 8): unaffected, same reason.
  • check-lock job (JDK 11): unaffected.
  • Compiled bytecode target stays Java 8 via maven-compiler-plugin.

Test plan

Verified locally against all three JDKs available on the dev machine:

  • JDK 17JAVA_HOME=.../java-17-openjdk-amd64 mvn spotless:checkBUILD SUCCESS
  • JDK 11 — fails with UnsupportedClassVersionError: ... class file version 61.0, this version of the Java Runtime only recognizes class file versions up to 55.0. Intentional floor; no CI job invokes spotless under JDK 11.
  • JDK 25JAVA_HOME=.../temurin-25-jdk-amd64 bash scripts/mvn-spotless-apply.shBUILD SUCCESS (~13s). End-to-end reproduction of the generator's environment.
  • make fmt on JDK 11 — first attempt fails as expected, fallback message appears, then JDK 17 path runs and succeeds. Net result: BUILD SUCCESS.
  • make fmt-jdk17 directlyBUILD SUCCESS in ~14s on a default-JDK-11 shell.
  • genkit update-sdk end-to-end on JDK 11 — succeeds (1325 tests, 0 failures). The local generator workflow is not blocked.
  • git diff --stat after running spotless:apply on a clean tree shows no source-file reformats required by GJF 1.27.0 — diff is just config edits.
  • CI: fmt (now JDK 17), all unit-tests matrix rows, release-build-check, check-lock all green.

NO_CHANGELOG=true

Follow-up to #777. Pinning GJF to 1.22.0 did not fix the JDK 25
generator crash because 1.22.0 still calls the old Queue-returning
Log$DeferredDiagnosticHandler.getDiagnostics() signature that JDK 23+
removed. GJF 1.27.0 is the first release with the DeferredDiagnosticHandler
compatibility fix, but it requires JRE 17+ to run. Bump the fmt CI job's
java-version from 11 to 17 to match.

The unit-tests matrix (JDK 8/11/17/20), release-build-check (JDK 8) and
check-lock (JDK 11) are unaffected - none invoke spotless. Compiled
bytecode target remains Java 8.

Verified locally:
- JDK 17: spotless:check passes
- JDK 11: UnsupportedClassVersionError (intentional floor, class file v61.0)
- JDK 25: scripts/mvn-spotless-apply.sh returns BUILD SUCCESS

Co-authored-by: Isaac
Since pom.xml now pins google-java-format 1.27.0 (requires JRE 17+ to
load), running `make fmt` on a default JDK older than 17 fails with
UnsupportedClassVersionError. Add a `fmt-jdk17` target that explicitly
points JAVA_HOME at /usr/lib/jvm/java-17-openjdk-amd64, and have `fmt`
fall back to it automatically when the default JDK can't run the
formatter.

Behavior:
- Default JDK >= 17: `make fmt` works as before, fallback never runs.
- Default JDK < 17: first attempt fails loudly (so genuine non-JDK
  errors aren't hidden), then transparently retries via fmt-jdk17.
- `make fmt-jdk17` is also usable directly.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 778
  • Commit SHA: 934a8a1ac7ee78dbc8b91a3834303398ab59c3ae

Checks will be approved automatically on success.

@Divyansh-db Divyansh-db enabled auto-merge April 30, 2026 17:54
@Divyansh-db Divyansh-db added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit afd4e0b Apr 30, 2026
18 checks passed
@Divyansh-db Divyansh-db deleted the fix-formatter-jdk25 branch April 30, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants