Skip to content

Commit 041a219

Browse files
author
Christian Wimmer
committed
[GR-46031] Add support for @stable annotation.
PullRequest: graal/14528
2 parents d08de8b + 984bce6 commit 041a219

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
@@ -154,7 +154,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
154154
Class<?> mhImplClazz = access.findClassByName("java.lang.invoke.MethodHandleImpl");
155155

156156
access.registerReachabilityHandler(MethodHandleFeature::registerMHImplFunctionsForReflection,
157-
ReflectionUtil.lookupMethod(mhImplClazz, "createFunction", byte.class));
157+
ReflectionUtil.lookupMethod(mhImplClazz, "getFunction", byte.class));
158158

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

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

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

0 commit comments

Comments
 (0)