Skip to content

Commit e4a1f23

Browse files
author
Christian Wimmer
committed
Remove SubstrateReflectionAccessorFactory
1 parent 299c651 commit e4a1f23

File tree

7 files changed

+17
-135
lines changed

7 files changed

+17
-135
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@
425425
"sun.util.resources",
426426
"jdk.internal.module",
427427
"sun.text.spi",
428+
"jdk.internal.reflect",
428429
],
429430
"jdk.internal.vm.ci" : [
430431
"jdk.vm.ci.runtime",
@@ -756,6 +757,7 @@
756757
"requiresConcealed" : {
757758
"java.base" : [
758759
"sun.invoke.util",
760+
"jdk.internal.reflect",
759761
],
760762
},
761763
"checkstyle": "com.oracle.svm.core",

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk11/reflect/SubstrateReflectionAccessorFactoryJDK11.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateConstructorAccessor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
import com.oracle.svm.core.jdk.InternalVMMethod;
3535
import com.oracle.svm.core.util.VMError;
3636

37+
import jdk.internal.reflect.ConstructorAccessor;
38+
3739
@InternalVMMethod
38-
public abstract class SubstrateConstructorAccessor {
40+
public final class SubstrateConstructorAccessor implements ConstructorAccessor {
3941

4042
interface ConstructorNewInstanceFunctionPointer extends CFunctionPointer {
4143
/** Must match the signature of {@link ReflectionAccessorHolder#newInstancePrototype}. */
@@ -46,11 +48,12 @@ interface ConstructorNewInstanceFunctionPointer extends CFunctionPointer {
4648
private final Executable member;
4749
private final CFunctionPointer newInstanceFunctionPointer;
4850

49-
protected SubstrateConstructorAccessor(Executable member, CFunctionPointer newInstanceFunctionPointer) {
51+
public SubstrateConstructorAccessor(Executable member, CFunctionPointer newInstanceFunctionPointer) {
5052
this.member = member;
5153
this.newInstanceFunctionPointer = newInstanceFunctionPointer;
5254
}
5355

56+
@Override
5457
public Object newInstance(Object[] args) {
5558
ConstructorNewInstanceFunctionPointer functionPointer = (ConstructorNewInstanceFunctionPointer) this.newInstanceFunctionPointer;
5659
if (functionPointer.isNull()) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateMethodAccessor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
import com.oracle.svm.core.jdk.InternalVMMethod;
3535
import com.oracle.svm.core.util.VMError;
3636

37+
import jdk.internal.reflect.MethodAccessor;
38+
3739
@InternalVMMethod
38-
public abstract class SubstrateMethodAccessor {
40+
public final class SubstrateMethodAccessor implements MethodAccessor {
3941

4042
interface MethodInvokeFunctionPointer extends CFunctionPointer {
4143
/** Must match the signature of {@link ReflectionAccessorHolder#invokePrototype}. */
@@ -46,11 +48,12 @@ interface MethodInvokeFunctionPointer extends CFunctionPointer {
4648
private final Executable member;
4749
private final CFunctionPointer invokeFunctionPointer;
4850

49-
protected SubstrateMethodAccessor(Executable member, CFunctionPointer invokeFunctionPointer) {
51+
public SubstrateMethodAccessor(Executable member, CFunctionPointer invokeFunctionPointer) {
5052
this.member = member;
5153
this.invokeFunctionPointer = invokeFunctionPointer;
5254
}
5355

56+
@Override
5457
public Object invoke(Object obj, Object[] args) {
5558
MethodInvokeFunctionPointer functionPointer = (MethodInvokeFunctionPointer) this.invokeFunctionPointer;
5659
if (functionPointer.isNull()) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateReflectionAccessorFactory.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.graalvm.compiler.core.common.NumUtil;
4545
import org.graalvm.compiler.debug.DebugContext;
4646
import org.graalvm.compiler.debug.Indent;
47-
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
4847
import org.graalvm.nativeimage.ImageSingletons;
4948
import org.graalvm.nativeimage.c.function.CEntryPointLiteral;
5049
import org.graalvm.nativeimage.c.function.CFunction;
@@ -84,6 +83,8 @@
8483
import com.oracle.svm.core.hub.DynamicHubSupport;
8584
import com.oracle.svm.core.hub.LayoutEncoding;
8685
import com.oracle.svm.core.meta.MethodPointer;
86+
import com.oracle.svm.core.reflect.SubstrateConstructorAccessor;
87+
import com.oracle.svm.core.reflect.SubstrateMethodAccessor;
8788
import com.oracle.svm.core.util.VMError;
8889
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;
8990
import com.oracle.svm.hosted.HostedConfiguration;
@@ -368,22 +369,9 @@ private void buildProfilingInformation() {
368369
CEntryPointLiteral.class,
369370
BoxedRelocatedPointer.class,
370371
FunctionPointerHolder.class,
372+
SubstrateMethodAccessor.class, SubstrateConstructorAccessor.class,
371373
FillerObject.class));
372374

373-
static {
374-
try {
375-
if (JavaVersionUtil.JAVA_SPEC >= 11) {
376-
IMMUTABLE_TYPES.add(Class.forName("com.oracle.svm.core.jdk11.reflect.SubstrateMethodAccessorJDK11"));
377-
IMMUTABLE_TYPES.add(Class.forName("com.oracle.svm.core.jdk11.reflect.SubstrateConstructorAccessorJDK11"));
378-
} else {
379-
IMMUTABLE_TYPES.add(Class.forName("com.oracle.svm.core.jdk8.reflect.SubstrateMethodAccessorJDK8"));
380-
IMMUTABLE_TYPES.add(Class.forName("com.oracle.svm.core.jdk8.reflect.SubstrateConstructorAccessorJDK8"));
381-
}
382-
} catch (ClassNotFoundException ex) {
383-
throw VMError.shouldNotReachHere(ex);
384-
}
385-
}
386-
387375
private void collectMonitorFieldInfo(BigBang bb) {
388376
if (!SubstrateOptions.MultiThreaded.getValue()) {
389377
/* No locking information needed in single-threaded mode. */

substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionFeature.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import com.oracle.svm.core.reflect.ReflectionAccessorHolder;
5757
import com.oracle.svm.core.reflect.SubstrateConstructorAccessor;
5858
import com.oracle.svm.core.reflect.SubstrateMethodAccessor;
59-
import com.oracle.svm.core.reflect.SubstrateReflectionAccessorFactory;
6059
import com.oracle.svm.core.util.VMError;
6160
import com.oracle.svm.hosted.FallbackFeature;
6261
import com.oracle.svm.hosted.FeatureImpl;
@@ -128,7 +127,7 @@ private Object createAccessor(Executable member) {
128127
ResolvedJavaMethod prototype = analysisAccess.getMetaAccess().lookupJavaMethod(invokePrototype).getWrapped();
129128
invokeMethod = createReflectiveInvokeMethod(name, prototype, (Method) member);
130129
}
131-
return ImageSingletons.lookup(SubstrateReflectionAccessorFactory.class).createMethodAccessor(member, register(invokeMethod));
130+
return new SubstrateMethodAccessor(member, register(invokeMethod));
132131

133132
} else {
134133
ResolvedJavaMethod newInstanceMethod;
@@ -145,7 +144,7 @@ private Object createAccessor(Executable member) {
145144
ResolvedJavaMethod prototype = analysisAccess.getMetaAccess().lookupJavaMethod(newInstancePrototype).getWrapped();
146145
newInstanceMethod = createReflectiveNewInstanceMethod(name, prototype, (Constructor<?>) member);
147146
}
148-
return ImageSingletons.lookup(SubstrateReflectionAccessorFactory.class).createConstructorAccessor(member, register(newInstanceMethod));
147+
return new SubstrateConstructorAccessor(member, register(newInstanceMethod));
149148
}
150149
}
151150

0 commit comments

Comments
 (0)