Skip to content

eikemeier/bazel_jdk17

Repository files navigation

Bazel JDK 17 Record Issue

Table of Contents

Abstract

Bazel 5.0rc1 cannot link JDK 17 records with explicit declared constructors in a separate package.

Demonstration

Install bazelisk, then run

bazelisk run //src/main/java/com/example

It fails with

ERROR: [...]/bazel_jdk17/src/main/java/com/example/hello/BUILD:3:13: Compiling Java headers src/main/java/com/example/hello/libhello-hjar.jar (1 source file) failed: (Exit 1): java failed: error executing command external/remotejdk17_macos/bin/java [...]

src/main/java/com/example/hello/Hello.java:6: error: unexpected token: {
  public Hello {
               ^

Analysis

Interestingly enough,

bazelisk build //src/main/java/com/example/hello

works, so the record can be compiled. What fails is the linking

bazelisk build --verbose_failures --sandbox_debug //src/main/java/com/example

On the other hand

bazelisk run --nojava_header_compilation //src/main/java/com/example

works, so it might be an issue with Turbine.