-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Overriding default java toolchain with source version 17 is failing in com.google.turbine.options.LanguageVersion: invalid -source version: 17 #14474
Comments
That error means that turbine can't load Those flags are not necessary anymore, the custom javac build hasn't been necessary since JDK 13 (#11262 (comment)). I can build your repro with the following change to omit the diff --git a/tools/BUILD b/tools/BUILD
index aac288cd66..6630f95ef8 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -1,6 +1,6 @@
load(
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
- "JDK9_JVM_OPTS",
+ "BASE_JDK9_JVM_OPTS",
"default_java_toolchain",
)
load("@rules_java//java:defs.bzl", "java_package_configuration")
@@ -9,6 +9,10 @@ exports_files(["nongoogle.bzl"])
default_java_toolchain(
name = "error_prone_warnings_toolchain_java11",
+ jvm_opts = BASE_JDK9_JVM_OPTS,
+ misc = [
+ "-Xep:ReturnValueIgnored:WARN",
+ ],
package_configuration = [
":error_prone",
],
@@ -22,10 +26,14 @@ default_java_toolchain(
default_java_toolchain(
name = "error_prone_warnings_toolchain_java17",
java_runtime = "@bazel_tools//tools/jdk:remotejdk_17",
+ jvm_opts = BASE_JDK9_JVM_OPTS,
+ misc = [
+ "-Xep:ReturnValueIgnored:WARN",
+ ],
package_configuration = [
":error_prone",
],
- source_version = "11",
+ source_version = "17",
target_version = "17",
visibility = ["//visibility:public"],
) (I'm not sure what's up with |
I can't reproduce the
which I think isn't covered by the |
Also the reason the built-in Java 17 toolchain works correctly is that it sets Line 393 in 46ed5d5
Including that in the custom toolchain definition in gerrit would also work, as an alternative to |
Thanks for the fast answer! It works now with suggested workaround, with addition of To demonstrate it, I added new record to the source base:
And while the build is failing with default (Java 11) toolchain (as expected):
It just works with
And the class file is there:
Also sorry for the confusion with |
…rly. There are really two changes here: 1. Fix the reference to `//tools/jdk:remote_jdk11` to have `@bazel_tools`. Without this, a direct copy/paste will fail to even build. 2. Change from `JDK9_JVM_OPTS` to `BASE_JDK9_JVM_OPTS` as the former includes `--patch-module=java.compiler=` which overrides `source_version` and can also cause build failures. See bazelbuild#14474 (comment) for an example.
…rrectly There are really two changes here: 1. Fix the reference to `//tools/jdk:remote_jdk11` to have `@bazel_tools`. Without this, a direct copy/paste will fail to even build. 2. Change from `JDK9_JVM_OPTS` to `BASE_JDK9_JVM_OPTS` as the former includes `--patch-module=java.compiler=` which overrides `source_version` and can also cause build failures. See [this issue](#14474 (comment)) for an example. Closes #15009. PiperOrigin-RevId: 433750777
On Bazel@HEAD (46ed5d5) I'm trying to override
default_java_toolchain
to promote Error Prone bug patterns to ERROR severity:and register this custom toolchain in
WORKSPACE
:and activate it like this in
.bazelrc
:Now, the build is failing:
If I downgrade the source version to 11 in custom toolchain:
it works as expected:
and major byte version 61 is produced:
However, custom Error Prone severity level doesn't seem to be respected, in the example below the build is failed with
ReturnValueIgnored
error prone bug pattern violation:Even though it was demoted to WARN level in custom java toolchain definition (and it works as expected for JDK 11):
Reproduced is here: [1]
//CC @comius @cushon
[1] https://gerrit-review.googlesource.com/c/gerrit/+/291864
The text was updated successfully, but these errors were encountered: