-
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
Java 10/11 should be supported #5723
Comments
It looks like this might be related to https://github.com/bazelbuild/bazel/blob/master/tools/jdk/default_java_toolchain.bzl#L37-L38 -- those jars might not support Java 10+? |
Support for |
@cushon is Java 11 supported as well? Java 10 will no longer receive support once Java 11 is released, which is scheduled for September 25th (less than 5 weeks away!). |
Note that using JDK 11 as a |
How would I set-up local jdk 11 to be used as
As you pointed out in this comment: [1], there are three JDKs used in Bazel, I think we want to change 2) and 3). So I define this
And using it like this:
That works, and still raises the question how to pass post Java arguments to the tests, like we do for Java 9 and Java 10:
However, I would expect that the class version produced by the command above is major version 55 that corresponds to Java 11. To my surprise, the major version is still 52 (Java 8):
Am I missing something? Are we passing somewhere in the Bazel toolchain hard coded Java target = 8? Should I file own issue for that problem? Or is this the missing support for Update: Note, that when I use alternative
|
If I pass,
|
The part I expected to work was specifically using JDK 11 as a
I can't reproduce. With gerrit @ 8f26af11797075aab14d9c17d1e69a30e00aa9e5:
|
|
So yes, I can confirm that:
works as expected and producing major version: 54. My question was to make Java 11 work, as you pointed out, it should be supported with This doesn't work and produces major version 52:
|
That isn't currently supported with the default toolchain: it's is using a JDK 10 javac, which will need to be updated to a JDK 11 javac to support --release 11. Again, that is part of the work being tracked by this bug.
That isn't supposed to produce v55 class files: the language level is configured by |
I see, thanks for clarifying. I see 2 fundamental problems with this approach:
I guess you meant: "That isn't supposed to produce v55 class files", right? Can't language level be configured by Do you have a working example how could I set-up custom toolchain with JDK11 to produce Gerrit with |
To confirm: do you want to build with the Java 9 language level and target JDK 9? Do you care about the
If you want to use whatever the latest supported language level is from the default_java_toolchain(
name = "toolchain_vanilla",
forcibly_disable_header_compilation = True,
javabuilder = [":vanillajavabuilder"],
jvm_opts = [],
) e.g. for v in $(seq 8 11); do
bazel build \
--host_javabase=:jdk${v} \
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
--java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
//java/com/google/gerrit/server:libserver.jar
javap -v -cp bazel-bin/java/com/google/gerrit/server/libserver.jar \
com.google.gerrit.server.util.SocketUtil | grep "major version"
done
|
Yes.
No.
In which case I wouldn't be able to use error prone and strict deps, and that's unfortunate. |
Using --release to target versions that support modules and are not the latest supported version (e.g. --release 9 on JDK 10) doesn't work: https://bugs.openjdk.java.net/browse/JDK-8209865 Related: bazelbuild#5723
re: error prone and strict deps--I'm glad those features are useful, you may want to read this thread if you haven't already and share any feedback you have. I had an idea for working around the bug with JDK 10 and With that patch, the following works: for v in $(seq 8 10); do
bazel build --verbose_failures \
--java_toolchain=@bazel_tools//tools/jdk:toolchain_java${v} \
//java/com/google/gerrit/server:libserver.jar
javap -v -cp bazel-bin/java/com/google/gerrit/server/libserver.jar com.google.gerrit.server.util.SocketUtil | grep "major version"
done
|
Using --release to target versions that support modules and are not the latest supported version (e.g. --release 9 on JDK 10) doesn't work: https://bugs.openjdk.java.net/browse/JDK-8209865 Related: bazelbuild#5723
To use the latest supported language level from the --host_javabase, use VanillaJavaBuilder (which should work with most host JDKs) and leave the source/target/bootclasspath unset so they default to the latest supported versions. With this in place, new java_runtime can be used, e.g.: java_runtime( name = "jdk11", java_home = "/usr/lib64/jvm/java-11", visibility = ["//visibility:public"], ) Now the JDK11 can be used with the language level 11: $ bazel build --host_javabase=:jdk11 \ --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ :a Related: bazelbuild#5723
Thanks! I tried to use vanilla Meantime, I added vanilla
It seems that the JUnit-Log is not complete, may be there is some Bazel/JUnit integration issues on JDK11 (and would worth its own issue)? |
If you look at the test log (or use
guice is using the But in general, sure: any time you have a minimal repro that demonstrates there's a bug in Bazel, please report it. |
Thanks for pointing this out. Somehow the full stack trace was reported on JDK10 for the same guice/ASM issue without providing this option: Anyway, I fixed that issue in this PR: [1], conducted this new Thanks for your help and big thank to the whole Bazel team! I think it's very impressive that such complex project as Gerrit (from build tool chain point of view) can be built on all currently released JDKs: 8,9,10 and even on the upcoming JDK11 ;-). [1] google/guice#1203 |
The choice of JavaBuilder implementation shouldn't affect the way test output is handled, and I can't observe a difference between the test output with JDK 10 and 11. Can you share the repro for that?
Thank you for testing with JDK 11 :) The feedback is helpful, and hopefully support for future JDK releases will go more smoothly as we get more practice with the new release cadence. |
Yes, you are right. I cannot reproduce this any more. I tried on JDK 11 and reverted my Guice/ASM fix and now I see, in fact even without |
One (minor?) problem with the setup @uri-canva shows above. When compiling using From debugging it looks like with jdk10 as Line 125 in 0b2352d
Path s instead of relative ones. This breaks DependencyModule.buildDependenciesProto .
Example wcurrie/examples@13f8b7e based off java-maven in https://github.com/bazelbuild/examples. With jdk8 as Maybe it's more practical to work around this issue at the intellij plugin level. We've done this internally. With this hack of |
The default javac has a fix for that issue: google/error-prone-javac@9901a45 That's one of the reasons Strict Deps doesn't work with the 'vanilla' toolchain: Lines 212 to 214 in 44cadaf
|
Sorry for the newbie question but will the error prone fix (google/error-prone-javac@9901a45) eventually make its way into the javac bundled with bazel? IIUC we could configure a toolchain pointed to a different |
Yep. However it's blocked on #6316. The JDK 11 javac needs a JDK 11 |
You can almost get Bazel itself to build wtih Java 11 using the vanilla toolchain. However, it fails because the vendored jarjar uses an old version of asm. Is there a plan update that? |
@benjaminp Bazel at head is using ASM 7: f4a35eb |
Right, the problem is jarjar:
|
That error message is referring to the API level, not the library version: #6692 |
Now that Oracle Java 8 is past EOL is there any update on this? I see there's quite a bit of progress on #6316, but is that the only thing that is blocking Java 11 support? Can we use Java 11 with |
Does this mean 0.23.0? Our project community is eagerly waiting for being able to build against JDK11 using off-the-shelf Bazel. |
0.24, unfortunately. The flag is not flipped in 0.23 by default :( |
I think #6316 is necessary but not sufficient: it makes it possible to add support for the Java 11 language level to the toolchain without regressing JDK 8 host_javabase support (because we can provide different versions of the tools). But the work to add support for 11 hasn't happened yet, and I'm not sure it's in scope for #6316. |
Just noting java 12 is here https://hackernoon.com/announcement-java12-has-released-435e659affee |
If built-in support for Java 11/12 is going to take more time, documentation on how to enable it yourself with toolchains and/or other configuration would be very helpful. |
@greggdonovan It is already possible to support Java 11/12/... with recent Bazel releases with This feature is also documented in Gerrit Code Review build toolchain documentation: [1] and there is even CI job in Bazel@CI for that. [1] https://github.com/GerritCodeReview/gerrit/blob/master/Documentation/dev-bazel.txt#L17-L67 |
There is a bug in Bazel, that it does not produce proper jdeps files for the IntelliJ plugin, thus breaking the existing API. The only workaround seems to be to force the plugin to treat all files to be part of the working set, and load external dependencies for them. More info at: bazelbuild#490 bazelbuild/bazel#5723 bazelbuild/bazel#6587
Description of the problem / feature request:
It seems like Bazel doesn't support building projects with Java 10 or Java 11. Java 10 is scheduled to be deprecated when Java 11 is released, currently estimated for September 25, 2018. In order to test and update our code base for Java 11, we need to be able to build it with Bazel.
Feature requests: what underlying problem are you trying to solve with this feature?
Bazel should support building against Java 10/11.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Follow the steps at https://github.com/ajrepp/java-upgrade-toy. The output is:
What operating system are you running Bazel on?
macOS X 10.13.6
What's the output of
bazel info release
?development version
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.bazel build //scripts/packages
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?https://github.com/bazelbuild/bazel.git
0a635c5
0a635c5
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
We haven't been able to find a definitive answer anywhere about new Java version support or easy-to-understand documentation for how to use new versions. Any information would be appreciated!
The text was updated successfully, but these errors were encountered: