diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/SharedConstantFieldProvider.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/SharedConstantFieldProvider.java index 10d74e882bb4..26f83f9c02c8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/SharedConstantFieldProvider.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/SharedConstantFieldProvider.java @@ -70,7 +70,18 @@ public boolean isFinalField(ResolvedJavaField field, ConstantFieldTool tool) @Override public boolean isStableField(ResolvedJavaField field, ConstantFieldTool tool) { - return super.isStableField(field, tool) && allowConstantFolding(field); + boolean stable; + /* + * GR-46030: JVMCI does not provide access yet to the proper "stable" flag that also takes + * the class loader of the using class into account. So we look at the annotation directly + * for now. + */ + if (field.isAnnotationPresent(jdk.internal.vm.annotation.Stable.class)) { + stable = true; + } else { + stable = super.isStableField(field, tool); + } + return stable && allowConstantFolding(field); } private boolean allowConstantFolding(ResolvedJavaField field) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java index 8ec6f279d51c..fd6cf625f0f7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java @@ -149,7 +149,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { Class mhImplClazz = access.findClassByName("java.lang.invoke.MethodHandleImpl"); access.registerReachabilityHandler(MethodHandleFeature::registerMHImplFunctionsForReflection, - ReflectionUtil.lookupMethod(mhImplClazz, "createFunction", byte.class)); + ReflectionUtil.lookupMethod(mhImplClazz, "getFunction", byte.class)); access.registerReachabilityHandler(MethodHandleFeature::registerMHImplConstantHandlesForReflection, ReflectionUtil.lookupMethod(mhImplClazz, "makeConstantHandle", int.class)); @@ -158,7 +158,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { access.findClassByName("java.lang.invoke.MethodHandleImpl$CountingWrapper")); access.registerReachabilityHandler(MethodHandleFeature::registerInvokersFunctionsForReflection, - ReflectionUtil.lookupMethod(access.findClassByName("java.lang.invoke.Invokers"), "createFunction", byte.class)); + ReflectionUtil.lookupMethod(access.findClassByName("java.lang.invoke.Invokers"), "getFunction", byte.class)); access.registerReachabilityHandler(MethodHandleFeature::registerValueConversionBoxFunctionsForReflection, ReflectionUtil.lookupMethod(ValueConversions.class, "boxExact", Wrapper.class));