Skip to content

toolchains: Add JDK 27 support - #385

Closed
sluongng wants to merge 2 commits into
bazelbuild:masterfrom
sluongng:sluongng/jdk27-support
Closed

sluongng wants to merge 2 commits into
bazelbuild:masterfrom
sluongng:sluongng/jdk27-support

Conversation

@sluongng

@sluongng sluongng commented Oct 1, 2026 •

Copy link
Copy Markdown

Register checksum-pinned JDK 27 GA runtimes and a matching compilation
toolchain. Use JDK 27 to compile Java 27 sources without changing
the JDK used by older language toolchains.

Include only available platforms, with vendor and Bazel mirror download
URLs. Mirroring completed in bazelbuild/bazel#31433.

Register checksum-pinned JDK 27 GA runtimes and a matching compilation
toolchain. Use JDK 27 to compile Java 27 sources without changing
the JDK used by older language toolchains.

Include only available platforms and vendor download URLs.
@sluongng
sluongng marked this pull request as ready for review October 1, 2026 15:33
@sluongng
sluongng requested review from a team and hvadehra as code owners October 1, 2026 15:33
The JDK 27 archives are now available on Bazel's mirror. Add the
mirror URLs alongside the vendor URLs and remove the temporary
vendor-only exception.
@hvadehra

hvadehra commented Oct 2, 2026

Copy link
Copy Markdown
Member

See #180 (comment)

@hvadehra hvadehra closed this Oct 2, 2026
@davido

davido commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

@hvadehra @meisterT

Sorry to see this closed — I'd like to make the case for reconsidering.

The goal for Gerrit Code Review (which I maintain) and many others in the wild is just:

  $ bazel build --config=java27 gerrit

which only works if remotejdk_27 is registered.

A personal module can't cover that: it can't publish to the Bazel mirror (mirror.bazel.build), and the JDK 27 archives are already mirrored there (bazelbuild/bazel#31433).

We'd offer this to all Gerrit Code Review stakeholders as an opt-in feature, keeping the default on the current Java LTS.

Could we keep one canonical, mirror-backed home for non-LTS releases — opt-in in rules_java, or an official Bazel module it consumes (say rules_java_toolchains — holds every GA release, LTS + non-LTS)?

Would the Bazel team be open to that?

@davido

davido commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

A concrete downstream data point, in case it helps reconsideration.

I wired this into Gerrit to validate the full flow (experimental change: gerrit/+/637823), consuming the PR with a git_override on the fork:

git_override(
    module_name = "rules_java",
    remote = "https://github.com/sluongng/rules_java.git",
    commit = "c9e6c5877b6103054cb2331340d31862c3fb7db6",
)

With that, bazel build --config=java27 gerrit works end to end: locally on macOS x86_64 and on RBE (BuildBuddy and GCP, Linux x86_64). The output is genuine Java 27 bytecode: the class files carry major version 71. Both remotejdk27_macos and remotejdk27_linux resolve as needed, and the LTS toolchains are untouched.

The catch is the method, and the change is explicitly marked experimental because of it: the only way to consume this today is pinning to a personal fork via git_override, which is fragile (the commit can be rebased or removed) and not something I can ship to downstream stakeholders. That is exactly the gap: there is no canonical, mirror-backed home for non-LTS GA runtimes, even though the archives are already mirrored (bazelbuild/bazel#31433) and a personal module cannot publish to mirror.bazel.build.

So the earlier ask stands: could we keep one canonical, mirror-backed home for non-LTS GA releases, opt-in in rules_java or a dedicated module it consumes (e.g. rules_java_toolchains)? Happy to help with whatever shape the Bazel team prefers.

eclipse-jgit-bot pushed a commit to eclipse-jgit/jgit that referenced this pull request Nov 2, 2026
No rules_java release in the Bazel Central Registry registers JDK 27
runtimes: JDK 27 is a non-LTS release, and rules_java deliberately
carries only the LTS line (its remote toolchains top out at JDK 25).
The JDK 27 support proposed in [1] is closed and was not merged.

Rather than forking rules_java, this adds java_toolchains [2], a small
standalone bzlmod module layered on rules_java. It contributes the non
LTS JDK catalog (currently JDK 27) and reuses rules_java's own
remote_java_repository, default_java_toolchain, and
java_runtime_version_alias machinery, so there is no rules_java fork to
track. rules_java stays pinned to JGit's chosen BCR version. The new
module registers the remotejdk_27 runtime and supplies the
@rules_java_toolchains//toolchains:remotejdk_27 label. tools/BUILD
sources the JDK 27 runtime from that module and JDK 25 from rules_java.

To build with JDK 27 and produce class-file major version 71, use one of

  $ bazel build --config=java27   all # local JDK 27
  $ bazel build --config=remote27 all # RBE on GCP

[1] bazelbuild/rules_java#385
[2] https://github.com/davido/java_toolchains

Change-Id: Ia64905e57da3042dfa3715acec0c1bf555da0b78
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.

3 participants