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

rules_closure (and Gerrit) fails on Bazel@HEAD with @bazel_tools//tools/jdk:toolchain_java9 #5961

Closed
davido opened this issue Aug 22, 2018 · 8 comments
Labels
team-Rules-Java Issues for Java rules untriaged

Comments

@davido
Copy link
Contributor

davido commented Aug 22, 2018

Trying to build rule_closure on most recent master (3555e5ba61fdcc17157dd833eaf7d19b313b1bca), and Gerrit with JDK9 on Bazel@HEAD(398478c) is failing with the same error:

  $ java -fullversion
  openjdk full version "9.0.4+12-suse-4.2-x8664"

  $ bazel test --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java9 --java_toolchain=@bazel_tools//tools/jdk:toolchain_java9 //closure/...
INFO: Analysed 1236 targets (0 packages loaded).
INFO: Found 1161 targets and 75 test targets...
ERROR: /home/davido/projects/rules_closure/java/io/bazel/rules/closure/BUILD:17:1: Building java/io/bazel/rules/closure/ClosureWorker.jar (1 source file) and running annotation processors (ComponentProcessor) failed (Exit 1)
Note: Multiple elements named 'javax.annotation.processing.Generated' in modules 'java.base, java.compiler, jdk.accessibility, java.desktop, java.datatransfer, java.xml, java.prefs, jdk.dynalink, java.logging, jdk.jartool, jdk.jsobject, jdk.jconsole, jdk.management.agent, java.management.rmi, java.naming, java.security.sasl, java.rmi, java.management, jdk.attach, jdk.management, jdk.jdi, jdk.jdwp.agent, jdk.net, jdk.xml.dom, jdk.httpserver, jdk.scripting.nashorn, java.scripting, jdk.unsupported, jdk.security.auth, java.security.jgss, jdk.sctp, jdk.security.jgss, java.sql.rowset, java.sql, java.instrument, java.xml.crypto' were found by javax.lang.model.util.Elements.getTypeElement.
Note: Multiple elements named 'javax.annotation.Generated' in modules 'java.base, jdk.accessibility, java.desktop, java.datatransfer, java.xml, java.prefs, jdk.dynalink, java.logging, jdk.jartool, jdk.jsobject, jdk.jconsole, jdk.management.agent, java.management.rmi, java.naming, java.security.sasl, java.rmi, java.management, jdk.attach, jdk.management, jdk.jshell, jdk.jdi, jdk.jdwp.agent, jdk.compiler, java.compiler, jdk.net, jdk.xml.dom, jdk.httpserver, jdk.scripting.nashorn, java.scripting, jdk.unsupported, jdk.security.auth, java.security.jgss, jdk.sctp, jdk.javadoc, jdk.security.jgss, java.se, java.sql.rowset, java.sql, java.instrument, java.xml.crypto' were found by javax.lang.model.util.Elements.getTypeElement.
bazel-out/host/bin/java/io/bazel/rules/closure/_javac/ClosureWorker/ClosureWorker_sourcegenfiles/io/bazel/rules/closure/DaggerClosureWorker_Server.java:145: error: [strict] Using type io.bazel.rules.closure.webfiles.compiler.CssParser from an indirect dependency (TOOL_INFO: "//java/io/bazel/rules/closure/webfiles/compiler"). See command below **
          DaggerClosureWorker_Server.this.fs, new CssParser());
                                                  ^
 ** Please add the following dependencies: 
  //java/io/bazel/rules/closure/webfiles/compiler to //java/io/bazel/rules/closure:ClosureWorker 
 ** You can use the following buildozer command: 
buildozer 'add deps //java/io/bazel/rules/closure/webfiles/compiler' //java/io/bazel/rules/closure:ClosureWorker 

INFO: Elapsed time: 3.400s, Critical Path: 1.82s
INFO: 15 processes: 12 linux-sandbox, 3 worker.
FAILED: Build did NOT complete successfully

//CC @cushon

@davido
Copy link
Contributor Author

davido commented Aug 22, 2018

It seems that this diff fixed that:

diff --git a/java/io/bazel/rules/closure/BUILD b/java/io/bazel/rules/closure/BUILD
index e8d1003..acf13f2 100644
--- a/java/io/bazel/rules/closure/BUILD
+++ b/java/io/bazel/rules/closure/BUILD
@@ -26,6 +26,7 @@ java_binary(
     deps = [
         "//java/com/google/javascript/jscomp",
         "//java/io/bazel/rules/closure/webfiles",
+        "//java/io/bazel/rules/closure/webfiles/compiler",
         "//java/io/bazel/rules/closure/worker",
         "@com_google_dagger",
         "@com_google_guava",

davido added a commit to davido/rules_closure that referenced this issue Aug 22, 2018
@cushon
Copy link
Contributor

cushon commented Aug 23, 2018

Adding the dep is a fine work-around, but it shouldn't be necessary.

Strict Deps ignores some dagger generated code:

Dagger uses this utility to pick a version-appropriate @Generated annotation: https://github.com/google/auto/blob/9cc04ecb39166207a2835174b85ee209cc08aad0/common/src/main/java/com/google/auto/common/GeneratedAnnotations.java#L54

That logic is failing on JDK 10 with --release 9 due to an apparent javac bug: https://bugs.openjdk.java.net/browse/JDK-8209865

@cushon cushon changed the title rules_closure (and Gerrit) fails on Bazel@HEAD on JDK9 rules_closure (and Gerrit) fails on Bazel@HEAD with @bazel_tools//tools/jdk:toolchain_java9 Aug 25, 2018
@jin jin added team-Rules-Java Issues for Java rules untriaged labels Aug 26, 2018
@davido
Copy link
Contributor Author

davido commented Aug 31, 2018

This was apparently fixed in 3987300?

@cushon
Copy link
Contributor

cushon commented Sep 4, 2018

JDK-8209865 remains unfixed, but 3987300 works around it by not using the flag.

@davido
Copy link
Contributor Author

davido commented Sep 4, 2018

Thanks, @laurentlb cherry-picked 3987300 in upcoming 0.17.0 release so that it's fine to close this issue.

@davido davido closed this as completed Sep 4, 2018
@davido
Copy link
Contributor Author

davido commented Sep 4, 2018

but 3987300 works around it by not using the flag.

Could you clarify how the mentioned workaround is able to produce JDK 8 (or JDK 9) byte code using embedded JDK10, without using --release 8|9 flag?

@cushon
Copy link
Contributor

cushon commented Sep 4, 2018

-source/-target/-bootclasspath are still supported and allow targeting the Java 8 (or 9) language level, and using them instead of --release avoids JDK-8209865.

@davido
Copy link
Contributor Author

davido commented Sep 4, 2018

Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Java Issues for Java rules untriaged
Projects
None yet
Development

No branches or pull requests

3 participants