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

remote_coverage_tools requires JDK 11 #17606

Open
nacl opened this issue Feb 27, 2023 · 3 comments
Open

remote_coverage_tools requires JDK 11 #17606

nacl opened this issue Feb 27, 2023 · 3 comments

Comments

@nacl
Copy link

nacl commented Feb 27, 2023

Description of the bug:

Our build uses JDK 8 to run tools and build binaries. Bazel itself and a sizeable amount of the precompiled tools are compiled using JDK 11, however, the Bazel java_tools are compiled with JDK 8 and work fine in our setup.

The remote_coverage_tools binaries, however, are precompiled using JDK 11, resulting in the following stacktrace in our setup:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/devtools/coverageoutputgenerator/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:365)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

To maintain JDK 8 compatibility (if desired), it would seem that the remote_coverage_tools should be built targeting JDK 8, or the sources made available as a part of the Bazel binary distribution

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

In Bazel itself:

bazel coverage --java_language_version=8 --tool_java_language_version=8 --java_runtime_version=8 --tool_java_runtime_version=8 //src/tools/singlejar:output_jar_simple_test

Will have this stack trace in the logs.

The build fails with JDK 8 in recent 7.0.0-pre builds due to (apparently) incompatible changes. A different example may needed for that purpose.

Which operating system are you running Bazel on?

Linux, Alma 9 (RHEL-like), arm64

What is the output of bazel info release?

release 6.1.0rc1 (also reproduces with 6.0.0)

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

Any other information, logs, or outputs that you want to share?

No response

@nacl
Copy link
Author

nacl commented Feb 27, 2023

This issue seems to be the direct result of the upgrade to coverage_output_generator 2.6 in a70d84b. 2.5 seems to have been compiled targeting JDK 8.

@c-mita c-mita added coverage and removed team-Rules-CPP Issues for C++ rules labels Feb 28, 2023
@thirtyseven
Copy link
Contributor

thirtyseven commented Mar 1, 2023

@nacl Bazel uses a separate JRE to run java tools like remote_coverage_tools, this is what --tool_java_language_version and --tool_java_runtime_version control. Is there any reason you also need them to be set to Java 8? In our Java 8 project, we have them set to the default of 11 with no issues.

@nacl
Copy link
Author

nacl commented Mar 1, 2023

@thirtyseven I am aware of those flags, but unfortunately we have numerous other java tools that are untested with Java 11. I agree that it will probably be fine, but if anything does come up it may become difficult to address the problems in a timely manner, as the people who might need to be involved have their own priorities/timetables/etc.

FWIW, I was able to compile these tools targeting Java 8 in our private build of Bazel with no issue, and coverage reports were generated as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants