Skip to content

Commit 46124c8

Browse files
committed
Explain why libgraal requires -H:+ClassForNameRespectsClassLoader
1 parent 4743a57 commit 46124c8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,13 +1671,23 @@ def prevent_build_path_in_libgraal():
16711671
] if mx.is_interactive() else []) + svm_experimental_options([
16721672
"-H:LibGraalClassLoader=jdk.graal.compiler.libgraal.loader.HostedLibGraalClassLoader",
16731673
"-Dlibgraal.module.path=${.}/../../../graalvm/libgraal.jar",
1674-
'-H:+ClassForNameRespectsClassLoader',
16751674
'-H:-UseServiceLoaderFeature',
16761675
'-H:+AllowFoldMethods',
16771676
'-Dtruffle.TruffleRuntime=',
16781677
'-H:+JNIEnhancedErrorCodes',
16791678
'-H:InitialCollectionPolicy=LibGraal',
16801679

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+
16811691
# Needed for initializing jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE.
16821692
# Remove after JDK-8346781.
16831693
'-Djdk.vm.ci.services.aot=true',

0 commit comments

Comments
 (0)