Non-LTS JDK toolchains for Bazel, packaged as a standalone bzlmod module on top
of rules_java.
rules_java ships remote JDK toolchains for the LTS line (8, 11, 17, 21, 25) and
is deliberately conservative about carrying non-LTS releases, since each one is
only supported for six months. This module adds those short-lived releases
(currently JDK 27) without forking rules_java: it reuses rules_java's own
remote_java_repository, default_java_toolchain, and java_runtime_version_alias
machinery and only contributes the archive catalog.
- Runtime toolchains for JDK 27 across linux (x86_64/aarch64/ppc64le/riscv64/s390x),
macOS (x86_64/aarch64), and Windows (x86_64), selectable with
--java_runtime_version=remotejdk_27(or=27). @java_toolchains//toolchains:remotejdk_27— the runtime label, for use as ajava_runtime = ...attribute.@java_toolchains//toolchains:toolchain_jdk_27— a compile toolchain that runsjavacon JDK 27, selectable with--java_language_version=27. (The LTS toolchains top out at JDK 25, whosejavacrejects source/target 27.)
This module is not yet released or published to the Bazel Central Registry.
For now, add a Git override pinned to a commit whose module name is
java_toolchains:
# MODULE.bazel
bazel_dep(name = "rules_java", version = "9.9.0")
bazel_dep(name = "java_toolchains", version = "0.0.1")
git_override(
module_name = "java_toolchains",
remote = "https://github.com/davido/java_toolchains.git",
commit = "5ba7b4f08019bccab1f560f29d1734ed55e3e985",
)# .bazelrc
build:java27 --java_language_version=27
build:java27 --java_runtime_version=remotejdk_27
build:java27 --tool_java_language_version=27
build:java27 --tool_java_runtime_version=remotejdk_27
bazelisk build --config=java27 //...
After a release is admitted to the BCR, the Git override can be removed.
examples/consuming is a self-contained workspace that consumes this module via
local_path_override and builds a Java target at language level 27:
cd examples/consuming
bazelisk run --config=java27 //:hello # prints "Hello from JDK 27"
bazelisk test --config=java27 //:toolchain_test
The test checks JDK 27 execution and Java 27 bytecode. The CI workflow covers Linux x86_64, macOS aarch64, and Windows x86_64 with Bazel 9.3.0, the minimum supported version. The remaining catalog architectures are not covered by that workflow.
JDK archives are fetched on demand for selected toolchains; adding the module does not require downloading every platform's JDK. The configured repository cache can reuse archives across workspaces.
See the API reference, contributor guide, and release procedure.
David Ostrovsky (@davido) maintains this project on a best-effort volunteer basis and is the point of contact for the Rules Authors SIG. The goal is to respond to issues and pull requests within 2–3 weeks; there is no guaranteed response time or commercial support. Additional maintainers are welcome.
The catalog follows non-LTS JDK releases, whose vendor maintenance windows are short. A catalog entry does not extend the vendor's security support. Retiring public labels follows the versioning policy in RELEASING.md.
- Add the archive structs to
jdk/repositories.bzl(name,target_compatible_with,sha256,strip_prefix,urls,version), mirroring the JDK 27 entries. - Add a
remote_jdkNN_repos()macro and call it fromjdk/extensions.bzl. - List the new repos in
MODULE.bazel(use_repo+register_toolchains). - Add the
remotejdk_NNalias andtoolchain_jdk_NNtotoolchains/BUILD.bazel. - Document the vendor's support window and announce any eventual removal as described in RELEASING.md.
Apache License 2.0. See LICENSE.