Skip to content

Cannot build Bazel with local JDK21 #21604

@coeuvre

Description

@coeuvre

Description of the bug:

When building Bazel itself with a local JDK21 (local_java_runtime), it fails with following error:

ERROR: /usr/local/google/home/chiwang/.cache/bazel/_bazel_chiwang/0d7b80a634c8f6dac7c916ddfc337473/external/rules_jvm_external~6.0/private/tools/java/com/github/bazelbuild/rules_jvm_external/BUILD:1:13: Compiling Java headers external/rules_jvm_external~6.0/private/tools/java/com/github/bazelbuild/rules_jvm_external/librules_jvm_external-hjar.jar (4 source files) [for tool] failed: (Exit 1): turbine_direct_graal failed: error executing Turbine command (from target @@rules_jvm_external~6.0//private/tools/java/com/github/bazelbuild/rules_jvm_external:rules_jvm_external) external/rules_java~7.4.0~toolchains~remote_java_tools_linux/java_tools/turbine_direct_graal --output ... (remaining 33 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
java.lang.NullPointerException: attempted to use --release, but JAVA_HOME is not set
        at [email protected]/java.util.Objects.requireNonNull(Objects.java:259)
        at com.google.turbine.binder.CtSymClassBinder.bind(CtSymClassBinder.java:55)
        at com.google.turbine.main.Main.bootclasspath(Main.java:309)
        at com.google.turbine.main.Main.compile(Main.java:142)
        at com.google.turbine.main.Main.compile(Main.java:133)
        at com.google.turbine.main.Main.main(Main.java:89)
Target //src:bazel failed to build

It seems like the turbine.ctSymPath property isn't correctly set, because java_runtime.lib_ct_sym is None. By following the code in _java_runtime_rule_impl, it's because local_java_runtime doesn't set srcs nor lib_ct_sym .

This prevent us using RBE with JDK21.

Which category does this issue belong to?

Java Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Clone https://github.com/bazelbuild/bazel
  2. Add a local JDK runtime into BUILD:
load("@rules_java//toolchains:local_java_repository.bzl", "local_java_runtime")
local_java_runtime(
    name = "local",
    java_home = "<path to local JDK21>",
    version = "21",
)
  1. bazel build --java_runtime_version=local --tool_java_runtime_version=local --extra_toolchains=//:all //src:bazel

Which operating system are you running Bazel on?

linux

What is the output of bazel info release?

release 7.0.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions