Skip to content

Commit 318a834

Browse files
[GR-65294] Fix Class.forName folding when respecting class loaders.
PullRequest: graal/20914
2 parents 5875d28 + 9b4aa2d commit 318a834

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/registry/BootClassRegistry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public synchronized Class<?> doLoadClass(Symbol<Type> type) {
6969
// Only looking into the jimage for now. There could be appended elements.
7070
// see GraalServices.getSavedProperty("jdk.boot.class.path.append")
7171
String pkg = packageFromType(type);
72+
if (pkg == null) {
73+
return null;
74+
}
7275
try {
7376
String moduleName = ClassRegistries.getBootModuleForPackage(pkg);
7477
if (moduleName == null) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ReflectionPlugins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
import com.oracle.svm.core.TrackDynamicAccessEnabled;
5252
import com.oracle.svm.hosted.DynamicAccessDetectionFeature;
53+
import com.oracle.svm.hosted.NativeImageSystemClassLoader;
5354
import org.graalvm.nativeimage.ImageSingletons;
5455
import org.graalvm.nativeimage.hosted.RuntimeReflection;
5556
import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport;
@@ -343,7 +344,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
343344
return false;
344345
}
345346
loader = (ClassLoader) unboxObjectConstant(b, classLoaderNode.asJavaConstant());
346-
if (loader == ClassLoader.getSystemClassLoader()) {
347+
if (loader == NativeImageSystemClassLoader.singleton().defaultSystemClassLoader) {
347348
/*
348349
* The run time's application class loader is the build time's image class
349350
* loader.

0 commit comments

Comments
 (0)