Skip to content
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

Support for JDK 11 #6245

Closed
3 tasks done
cushon opened this issue Sep 26, 2018 · 17 comments
Closed
3 tasks done

Support for JDK 11 #6245

cushon opened this issue Sep 26, 2018 · 17 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules

Comments

@cushon
Copy link
Contributor

cushon commented Sep 26, 2018

As of today (2018-9-25), JDK 11 is generally available: http://jdk.java.net/11/.

Bazel should support it, including:

@RNabel
Copy link
Contributor

RNabel commented Dec 28, 2018

@cushon Do you have a road map / timeline for support for JDK 11?

@jin
Copy link
Member

jin commented Dec 28, 2018

@cushon please add a priority label, thanks!

@cushon
Copy link
Contributor Author

cushon commented Dec 28, 2018

cc @iirina

@davido
Copy link
Contributor

davido commented Jan 7, 2019

#6592 seems to be related.

@jin jin added the untriaged label Jan 14, 2019
@meteorcloudy
Copy link
Member

FYI, I have to disable some tests for ubuntu1804_java11

    # Some prebuilt jars doesn't run with Java 11
    - "-//src/test/shell/bazel:external_integration_test"
    - "-//src/test/shell/bazel:maven_test"
    # Re-enable once bootstrap works with Java 11
    - "-//src/test/shell/bazel:bazel_bootstrap_distfile_test

https://buildkite.com/bazel/google-bazel-presubmit/builds/14214#d7b484bc-ed66-4bf0-aa53-6b148c255e03

@iirina iirina added the P2 We'll consider working on this in future. (Assignee optional) label Jan 15, 2019
@iirina iirina self-assigned this Jan 15, 2019
@iirina iirina removed the untriaged label Jan 15, 2019
@ittaiz
Copy link
Member

ittaiz commented May 22, 2019

@cushon should JDK 11 host runtime support (--host_javabase) be updated? The linked issue is closed

@iirina
Copy link
Contributor

iirina commented May 22, 2019

This can be closed altogether.

@iirina iirina closed this as completed May 22, 2019
@ittaiz
Copy link
Member

ittaiz commented May 22, 2019

you mean everything is supported? are there docs for bazel and jdk11?

@ittaiz
Copy link
Member

ittaiz commented May 22, 2019

for example what is the toolchain I should use for jdk11

@uri-canva
Copy link
Contributor

https://github.com/bazelbuild/bazel/blob/108bc5aaf46c4ec5e6dc0ac7c81c2f16d9ae2a21/tools/jdk/BUILD shows remote_jdk10 and remote_jdk11, but no toolchain_java10 or toolchain_java11 from what I can tell.

@gmishkin
Copy link

gmishkin commented May 22, 2019

I don't think you're supposed to use the toolchains named in that style anyway if you want the new stuff, the one that's just called toolchain or remote_toolchain now points to the recent work: bad5a2b#diff-b53d77ce419e665f48b6c7bca4965357

But I haven't checked whether the language level for Java 11 is usable yet, and buildjar still seems to depend on langtools' javac which is javac-9+181-r4173-1.jar unless I'm misinterpreting something (based on my understanding of #5723 (comment)).

@davido
Copy link
Contributor

davido commented May 22, 2019

support for the Java 11 language level (--java_toolchain/--host_java_toolchain)

Can someone clarify how the point 3 from the issue description is solved on Bazel@HEAD?

@cushon
Copy link
Contributor Author

cushon commented May 22, 2019

The Java 11 language level works for me at head:

$ cat BUILD Hello.java
java_binary(
    name = "Hello",
    srcs = ["Hello.java"],
    main_class = "Hello",
)
class Hello {
  public static void main(String[] args) {
    var message = "Hello world";
    System.err.println(message);
  }
}
$ JAVA_HOME=<path to JDK 11> bazel run --javacopt='--release 11' :Hello 
Hello world

@gmishkin
Copy link

Thanks, is this the recommended way of setting the language level, or will the toolchain rule be updated to have a release_version argument?

Also assuming this works with remote_jdk11 as the host_javabase and not just when setting JAVA_HOME?

@Ubehebe
Copy link

Ubehebe commented Jun 11, 2019

@cushon, can you clarify how to use this feature? Bazel at head defines toolchain_java8 and toolchain_java9, but not toolchain_java10 or toolchain_java11. I was able to roll my own like this:

default_java_toolchain(
    name = "toolchain_java11",
    source_version = "11",
    target_version = "11",
    visibility = [
        "//visibility:public",
    ],
)

then activate it by default from my bazelrc:

build --java_toolchain=//:toolchain_java11
build --host_java_toolchain=//:toolchain_java11

But now building a simple java_library fails with the following:

java.lang.IllegalArgumentException: invalid source release: 11
        at jdk.compiler/com.sun.tools.javac.main.Arguments.error(Arguments.java:913)
        at jdk.compiler/com.sun.tools.javac.main.Arguments.doProcessArgs(Arguments.java:383)
        at jdk.compiler/com.sun.tools.javac.main.Arguments.processArgs(Arguments.java:347)
        at jdk.compiler/com.sun.tools.javac.main.Arguments.init(Arguments.java:246)
        at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:185)
        at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:99)
        at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:57)                                                                                               
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:116)                                                                                                              
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:123)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.processRequest(BazelJavaBuilder.java:106)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.runPersistentWorker(BazelJavaBuilder.java:68)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:46)

I believe this means the JVM used in the host configuration doesn't understand source release 11. OK, let's set this explicitly in bazelrc:

build --javabase @bazel_tools//tools/jdk:remote_jdk11
build --host_javabase @bazel_tools//tools/jdk:remote_jdk11

But this doesn't make a difference; I get the same stack trace as above. Is there a piece of the puzzle I'm missing?

@iirina
Copy link
Contributor

iirina commented Jun 12, 2019

With bazel@HEAD @bazel_tools//tools/jdk:toolchain is a toolchain for java 11, but still targets JDK 8.

I tried reproducing with your example but I could run a Java 11 binary. Make sure that you are using bazel built@HEAD otherwise the default_java_toolchain still points to a Java 10 toolchain.

We are planning to soon make available the toolchains for java version 9-12 under https://github.com/bazelbuild/java_tools.

@iirina
Copy link
Contributor

iirina commented Jun 13, 2019

1d82cf8 introduced @bazel_tools//tools/jdk:toolchain_java10 and @bazel_tools//tools/jdk:toolchain_java11. You can try them out with bazel@HEAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules
Projects
None yet
Development

No branches or pull requests

10 participants