-
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
Bazel cannot set --host_javabase
to less than JDK 11
#8750
Comments
There is no such thing as Java 9 and Java 10. They are gone: [1].
[1] https://www.oracle.com/technetwork/java/java-se-support-roadmap.html |
You are right that Java 9 and 10 are EOL, however, that doesn't mean that organizations still use Java 9/10 or more commonly Java 8 (as it is a LTS version). As a datapoint, see "The State of Developer Ecosystem 2019". I personally know some organizations that still use Java 8. I also wanted to point out that you can still get updates for Java 8 if you are a paying customer. That's a new option introduces in the past 6 months I believe. It's totally fine for Bazel to ship with JDK 11 but it should be compiled with an earlier target compatibility to allow projects to use a JDK < 11 if needed to detect incompatibilities early in the development lifecycle. |
Java compilation is quite complex in Bazel. The JDK's system libraries Bazel is using are coming from target JDK, which is by default locally installed JDK. So you should be able to compile your code by either having JDK10 installed in JAVA_HOME and on PATH or overriding it with --javabase. --host_javabase specifies JDK that's used during compilation. You should be able to use either JDK10 or the default JDK11, since you're setting --source and --target. May I also suggest to use Bazel 4.0.0, which is a LTS. I will close this issue, because Bazel@HEAD significantly changes the mechanisms, javabase flags were deprecated. More info on https://docs.bazel.build/versions/master/bazel-and-java.html |
We use JDK 8 because the nixpkgs version 18.09 does not provide Java 11 yet and Java 9 and 10 cause problems with Bazel 4.0.0 and are no longer supported releases. See - bazelbuild/bazel#8750 (comment) - bazelbuild/bazel#13065
Description of the problem / feature request:
As a user I want to compile my program with JDK 10 instead of default JDK 11 version that comes with Bazel. Let's say the reason for it is that my production system relies on Java 10 features. In the following example I want to make sure that I can compile with JDK 10 which still includes the module
java.xml.bind
. The module has been removed in Java 11 and therefore fails witherror: module not found: java.xml.bind
.Bazel itself seems to set a target compatibility of Java 11 and therefore cannot run with < Java 11 anymore.
I would expect to be able to set
--host_javabase
with less than Java 11.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
See console output above
What operating system are you running Bazel on?
MacOSX 10.14.5
What's the output of
bazel info release
?release 0.27.0
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?[email protected]:bmuschko/bazel-examples.git
638882ca1bfcece3504cad3955398a98c39dcde1
638882ca1bfcece3504cad3955398a98c39dcde1
The text was updated successfully, but these errors were encountered: