Tracking the latest JDK version a bit more closely

96 views
Skip to first unread message

Lukács T. Berki

unread,
Mar 15, 2018, 10:00:12 AM3/15/18
to bazel-dev
Hey there,

What do y'all think about not publishing Bazel versions *without* a bundled JDK anymore?

The context is that it would be nice if JavaBuilder was always using the latest JDK version, because why lag behind? However, since JavaBuilder is intimately coupled to a particular version of the JDK because it uses internal APIs, the newer the JDK we are using, the less we can be sure that our users have a suitable one available.

Relying on the JDK bundled with Bazel would solve this, thus the idea of always bundling it and keeping it up-to-date. WDYT? Then Bazel could revert to VanillaJavaBuilder if an incompatible JDK is used, so that it still works, albeit in bit dumber fashion.

The only place I can think of where this is problematic is various software distributions, but realistically, we don't have an official Debian package yet, thus, that's not a problem and my faint memory is is that this is also solvable with Homebrew and Chocolatey is freewheeling enough that I'm not afraid of this not working.

--
Lukács T. Berki | Software Engineer | lbe...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891

ittai zeidman

unread,
Mar 15, 2018, 5:39:04 PM3/15/18
to bazel-dev
This might be a dumb question but what are the implications (as a bazel user) of using openjdk vs oracle's?
I'm guessing that's a big consideration

Philipp Wollermann

unread,
Mar 16, 2018, 9:15:56 AM3/16/18
to ittai zeidman, bazel-dev
Hi Ittai,

not a dumb question at all.

We've been testing Bazel with Azul's Zulu (certified and pretty much vanilla) OpenJDK build and Oracle's JDK for some time and couldn't observe any difference.
Inside Google we're also using a custom version of OpenJDK to run Bazel and our other Java software.

With the change to Buildkite, I also switched our CI workers to use Azul Zulu as their local JDK, so Oracle JDK is no longer being automatically tested - although I wouldn't expect any issues using that. This was an invisible change - again we couldn't observe any difference in performance or behavior.

Other companies also tend to bundle a custom patched version of OpenJDK with their Java software, e.g. JetBrains has their own version of OpenJDK with relevant fixes that is included with IntelliJ and their other software: https://github.com/JetBrains/jdk8u

Also, Bazel includes two escape hatches :) You can tell Bazel to completely ignore the bundled JDK and use any local JDK to run itself and all of its tools:

philwo@philwo-macbookpro ~/src/bazel (master *) bazel info
java-home: /private/var/tmp/_bazel_philwo/install/aaf45a69b50723670ecae3ec4e7a8395/_embedded_binaries/embedded_tools/jdk/jre
java-runtime: OpenJDK Runtime Environment (build 1.8.0_163-b01) by Azul Systems, Inc.

philwo@philwo-macbookpro ~/src/bazel (master *) bazel --host_javabase=$JAVA_HOME info
java-home: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre
java-runtime: Java(TM) SE Runtime Environment (build 1.8.0_151-b12) by Oracle Corporation

You can also let Bazel use its bundled JDK to run itself, but then use a different JDK to run tools (e.g. JavaBuilder and Java binaries):

cat >> ~/myproject/BUILD <<'EOF'
java_runtime_suite(name="cmdline", default=":cmdline-jdk")
java_runtime(name="cmdline-jdk", java_home="$(CUSTOM_JDK)", visibility=["//visibility:public"])
EOF
bazel build --host_javabase=//:cmdline-jdk --javabase=//:cmdline-jdk --define=CUSTOM_JDK=$JAVA_HOME //src:bazel

Alternatively you can of course always check-in a JDK into your repository and use that with --(host_)javabase=, or hardcode the path to it in the java_home= attribute, instead of using a variable.

If it's too annoying to pass these flags, we could e.g. add an --ignore_bundled_jdk flag to the startup options and/or include the "cmdline" / "cmdline-jdk" lines in Bazel's embedded //tools BUILD files, so that you don't have to add them to your own project.

But: I think you shouldn't observe any difference or issues with the Bazel that bundles an OpenJDK. It should just work great out of the box. If you do notice something, I'd consider that a P1 bug - please let me know immediately!

Cheers,
Philipp


--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/78b4f394-764a-4c15-a4ea-12d2d416a646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Google Germany GmbH
Erika-Mann-Straße 33
80636 München


Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

ittai zeidman

unread,
Mar 16, 2018, 11:56:19 AM3/16/18
to Philipp Wollermann, bazel-dev
SGTM!
Reply all
Reply to author
Forward
0 new messages