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

Java 16 toolchain #13274

Closed
wants to merge 1 commit into from
Closed

Java 16 toolchain #13274

wants to merge 1 commit into from

Conversation

davido
Copy link
Contributor

@davido davido commented Mar 28, 2021

Closes #13270.

@google-cla google-cla bot added the cla: yes label Mar 28, 2021
@davido
Copy link
Contributor Author

davido commented Mar 28, 2021

I released java_tools_16.0 from this PR and with this Bazel patch:

diff --git a/distdir_deps.bzl b/distdir_deps.bzl
index e2ec4469a3..3ab07efa5c 100644
--- a/distdir_deps.bzl
+++ b/distdir_deps.bzl
@@ -267,11 +267,10 @@ DIST_DEPS = {
             "remote_java_tools_test",
             "remote_java_tools_for_testing",
         ],
-        "archive": "java_tools-v11.2.zip",
-        "sha256": "b6c468410a371728fe703ef7a6e386bb7f69bb46b900fed0460eb68c54f99895",
+        "archive": "java_tools-v16.0.zip",
+        "sha256": "6f036ca629f3e30f3c32527e447647aff00b4c2cf1e3ff57635ee49b6e17c8d5",
         "urls": [
-            "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.2/java_tools-v11.2.zip",
-            "https://github.com/bazelbuild/java_tools/releases/download/java_v11.2/java_tools-v11.2.zip",
+            "https://github.com/davido/java_tools/releases/download/v16.0/java_tools_linux-v16.0.zip",
         ],
         "used_in": [
             "additional_distfiles",

I can build gerrit with JDK 16 from this change: [1]:

  $ bazeldev build --config=java16 java/com/google/gerrit/common:server
  [...]
  INFO: Analyzed target //java/com/google/gerrit/common:server (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //java/com/google/gerrit/common:server up-to-date:
  bazel-bin/java/com/google/gerrit/common/libserver.jar
INFO: Elapsed time: 0.527s, Critical Path: 0.27s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

And can confirm, that major byte code version is 60, as expected:

  $ javap -v -cp bazel-bin/java/com/google/gerrit/common/libserver.jar \
    com.google.gerrit.common.data.PatchScript | grep major
  major version: 60

[1] https://gerrit-review.googlesource.com/c/gerrit/+/301362

@davido
Copy link
Contributor Author

davido commented Mar 28, 2021

@meteorcloudy

Could you please upload JDK 16 archives to Bazel mirror?

@comius comius self-requested a review March 30, 2021 07:22
@comius comius self-assigned this Mar 30, 2021
@davido davido force-pushed the java_16_toolchain branch 2 times, most recently from d064ee3 to 6706428 Compare March 30, 2021 15:40
Copy link
Contributor

@comius comius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind also adding "16" to the JAVA_VERSIONS in src/test/shell/BUILD? Those tests have much better coverage and will make sure JDK16 works.

nit: there are some "14" left in the tests and those test fail because JDK14 was removed. If you also care replacing them with "15" or removing them.

@davido
Copy link
Contributor Author

davido commented Apr 8, 2021

Thanks for the review.

Would you mind also adding "16" to the JAVA_VERSIONS in src/test/shell/BUILD?

After adding the "16" to the JAVA_VERSIONS in src/test/shell/bazel/BUILD, the tests are failing with:

An exception has occurred in the compiler (16). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.IllegalAccessError: class com.google.devtools.build.buildjar.javac.plugins.dependency.StrictJavaDepsPlugin (in unnamed module @0xa4354f2) cannot access class com.sun.tools.javac.resources.CompilerProperties$Errors (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.resources to unnamed module @0xa4354f2
        at com.google.devtools.build.buildjar.javac.plugins.dependency.StrictJavaDepsPlugin.finish(StrictJavaDepsPlugin.java:178)
        at com.google.devtools.build.buildjar.javac.BlazeJavaCompiler.close(BlazeJavaCompiler.java:122)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:1000)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:123)
        at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.fallback(ReducedClasspathJavaLibraryBuilder.java:103)
        at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:65)
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:110)
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:118)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.build(BazelJavaBuilder.java:99)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.parseAndBuild(BazelJavaBuilder.java:79)
        at com.google.devtools.build.lib.worker.WorkRequestHandler.respondToRequest(WorkRequestHandler.java:151)
        at com.google.devtools.build.lib.worker.WorkRequestHandler.lambda$createResponseThread$0(WorkRequestHandler.java:134)
        at java.base/java.lang.Thread.run(Thread.java:831)
java.lang.IllegalAccessError: class com.google.devtools.build.buildjar.javac.plugins.dependency.StrictJavaDepsPlugin (in unnamed module @0xa4354f2) cannot access class com.sun.tools.javac.resources.CompilerProperties$Errors (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.resources to unnamed module @0xa4354f2
        at com.google.devtools.build.buildjar.javac.plugins.dependency.StrictJavaDepsPlugin.finish(StrictJavaDepsPlugin.java:178)
        at com.google.devtools.build.buildjar.javac.BlazeJavaCompiler.close(BlazeJavaCompiler.java:122)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.cleanup(JavacTaskImpl.java:234)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:114)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:123)
        at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.fallback(ReducedClasspathJavaLibraryBuilder.java:103)
        at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:65)
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:110)
        at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:118)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.build(BazelJavaBuilder.java:99)
        at com.google.devtools.build.buildjar.BazelJavaBuilder.parseAndBuild(BazelJavaBuilder.java:79)
        at com.google.devtools.build.lib.worker.WorkRequestHandler.respondToRequest(WorkRequestHandler.java:151)
        at com.google.devtools.build.lib.worker.WorkRequestHandler.lambda$createResponseThread$0(WorkRequestHandler.java:134)
        at java.base/java.lang.Thread.run(Thread.java:831)
Target //java/com/google/sandwich:Main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.430s, Critical Path: 2.62s
INFO: 11 processes: 5 internal, 3 linux-sandbox, 3 worker.
FAILED: Build did NOT complete successfully

And this diff fixed it:

diff --git a/tools/jdk/default_java_toolchain.bzl b/tools/jdk/default_java_toolchain.bzl
index fee344a45f..ebd2b16f0d 100644
--- a/tools/jdk/default_java_toolchain.bzl
+++ b/tools/jdk/default_java_toolchain.bzl
@@ -26,6 +26,7 @@ BASE_JDK9_JVM_OPTS = [
     "--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
     "--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
     "--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+    "--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED",
     "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
     "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
     "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",

nit: there are some "14" left in the tests and those test fail because JDK14 was removed.

Done.

@davido davido force-pushed the java_16_toolchain branch from 3211800 to 13430e5 Compare April 8, 2021 12:38
@davido davido requested a review from comius April 8, 2021 12:45
@davido
Copy link
Contributor Author

davido commented Apr 8, 2021

@comius

This test is failing:

//src/test/shell/bazel:bazel_coverage_java_jdk16_toolchain_released_test FAILED in 104.9s

I can reproduce it locally but it's hard to see what is the root cause?!

@davido
Copy link
Contributor Author

davido commented Apr 8, 2021

@comius

I think I see what's going on.

I extracted a reproducer repository for coverage based on the test:

https://github.com/davido/bazel_coverage_src_and_test_same_package

And all I changed is added these lines to .bazelrc to reflect building with Java 16:

cat .bazelrc

# Builds using remote_jdk16, executes using remote_jdk16
build --java_language_version=16
build --java_runtime_version=16
build --tool_java_language_version=16
build --tool_java_runtime_version=16

Now, running coverage with new java_tools we see what's going on:

 cd /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/execroot/__main__
davido@localhost:~/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/execroot/__main__$ external/remotejdk16_linux/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' -jar external/remote_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/k8-fastbuild/bin/libcollatz-lib.jar-0.params @bazel-out/k8-fastbuild/bin/libcollatz-lib.jar-1.params
java.io.IOException: Error while instrumenting bazel-out/k8-fastbuild/bin/_javac/collatz-lib/libcollatz-lib_classes/com/example/Collatz.class.
	at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:170)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:120)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:145)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:165)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$1.visitFile(JacocoInstrumentationProcessor.java:141)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$1.visitFile(JacocoInstrumentationProcessor.java:113)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2804)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2876)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.instrumentRecursively(JacocoInstrumentationProcessor.java:111)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.processRequest(JacocoInstrumentationProcessor.java:85)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.buildJar(SimpleJavaLibraryBuilder.java:151)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:120)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.build(BazelJavaBuilder.java:99)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.parseAndBuild(BazelJavaBuilder.java:79)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:63)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:196)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:177)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:163)
	at org.jacoco.core.internal.instr.InstrSupport.classReaderFor(InstrSupport.java:247)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:86)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:118)
	... 13 more

IOW, currently used jacoco distribution on Bazel@HEAD doesn't support Java 16 yet.

Bazel is still using JaCoCo 0.8.3:

cat third_party/java/jacoco/BUILD

VERSION = "0.8.3"

While the experimental support for Java 16 was added in release 0.8.6: [1] in this PR: [2].

[1] https://github.com/jacoco/jacoco/releases/tag/v0.8.6
[2] jacoco/jacoco#1059

@comius
Copy link
Contributor

comius commented Apr 9, 2021

Thanks @davido, it's great that you found this. I'll upgrade jacoco - I removed all blockers there in past weeks and it's just waiting on me to actually execute it.

Related issue #11674

@davido
Copy link
Contributor Author

davido commented Apr 9, 2021

@comius

I'll upgrade jacoco - I removed all blockers there in past weeks and it's just waiting on me to actually execute it.

Thanks for the pointer, I see, that jacoco and asm need update. Do you have WIP change for me to try? Now that we have this change in place with extended test coverage, I would expect that:

  $ bazel test //src/test/shell/bazel:bazel_coverage_java_jdk16_toolchain_released_test 

should just pass?!

bazel-io pushed a commit that referenced this pull request Apr 14, 2021
Closes bazelbuild/java_tools#49
Closes #11674
Unblocks #13270, #13274.

Closes #13343.

PiperOrigin-RevId: 368428107
@davido davido force-pushed the java_16_toolchain branch from 13430e5 to 8d6288f Compare April 14, 2021 14:52
@davido
Copy link
Contributor Author

davido commented Apr 14, 2021

@comius

Thanks for bumping jacoco and asm dependencies.

If it works, could you merge it and release yet another java_tools with Java 16 support?

@comius
Copy link
Contributor

comius commented Apr 14, 2021

If it works, could you merge it and release yet another java_tools with Java 16 support?

No need. None of the files in this PR are a part of java_tools. I reorganised this a while ago to make things easier. We merge this PR and you're done.

@davido
Copy link
Contributor Author

davido commented Apr 14, 2021

No need. None of the files in this PR are a part of java_tools. I reorganised this a while ago to make things easier. We merge this PR and you're done.

Great news. How can I activate the new toolchain built from this PR in bazel?

I'm asking because coverage Java 16 tests are still failing. Even though, I've rebased this PR on Bazel@HEAD.

@davido
Copy link
Contributor Author

davido commented Apr 14, 2021

I can reproduce the failure locally, and see this if I try to run coverage with Java 16 toochain:

INFO: From Testing //:test:
==================== Test output for //:test:
+ [[ -z bazel-out/k8-fastbuild/bin/test.instrumented_files ]]
+ export ROOT=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__
+ ROOT=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__
+ [[ bazel-out/k8-fastbuild/bin/test.instrumented_files != /* ]]
+ export COVERAGE_MANIFEST=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.instrumented_files
+ COVERAGE_MANIFEST=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.instrumented_files
+ export COVERAGE_DIR=_coverage/test/test
+ COVERAGE_DIR=_coverage/test/test
+ [[ _coverage/test/test == /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__* ]]
+ COVERAGE_DIR=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test
+ mkdir -p /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test
+ COVERAGE_OUTPUT_FILE=bazel-out/k8-fastbuild/testlogs/test/coverage.dat
+ [[ bazel-out/k8-fastbuild/testlogs/test/coverage.dat == /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__* ]]
+ COVERAGE_OUTPUT_FILE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/testlogs/test/coverage.dat
+ export JAVA_COVERAGE_FILE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/jvcov.dat
+ JAVA_COVERAGE_FILE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/jvcov.dat
+ export COVERAGE=1
+ COVERAGE=1
+ export BULK_COVERAGE_RUN=1
+ BULK_COVERAGE_RUN=1
+ for name in "$LCOV_MERGER"
+ [[ ! -e bazel-out/k8-opt-exec-2B5CBBC6/bin/external/remote_coverage_tools/Main ]]
+ [[ -z '' ]]
+ export GCOV_PREFIX_STRIP=3
+ GCOV_PREFIX_STRIP=3
+ export GCOV_PREFIX=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test
+ GCOV_PREFIX=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test
+ export LLVM_PROFILE_FILE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/%h-%p-%m.profraw
+ LLVM_PROFILE_FILE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/%h-%p-%m.profraw
+ [[ ! -z bazel-out/k8-fastbuild/bin/runtime_classpath_for_coverage/test/runtime_classpath.txt ]]
+ JAVA_RUNTIME_CLASSPATH_FOR_COVERAGE=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/runtime_classpath_for_coverage/test/runtime_classpath.txt
+ SINGLE_JAR_TOOL=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/external/remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local
+ mkdir -p /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test
+ single_jar_params_file=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/runtime_classpath.paramsfile
+ touch /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/runtime_classpath.paramsfile
+ export JACOCO_METADATA_JAR=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/coverage-runtime_merged_instr.jar
+ JACOCO_METADATA_JAR=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/coverage-runtime_merged_instr.jar
+ echo -e '--output /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/coverage-runtime_merged_instr.jar\n--sources'
+ RUNFILES_PREFIX=/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/
+ cat /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/runtime_classpath_for_coverage/test/runtime_classpath.txt
+ sed 's@^@/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/@'
+ /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/external/remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local @/home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/_coverage/test/test/runtime_classpath.paramsfile
singlejar_local: ./src/tools/singlejar/mapped_file_posix.inc:42: open /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/java_tools/JacocoCoverage_jarjar_deploy.jar:: No such file or directory
singlejar_local: src/tools/singlejar/input_jar.cc:24: Cannot open input jar /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/sandbox/linux-sandbox/14/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/java_tools/JacocoCoverage_jarjar_deploy.jar: No such file or directory

@davido
Copy link
Contributor Author

davido commented Apr 14, 2021

If I disable the sandbox, it doesn't find Jacoco either:

singlejar_local: src/tools/singlejar/input_jar.cc:24: Cannot open input jar /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/java_tools/JacocoCoverage_jarjar_deploy.jar: No such file or directory

Looking into the directory structure, it's here:

$ ls -all /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/external/remote_java_tools/java_tools/JacocoCoverage_jarjar_deploy.jar
lrwxrwxrwx 1 davido users 143 Apr 14 17:48 /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/execroot/__main__/bazel-out/k8-fastbuild/bin/test.runfiles/__main__/external/remote_java_tools/java_tools/JacocoCoverage_jarjar_deploy.jar -> /home/davido/.cache/bazel/_bazel_davido/d2e4628c65018481d7632ab5397b30b3/external/remote_java_tools/java_tools/JacocoCoverage_jarjar_deploy.jar

@comius
Copy link
Contributor

comius commented Apr 15, 2021

Great news. How can I activate the new toolchain built from this PR in bazel?

Just using --{,tool_}java_language_version=16, --{,tool_}java_runtime_version=16 flags.

I can reproduce the same problems locally. They are weird though:

java.util.zip.ZipException: zip END header not found

.Exception in thread "main" java.lang.IllegalStateException: JACOCO_METADATA_JAR/JACOCO_MAIN_CLASS environment 
variables not set, and no META-INF/MANIFEST.MF on the classpath has a Coverage-Main-Class attribute.  Cannot 
determine the name of the main class for the code under test.
	at com.google.testing.coverage.JacocoCoverageRunner.getMainClass(JacocoCoverageRunner.java:323)


.Exception in thread "main" java.lang.ClassNotFoundException: com.google.testing.junit.runner.BazelTestRunner

Possibly connected to some new visibility/exports requirement in JDK16?

Would you mind disabling coverage test on JDK16, opening a separate issue for it and pushing this PR forward?

@davido
Copy link
Contributor Author

davido commented Apr 15, 2021

Would you mind disabling coverage test on JDK16, opening a separate issue for it and pushing this PR forward?

Sure, will update PR in a moment and open coverage issue for JDK 16. Thanks!

Closes bazelbuild#13270.

Change-Id: I215c2f86a35f87bea0102cf6da5248b19a319d3e
@davido
Copy link
Contributor Author

davido commented Apr 15, 2021

Would you mind disabling coverage test on JDK16, opening a separate issue for it and pushing this PR forward?

Sure, will update PR in a moment and open coverage issue for JDK 16.

Done. PTAL.

Copy link
Contributor

@comius comius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@bazel-io bazel-io closed this in e2ed2fd Apr 15, 2021
@davido davido deleted the java_16_toolchain branch April 15, 2021 12:50
@cushon cushon mentioned this pull request Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java 16 toolchain support
3 participants