bazelbuild / bazelbuild/bazel

Failure to start from source due to bytecode version for bazel-dev vs. bazel

Open
#21,974 1 comment 1 reaction 0 assignees View on GitHub
team-Core type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

Building **bazel-dev** fails to start due to mismatch bytecode version.
This is confusing because my understanding is that it should have an embedded JDK?

```
Something is weird with all_modules version
❯ ./bazel-bin/src/bazel-dev
Starting local Bazel server and connecting to it...
Server crashed during startup. Now printing /usr/local/google/home/fmzakari/.cache/bazel/_bazel_fmzakari/874c14ef1c34fc798aecff4a194edbff/server/jvm.out
Error: LinkageError occurred while loading main class com.google.devtools.build.lib.bazel.Bazel
java.lang.UnsupportedClassVersionError: com/google/devtools/build/lib/bazel/Bazel has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 55.0
```

The **bazel** target which has the minimal JDK seems to work fine.
```
) for suffix, jdk in [
("-dev", "_jdk_allmodules"),
("", "_jdk_minimal"),
("_jdk_allmodules", "_jdk_allmodules"),
("_jdk_minimal", "_jdk_minimal"),
("_notools", "_notools"),
("_nojdk", "_nojdk"),
]]
```

```
❯ ./bazel-bin/src/bazel
Starting local Bazel server and connecting to it...
[bazel development version]
Usage: bazel .
```

**bazel_nojdk** also has the problem but from what I understand that is picking up my default JDK which is Java11
```
❯ bazel-bin/src/bazel_nojdk

Starting local Bazel server and connecting to it...
Server crashed during startup. Now printing /usr/local/google/home/fmzakari/.cache/bazel/_bazel_fmzakari/874c14ef1c34fc798aecff4a194edbff/server/jvm.out
Error: LinkageError occurred while loading main class com.google.devtools.build.lib.bazel.Bazel
java.lang.UnsupportedClassVersionError: com/google/devtools/build/lib/bazel/Bazel has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 55.0
```

### Which category does this issue belong to?

Core

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

_No response_

### Which operating system are you running Bazel on?

Linux

### What is the output of `bazel info release`?

7.1.1

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

_No response_

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

_No response_

### Have you found anything relevant by searching the web?

_No response_

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by comparing the bazel-dev, bazel, and bazel_nojdk build targets and the JDK selections shown in the issue. Reproduce the startup commands on Linux and trace why bazel-dev launches Java 11-class runtime code against class files built for Java 21; done means the affected targets start without 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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.