From 84d11dc906378bd9ab427ceb16336dfa89a088c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Rohde=20D=C3=B8ssing?= Date: Fri, 5 Apr 2024 16:20:15 -0700 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 Fixes #318 FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google/turbine/pull/318 from srdo-humio:stig/check-ct-sym-first 2a48a7d65a46c7669c55d7222b2c96ac9c7c8ada PiperOrigin-RevId: 622308437 --- 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 98df39e..86d7339 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()) {