@@ -1671,13 +1671,23 @@ def prevent_build_path_in_libgraal():
1671
1671
] if mx .is_interactive () else []) + svm_experimental_options ([
1672
1672
"-H:LibGraalClassLoader=jdk.graal.compiler.libgraal.loader.HostedLibGraalClassLoader" ,
1673
1673
"-Dlibgraal.module.path=${.}/../../../graalvm/libgraal.jar" ,
1674
- '-H:+ClassForNameRespectsClassLoader' ,
1675
1674
'-H:-UseServiceLoaderFeature' ,
1676
1675
'-H:+AllowFoldMethods' ,
1677
1676
'-Dtruffle.TruffleRuntime=' ,
1678
1677
'-H:+JNIEnhancedErrorCodes' ,
1679
1678
'-H:InitialCollectionPolicy=LibGraal' ,
1680
1679
1680
+ # A libgraal image contains classes with the same FQN loaded by different classloaders.
1681
+ # I.e. the SVM runtime depends on
1682
+ # - jdk.vm.ci.* classes loaded by the bootstrap classloader
1683
+ # - jdk.graal.compiler.options.* classes loaded by the platform classloader
1684
+ # - org.graalvm.collections.* classes loaded by the app classloader
1685
+ # But potentially different versions of those classes are also loaded by the
1686
+ # LibGraalClassLoader as part of the classes that libgraal consist of.
1687
+ # Thus, we cannot use the naive default ClassForName implementation that only
1688
+ # works if there are no two different classes in the image with the same FQN.
1689
+ '-H:+ClassForNameRespectsClassLoader' ,
1690
+
1681
1691
# Needed for initializing jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE.
1682
1692
# Remove after JDK-8346781.
1683
1693
'-Djdk.vm.ci.services.aot=true' ,
0 commit comments