Skip to content

Commit 2e889d9

Browse files
committed
move side-effecting code out of GuestGraalFeature constructor
1 parent 1b709d2 commit 2e889d9

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

substratevm/src/com.oracle.svm.graal.hotspot.guestgraal/resources/META-INF/native-image/com.oracle.svm.graal.hotspot.guestgraal/native-image.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Args = \
66
-Djdk.vm.ci.services.aot=true \
77
-Dtruffle.TruffleRuntime= \
88
--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED \
9+
--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.feature=ALL-UNNAMED \
910
--features=com.oracle.svm.graal.hotspot.guestgraal.GuestGraalFeature \
1011
--enable-monitoring=heapdump \
1112
--no-fallback \

substratevm/src/com.oracle.svm.graal.hotspot.guestgraal/src/com/oracle/svm/graal/hotspot/guestgraal/GuestGraalFeature.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
import com.oracle.svm.graal.hotspot.GetCompilerConfig;
4949
import com.oracle.svm.graal.hotspot.GetJNIConfig;
5050
import com.oracle.svm.hosted.FeatureImpl;
51-
import com.oracle.svm.hosted.jni.JNIFeature;
52-
import com.oracle.svm.hosted.reflect.ReflectionFeature;
5351
import jdk.graal.compiler.options.OptionDescriptor;
5452
import jdk.graal.compiler.options.OptionKey;
5553
import jdk.graal.compiler.serviceprovider.LibGraalService;
@@ -128,27 +126,8 @@ public boolean getAsBoolean() {
128126
}
129127
}
130128

131-
private GuestGraalFeature() {
132-
// GuestGraalFieldsOffsetsFeature implements InternalFeature which is in
133-
// the non-public package com.oracle.svm.core.feature
134-
accessModulesToClass(ModuleSupport.Access.EXPORT, GuestGraalFeature.class, "org.graalvm.nativeimage.builder");
135-
136-
// GuestGraalFeature accesses a few Graal classes (see import statements above)
137-
accessModulesToClass(ModuleSupport.Access.EXPORT, GuestGraalFeature.class, "jdk.graal.compiler");
138-
}
139-
140129
@Override
141130
public List<Class<? extends Feature>> getRequiredFeatures() {
142-
/*
143-
* LibGraal needs JNIFeature for the upcalls from HotSpot and ReflectionFeature to construct
144-
* exceptions in jdk.internal.vm.TranslatedException.create(). However, both of these
145-
* features are automatically registered (i.e. annotated by @AutomaticallyRegisteredFeature)
146-
* so no need to explicitly add them here. Simply trying to look them up ensures that they
147-
* are available.
148-
*/
149-
ImageSingletons.lookup(ReflectionFeature.class);
150-
ImageSingletons.lookup(JNIFeature.class);
151-
152131
return List.of(GuestGraalFieldsOffsetsFeature.class);
153132
}
154133

@@ -196,6 +175,13 @@ public GuestGraalClassLoader getLoader() {
196175
*/
197176
@Override
198177
public void afterRegistration(AfterRegistrationAccess access) {
178+
// GuestGraal uses a number of classes in org.graalvm.nativeimage.builder
179+
accessModulesToClass(ModuleSupport.Access.EXPORT, GuestGraalFeature.class,
180+
"org.graalvm.nativeimage.builder");
181+
182+
// GuestGraalFeature accesses a few Graal classes (see import statements above)
183+
accessModulesToClass(ModuleSupport.Access.EXPORT, GuestGraalFeature.class, "jdk.graal.compiler");
184+
199185
ImageSingletons.add(NativeBridgeSupport.class, new GuestGraalNativeBridgeSupport());
200186
// Target_jdk_graal_compiler_serviceprovider_VMSupport.getIsolateID needs access to
201187
// org.graalvm.nativeimage.impl.IsolateSupport

0 commit comments

Comments
 (0)