Skip to content

Commit 4c2718e

Browse files
committed
[GR-63733] Make Class.forName work with null caller class
PullRequest: graal/20457
2 parents c842d73 + 9ccac09 commit 4c2718e

File tree

1 file changed

+1
-6
lines changed
  • substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub

1 file changed

+1
-6
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
import org.graalvm.nativeimage.Platform;
8686
import org.graalvm.nativeimage.Platforms;
8787
import org.graalvm.nativeimage.c.function.CFunctionPointer;
88-
import org.graalvm.nativeimage.impl.InternalPlatform;
8988

9089
import com.oracle.svm.core.BuildPhaseProvider.AfterHostedUniverse;
9190
import com.oracle.svm.core.BuildPhaseProvider.CompileQueueFinished;
@@ -1567,28 +1566,24 @@ private static Constructor<?>[] copyConstructors(Constructor<?>[] original) {
15671566
private native Constructor<?> getEnclosingConstructor();
15681567

15691568
@Substitute
1570-
@Platforms(InternalPlatform.NATIVE_ONLY.class)
15711569
@CallerSensitive
15721570
private static Class<?> forName(String className) throws Throwable {
15731571
return forName(className, Reflection.getCallerClass());
15741572
}
15751573

15761574
@Substitute
1577-
@Platforms(InternalPlatform.NATIVE_ONLY.class)
15781575
@CallerSensitiveAdapter
15791576
private static Class<?> forName(String className, Class<?> caller) throws Throwable {
1580-
return forName(className, true, caller.getClassLoader(), caller);
1577+
return forName(className, true, caller == null ? ClassLoader.getSystemClassLoader() : caller.getClassLoader(), caller);
15811578
}
15821579

15831580
@Substitute
1584-
@Platforms(InternalPlatform.NATIVE_ONLY.class)
15851581
@CallerSensitive
15861582
private static Class<?> forName(Module module, String className) throws Throwable {
15871583
return forName(module, className, Reflection.getCallerClass());
15881584
}
15891585

15901586
@Substitute
1591-
@Platforms(InternalPlatform.NATIVE_ONLY.class)
15921587
@CallerSensitiveAdapter
15931588
@TargetElement(onlyWith = JDK21OrEarlier.class)
15941589
private static Class<?> forName(@SuppressWarnings("unused") Module module, String className, Class<?> caller) throws Throwable {

0 commit comments

Comments
 (0)