Buck: Buck does not compile with Java 11

Created on 28 Sep 2017  路  19Comments  路  Source: facebook/buck

Set your JAVA_HOME to point to an official Java 9 JDK. Run ant clean default. Watch the catastrophic failure of the build.

Fortunately, once you have a compiled version of buck, it _runs_ under Java 9, which is nice.

Most helpful comment

Actually google/auto#563 is merged so @ttsugriy it is good time to revisit this issue ;)

All 19 comments

it _runs_ under Java 9

Well, sort of. Some codepaths in the Java compilation support don't like it much. :-)

known problem :( Internally we haven't embraced Java 9 yet, but it's on our radar to fix Java 9 builds :)

I've submitted a patch that mostly gets Buck built under JDK9. There are some remaining issues because of the Skylark dependency, which uses an old version of AutoValue that is not JDK9 friendly.

https://github.com/facebook/buck/pull/1672

Thank you, @epkugelmass! This is pretty awesome. I'm going to work on resolving the old AutoValue issue.

Looks like even the latest version of AutoValue still has issues, so I'm going to have to wait until https://github.com/google/auto/pull/563 is merged, new version of AutoValue is released and it's used in Bazel :(

Awesome! You'll probably also want to bump ASM for the RELEASE_9 Opcodes. Or I can do it. Was feeling a bit lazy.

Nevermind -- buck is already using 6.0. I'll update the patch to take advantage of that.

@ttsugriy I released a private version of auto-value with this PR included https://github.com/google/auto/pull/563 here: [1]. I needed it to build gerrit code review with bazel, with Java 9: [2].

Actually google/auto#563 is merged so @ttsugriy it is good time to revisit this issue ;)

Java 9 is no longer supported by Oracle, so we are unlikely to be supporting it. We may repurposes this for Java 10 support though.

@davido, looks like Bazel is still using autovalue 1.4 https://source.bazel.build/bazel/+/master:third_party/auto/auto-value-1.4.jar :(

@ttsugriy Right, but I was able to build Bazel with this version with Java 9, see https://github.com/bazelbuild/bazel/pull/4820.

@ttsugriy I filed this issue: https://github.com/bazelbuild/bazel/issues/4906. I'm on vacation now, and can only look into it later.

I'm also fixing a few issues that creeped into Buck's codebase that relied on a different behavior of HashMap#computeIfAbsent which used to allow value computations inside of computeIfAbsent block (despite explicitly saying in javadoc that nobody should do it :) I've already fixed one of such bugs and will try to fix the rest as soon as possible. I'm testing against Java 10 though, since Java 9 is dead :)

sorry, wrong link. I was referring to [HashMap#computeIfAbsent's](https://docs.oracle.com/javase/10/docs/api/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function) which says

Throws:
ConcurrentModificationException - if it is detected that the mapping function modified this map

By replacing ecj with the system compiler, it's possible to get further in the ant build. However, the aosp compilation fails because sun.misc.BASE64Encoder is not in the Java 10 JRE. I'm unsure of the reasons for compiling AOSP again, but ISTR it had something to do with allowing us to get fast android installs working. It may be worth revisiting this decision, or updating to a more recent snapshot of the AOSP.

I guess another modification of the title is needed ;)

You're using Java 11, but Buck requires Java 8.

Actually, I can compile Buck with JDK11 without any issue. When I try to run Buck built on JDK11 it crashes: http://paste.openstack.org/show/744455.

Is it a known issue?

Known problem, though I don't know if there is a GitHub issue open for it.
You can fix it by passing the --java11-test-mode flag.

https://github.com/facebook/buck/blame/master/programs/buck.py#L187

Was this page helpful?
0 / 5 - 0 ratings