-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix and verify Java version compatibility of Java tools #26126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Prebuilt Java tools meant to run on the user-specified `--java_{tool_,}runtime_version` must only use Java 8 language features and APIs. Previously, these tools were compiled with `--java_language_version=8`, but had access to a JDK 21 as the bootclasspath. In fact, `junitrunner` used `Stream#dropWhile`, which isn't available in a JDK 8. Similarly, Java tools meant to run on the Java runtime provided by a Java (compilation) toolchain must only use Java 11 language features and APIs. This was the case, but they were in fact build with `--java_language_version=8` and a JDK 21, just like the other tools, thus lacking validation for this property. This PR splits tools into two groups and enforces consistent Java language and bootclasspath runtime for them via `--@rules_java//toolchains:incompatible_language_version_bootclasspath`. Constants in `//src:release_archive.bzl` can be used to set the two minimum versions globally.
@@ -11,7 +10,7 @@ package( | |||
|
|||
licenses(["notice"]) # Apache 2.0 | |||
|
|||
java_binary( | |||
minimum_java_runtime_java_binary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's sometimes necessary to build this for a higher bytecode version, we could keep it a regular java_binary
and wrap it in a transitioning filegroup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @c-mita
CI is green after I fixed the bootstrap tests. |
Precompiled Java tools meant to run with the user-specified
--java_{tool_,}runtime_version
must only use Java 8 language features and APIs. Previously, these tools were compiled with--java_language_version=8
, but had access to a JDK 21 as the bootclasspath. In fact,junitrunner
usedStream#dropWhile
, which isn't available in a JDK 8. Similarly, Java tools meant to run on the Java runtime provided by a Java (compilation) toolchain must only use Java 11 language features and APIs. This was the case, but they were in fact build with--java_language_version=8
and a JDK 21, just like the other tools.This PR splits tools into two groups and enforces consistent Java language and bootclasspath runtime versions for them via
--@rules_java//toolchains:incompatible_language_version_bootclasspath
. Constants in//src:release_archive.bzl
can be used to set the two minimum versions globally.Related to #26100