Skip to content

build: Add Java 25 build compatibility#232

Merged
usmansaleem merged 2 commits into
Consensys:masterfrom
usmansaleem:java25-compat
May 15, 2026
Merged

build: Add Java 25 build compatibility#232
usmansaleem merged 2 commits into
Consensys:masterfrom
usmansaleem:java25-compat

Conversation

@usmansaleem
Copy link
Copy Markdown
Contributor

@usmansaleem usmansaleem commented May 14, 2026

PR Description

Upgrade the build toolchain so the project compiles cleanly under both Java 21 (CI) and Java 25 (local default JDK), in preparation for the eventual Java 25 jump after Besu and Teku move. No source-level Java version bump — produced bytecode remains classfile 65 (Java 21).

Build infrastructure changes

Change From To Reason
Gradle wrapper 8.8 9.5.1 Minimum Gradle for JDK 25 (JEP 472 native-access support)
Spotless plugin 6.25.0 8.4.0 6.x caps at GJF 1.24; 8.x supports GJF 1.35 + Gradle 9
Google Java Format 1.17.0 1.35.0 1.17 crashed on JDK 25 javac internals (Log$DeferredDiagnosticHandler.getDiagnostics() signature change)
spring dependency-management 1.1.5 1.1.7 1.1.5 broken on Gradle 9
sourceCompatibility/targetCompatibility top-level inside java { toolchain { languageVersion = 21 } } Top-level form removed in Gradle 9
testRuntimeOnly junit-platform-launcher (auto-loaded) explicit Gradle 9 stopped auto-loading it
hierynomus.license plugin 0.16.1 (removed) Unmaintained since 2021; downloadLicenses broken on Gradle 9
Header enforcement hierynomus Spotless licenseHeaderFile Single source of truth alongside formatting
Dependency license audit hierynomus downloadLicenses / custom checkLicenses com.github.jk1.dependency-license-report 3.1.2 Actively maintained, Gradle-9 compatible. New config in gradle/allowed-licenses.json and gradle/license-normalizer-bundle.json. Verified by temporarily adding an LGPL dep — checkLicense rejected it correctly.
org.gradle.jvmargs (unchanged) + --enable-native-access=ALL-UNNAMED Silences JEP-472 restricted-method warnings on JDK 24+ (no-op on JDK 21)

Also fixed two Gradle 10-deprecated DSL lines: maven { url = ... } and groupId = ... (groovy_space_assignment_syntax).

Source changes

Spotless's licenseHeaderFile normalizes the blank line between the SPDX header and package on 62 source files that previously missed it. Pure whitespace, no logic changes.

CI

CI continues to build on Java 21 only. ./gradlew build task graph still includes :checkLicense (wired via check.dependsOn 'checkLicense'), so the license safety net runs on every PR.

Test plan

  • ./gradlew build clean on JDK 25 + Gradle 9.5.1 — green, no warnings, bytecode classfile 65
  • ./gradlew build clean on JDK 21 + Gradle 9.5.1 (toolchain provisioned) — green apart from a known pre-existing flake DiscoveryIntegrationTest.shouldRecoverAfterErrorWhileDecodingInboundMessage (unrelated; reproduces on master too)
  • ./gradlew checkLicense correctly rejects an unapproved license — tested by temporarily adding org.jfree:jfreechart:1.5.4 (LGPL-2.1); build failed with GNU LESSER GENERAL PUBLIC LICENSE, Version 3 is not on the allowed list
  • No deprecation warnings on Gradle 9.5.1 (verified with --warning-mode=all)

Fixed Issue(s)


Note

Medium Risk
Moderate risk because it upgrades the Gradle wrapper to 9.5.1 and replaces the dependency license-check mechanism, which can change CI/build behavior and potentially fail builds due to stricter license normalization/allowlisting.

Overview
Enables building on newer JDKs by upgrading the Gradle wrapper to 9.5.1, moving Java versioning to a java { toolchain { languageVersion = 21 } } configuration, adding --enable-native-access=ALL-UNNAMED to Gradle JVM args, and explicitly adding junit-platform-launcher at test runtime.

Replaces the old hierynomus.license/custom checkLicenses flow with com.github.jk1.dependency-license-report and a new allowlist+normalization setup (gradle/allowed-licenses.json, gradle/license-normalizer-bundle.json), wiring check to depend on checkLicense.

Updates formatting/header enforcement by upgrading Spotless and Google Java Format, shifting license header insertion to Spotless (gradle/java.license), and applies whitespace-only header normalization across many Java sources; regenerates gradlew/gradlew.bat accordingly.

Reviewed by Cursor Bugbot for commit 6c18606. Bugbot is set up for automated code reviews on this repo. Configure here.

Upgrade the build toolchain so the project compiles cleanly under both
Java 21 (CI) and Java 25 (local default JDK), in preparation for the
eventual Java 25 jump after Besu and Teku move.

* Gradle wrapper 8.8 -> 9.5.1 (minimum for JDK 25)
* Spotless 6.25.0 -> 8.4.0, Google Java Format 1.17.0 -> 1.35.0
  (1.17 crashed on JDK 25 javac internals)
* spring dependency-management 1.1.5 -> 1.1.7 (1.1.5 broken on Gradle 9)
* Move sourceCompatibility/targetCompatibility into a java { toolchain }
  block; top-level form removed in Gradle 9
* Add explicit testRuntimeOnly junit-platform-launcher (Gradle 9 stopped
  auto-loading it)
* Replace the unmaintained hierynomus.license plugin (broken on Gradle 9)
  with Spotless licenseHeaderFile for header enforcement and
  jk1.dependency-license-report 3.1.2 for the third-party license audit
* gradle.properties: add --enable-native-access=ALL-UNNAMED to silence
  JEP-472 restricted-method warnings on JDK 24+
* Fix two Gradle 10-deprecated DSL lines (groovy_space_assignment_syntax)
* Spotless normalizes the blank line between SPDX header and package on
  62 source files that previously missed it
@usmansaleem usmansaleem requested a review from lucassaldanha May 14, 2026 01:46
@usmansaleem usmansaleem changed the title Add Java 25 build compatibility build: Add Java 25 build compatibility May 14, 2026
@lucassaldanha lucassaldanha self-assigned this May 14, 2026
@usmansaleem usmansaleem merged commit 0b2fbf4 into Consensys:master May 15, 2026
5 checks passed
@usmansaleem usmansaleem deleted the java25-compat branch May 15, 2026 00:08
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants