|
92 | 92 | @FromLibGraalEntryPointsResolver(value = TruffleFromLibGraal.Id.class, entryPointsClassName = "com.oracle.truffle.runtime.hotspot.libgraal.TruffleFromLibGraalEntryPoints")
|
93 | 93 | final class HSTruffleCompilerRuntime extends HSObject implements TruffleCompilerRuntime {
|
94 | 94 |
|
| 95 | + private static final Class<?> TRANSLATED_EXCEPTION; |
| 96 | + static { |
| 97 | + Class<?> clz; |
| 98 | + try { |
| 99 | + clz = Class.forName("jdk.internal.vm.TranslatedException"); |
| 100 | + } catch (ClassNotFoundException cnf) { |
| 101 | + clz = null; |
| 102 | + } |
| 103 | + TRANSLATED_EXCEPTION = clz; |
| 104 | + } |
| 105 | + |
95 | 106 | private final ResolvedJavaType classLoaderDelegate;
|
96 | 107 | final TruffleFromLibGraalCalls calls;
|
97 | 108 |
|
@@ -209,7 +220,27 @@ public ConstantFieldInfo getConstantFieldInfo(ResolvedJavaField field) {
|
209 | 220 | @Override
|
210 | 221 | public ResolvedJavaType resolveType(MetaAccessProvider metaAccess, String className, boolean required) {
|
211 | 222 | String internalName = getInternalName(className);
|
212 |
| - JavaType jt = runtime().lookupType(internalName, (HotSpotResolvedObjectType) classLoaderDelegate, required); |
| 223 | + JavaType jt; |
| 224 | + try { |
| 225 | + jt = runtime().lookupType(internalName, (HotSpotResolvedObjectType) classLoaderDelegate, required); |
| 226 | + } catch (Exception e) { |
| 227 | + if (TRANSLATED_EXCEPTION != null && TRANSLATED_EXCEPTION.isInstance(e)) { |
| 228 | + /* |
| 229 | + * As of JDK 24 (JDK-8335553), a translated exception is boxed in a |
| 230 | + * TranslatedException. Unbox a translated unchecked exception as they are the only |
| 231 | + * ones that can be expected by callers since this method is not declared in checked |
| 232 | + * exceptions. |
| 233 | + */ |
| 234 | + Throwable cause = e.getCause(); |
| 235 | + if (cause instanceof Error) { |
| 236 | + throw (Error) cause; |
| 237 | + } |
| 238 | + if (cause instanceof RuntimeException) { |
| 239 | + throw (RuntimeException) cause; |
| 240 | + } |
| 241 | + } |
| 242 | + throw e; |
| 243 | + } |
213 | 244 | if (jt instanceof UnresolvedJavaType) {
|
214 | 245 | if (required) {
|
215 | 246 | throw new NoClassDefFoundError(internalName);
|
|
0 commit comments