bazelbuild / bazelbuild/bazel

remote_coverage_tools requires JDK 11

Open
#17,606 3 comments 0 reactions 0 assignees View on GitHub
coverage type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### 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?

- https://github.com/bazelbuild/bazel/issues/17165 refers to use of the java 11 runner to build against java 8 targets. We are using Java 8 everywhere.
- https://github.com/bazelbuild/bazel/issues/17568 is python-specific
- https://github.com/bazelbuild/bazel/issues/17458 is specific to the runfiles library

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the remote_coverage_tools packaging and build path, then reproduce the issue using the supplied coverage command with Java 8 settings. Check whether the precompiled coverageoutputgenerator is produced for JDK 11 and whether its sources are available in the Bazel binary distribution. Done means the coverage invocation runs under JDK 8 without the UnsupportedClassVersionError.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.