Skip to content

Commit cf5ec75

Browse files
committed
Set test toolchains to @rules_java//toolchains:
The test target toolchain updates resolve the following errors under Bazel 6.5.0: ```txt $ bazel build //{src,jmh,test,third_party,scala_proto}/... [ ...snip... ] ERROR: test/src/main/resources/java_sources/BUILD:11:14: Building test/src/main/resources/java_sources/CompiledWithJava11_java.jar (1 source file) failed: Worker process did not return a WorkResponse: ---8<---8<--- Start of log, file at .../bazel-workers/multiplex-worker-33-Javac.log ---8<---8<--- Error thrown by worker thread, shutting down worker. java.lang.UnsupportedClassVersionError: com/google/errorprone/ErrorProneError has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) [ ...snip... ] ERROR: test/src/main/resources/java_sources/BUILD:5:14: Building test/src/main/resources/java_sources/CompiledWithJava8_java.jar (1 source file) failed: Worker process did not return a WorkResponse: ---8<---8<--- Start of log, file at .../bazel-workers/multiplex-worker-33-Javac.log ---8<---8<--- Error thrown by worker thread, shutting down worker. java.lang.UnsupportedClassVersionError: com/google/errorprone/ErrorProneError has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) [ ...snip... ] ``` Bazel 6.5.0 now breaks with the expected error, fixed by: - bazelbuild/rules_java@30ecf3f - `rules_java` 7.10.0 ```txt $ bazel build //{src,jmh,test,third_party,scala_proto}/... ERROR: .../external/rules_java/toolchains/java_toolchain_alias.bzl:83:34: Use of Starlark transition without allowlist attribute '_allowlist_function_transition'. See Starlark transitions documentation for details and usage: @rules_java//toolchains:java_toolchain_alias.bzl NORMAL ERROR: test/aspect/BUILD:67:26: While resolving toolchains for target //test/aspect:javainfo_from_aspect_test: invalid registered toolchain '//toolchains:all': while parsing '//toolchains:all': error loading package '@rules_java//toolchains': initialization of module 'toolchains/java_toolchain_alias.bzl' failed ``` Bazel 7.4.1 builds, and Bazel 8.0.0rc6 and 8.0.0rc7 fail as described in the previous commit.
1 parent 55b6ee6 commit cf5ec75

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

test/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ scala_library(
782782
"src/main/scala/scalarules/test/junit/runtime_platform/JunitRuntimePlatformTest.java",
783783
],
784784
# make sure java compilation toolchain matches runtime toolchain ie --target
785-
java_compile_toolchain = "@bazel_tools//tools/jdk:toolchain_java11",
785+
java_compile_toolchain = "@rules_java//toolchains:toolchain_java11",
786786
deps = ["@io_bazel_rules_scala_junit_junit"],
787787
)
788788

test/src/main/resources/java_sources/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ package(default_visibility = ["//visibility:public"])
55
scala_library(
66
name = "CompiledWithJava8",
77
srcs = ["SimpleJavaSourceFileA.java"],
8-
java_compile_toolchain = "@bazel_tools//tools/jdk:toolchain_java8",
8+
java_compile_toolchain = "@rules_java//toolchains:toolchain_java8",
99
)
1010

1111
scala_library(
1212
name = "CompiledWithJava11",
1313
srcs = ["SimpleJavaSourceFileB.java"],
14-
java_compile_toolchain = "@bazel_tools//tools/jdk:toolchain_java11",
14+
java_compile_toolchain = "@rules_java//toolchains:toolchain_java11",
1515
)

0 commit comments

Comments
 (0)