Skip to content

Commit 984bce6

Browse files
author
Christian Wimmer
committed
Add support for @stable annotation
1 parent 74de527 commit 984bce6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/SharedConstantFieldProvider.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ public boolean isFinalField(ResolvedJavaField field, ConstantFieldTool<?> tool)
7070

7171
@Override
7272
public boolean isStableField(ResolvedJavaField field, ConstantFieldTool<?> tool) {
73-
return super.isStableField(field, tool) && allowConstantFolding(field);
73+
boolean stable;
74+
/*
75+
* GR-46030: JVMCI does not provide access yet to the proper "stable" flag that also takes
76+
* the class loader of the using class into account. So we look at the annotation directly
77+
* for now.
78+
*/
79+
if (field.isAnnotationPresent(jdk.internal.vm.annotation.Stable.class)) {
80+
stable = true;
81+
} else {
82+
stable = super.isStableField(field, tool);
83+
}
84+
return stable && allowConstantFolding(field);
7485
}
7586

7687
private boolean allowConstantFolding(ResolvedJavaField field) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
149149
Class<?> mhImplClazz = access.findClassByName("java.lang.invoke.MethodHandleImpl");
150150

151151
access.registerReachabilityHandler(MethodHandleFeature::registerMHImplFunctionsForReflection,
152-
ReflectionUtil.lookupMethod(mhImplClazz, "createFunction", byte.class));
152+
ReflectionUtil.lookupMethod(mhImplClazz, "getFunction", byte.class));
153153

154154
access.registerReachabilityHandler(MethodHandleFeature::registerMHImplConstantHandlesForReflection,
155155
ReflectionUtil.lookupMethod(mhImplClazz, "makeConstantHandle", int.class));
@@ -158,7 +158,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
158158
access.findClassByName("java.lang.invoke.MethodHandleImpl$CountingWrapper"));
159159

160160
access.registerReachabilityHandler(MethodHandleFeature::registerInvokersFunctionsForReflection,
161-
ReflectionUtil.lookupMethod(access.findClassByName("java.lang.invoke.Invokers"), "createFunction", byte.class));
161+
ReflectionUtil.lookupMethod(access.findClassByName("java.lang.invoke.Invokers"), "getFunction", byte.class));
162162

163163
access.registerReachabilityHandler(MethodHandleFeature::registerValueConversionBoxFunctionsForReflection,
164164
ReflectionUtil.lookupMethod(ValueConversions.class, "boxExact", Wrapper.class));

0 commit comments

Comments
 (0)