From 2a48a7d65a46c7669c55d7222b2c96ac9c7c8ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Rohde=20D=C3=B8ssing?= Date: Fri, 5 Apr 2024 10:10:08 +0200 Subject: [PATCH] Check ct.sym first before falling back to jrt Since Turbine is used via a GraalVM native image in Bazel, jrt is not enabled, so looking up the bootclasspath that way doesn't work. As of Java 22, ct.sym contains signatures for all supported JDKs, so there is no need to look in jrt. Partial fix for https://github.com/bazelbuild/bazel/issues/21895 --- java/com/google/turbine/main/Main.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/java/com/google/turbine/main/Main.java b/java/com/google/turbine/main/Main.java index 98df39ee..86d7339a 100644 --- a/java/com/google/turbine/main/Main.java +++ b/java/com/google/turbine/main/Main.java @@ -301,16 +301,16 @@ private static ClassPath bootclasspath(TurbineOptions options) throws IOExceptio } if (release.isPresent()) { - if (release.getAsInt() == Integer.parseInt(JAVA_SPECIFICATION_VERSION.value())) { + // Search ct.sym for a matching release + ClassPath bootclasspath = CtSymClassBinder.bind(release.getAsInt()); + if (bootclasspath != null) { + return bootclasspath; + } else if (release.getAsInt() == Integer.parseInt(JAVA_SPECIFICATION_VERSION.value())) { // if --release matches the host JDK, use its jimage instead of ct.sym return JimageClassBinder.bindDefault(); - } - // ... otherwise, search ct.sym for a matching release - ClassPath bootclasspath = CtSymClassBinder.bind(release.getAsInt()); - if (bootclasspath == null) { + } else { throw new UsageException("not a supported release: " + release); } - return bootclasspath; } if (options.system().isPresent()) {