Skip to content

Commit 2348c9c

Browse files
committed
Remove obsolete ClassForNameSupport workaround for libgraal building
1 parent 995b1f7 commit 2348c9c

File tree

3 files changed

+1
-31
lines changed

3 files changed

+1
-31
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,7 @@ 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',
16741675
'-H:-UseServiceLoaderFeature',
16751676
'-H:+AllowFoldMethods',
16761677
'-Dtruffle.TruffleRuntime=',

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ public boolean getAsBoolean() {
9696
}
9797
}
9898

99-
private ClassLoader libGraalLoader;
100-
101-
public void setLibGraalLoader(ClassLoader libGraalLoader) {
102-
this.libGraalLoader = libGraalLoader;
103-
}
104-
10599
@Platforms(Platform.HOSTED_ONLY.class)
106100
public static ClassForNameSupport currentLayer() {
107101
return LayeredImageSingletonSupport.singleton().lookup(ClassForNameSupport.class, false, true);
@@ -201,17 +195,6 @@ public void registerClass(ConfigurationCondition condition, Class<?> clazz, Clas
201195
ConditionalRuntimeValue<Object> existingEntry = knownClasses.get(name);
202196
Object currentValue = existingEntry == null ? null : existingEntry.getValueUnconditionally();
203197

204-
/* TODO: Remove workaround once GR-53985 is implemented */
205-
if (currentValue instanceof Class<?> currentClazz && clazz.getClassLoader() != currentClazz.getClassLoader()) {
206-
/* Ensure runtime lookup of LibGraalClassLoader classes */
207-
if (isLibGraalClass(currentClazz)) {
208-
return;
209-
}
210-
if (isLibGraalClass(clazz)) {
211-
currentValue = null;
212-
}
213-
}
214-
215198
if (currentValue == null || // never seen
216199
currentValue == NEGATIVE_QUERY ||
217200
currentValue == clazz) {
@@ -251,11 +234,6 @@ private void addKnownClass(String name, Consumer<EconomicMap<String, Conditional
251234
}
252235
}
253236

254-
@Platforms(HOSTED_ONLY.class)
255-
private boolean isLibGraalClass(Class<?> clazz) {
256-
return libGraalLoader != null && clazz.getClassLoader() == libGraalLoader;
257-
}
258-
259237
public static ConditionalRuntimeValue<Object> updateConditionalValue(ConditionalRuntimeValue<Object> existingConditionalValue, Object newValue,
260238
ConfigurationCondition additionalCondition) {
261239
if (existingConditionalValue == null) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassLoaderFeature.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@
2727
import java.util.concurrent.ConcurrentHashMap;
2828
import java.util.function.Function;
2929

30-
import org.graalvm.nativeimage.libgraal.hosted.LibGraalLoader;
31-
3230
import com.oracle.graal.pointsto.heap.ImageHeapConstant;
3331
import com.oracle.svm.core.BuildPhaseProvider;
3432
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
3533
import com.oracle.svm.core.feature.InternalFeature;
3634
import com.oracle.svm.core.fieldvaluetransformer.FieldValueTransformerWithAvailability;
3735
import com.oracle.svm.core.fieldvaluetransformer.ObjectToConstantFieldValueTransformer;
38-
import com.oracle.svm.core.hub.ClassForNameSupport;
3936
import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport;
4037
import com.oracle.svm.core.util.VMError;
41-
import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl;
4238
import com.oracle.svm.hosted.imagelayer.CrossLayerConstantRegistry;
4339
import com.oracle.svm.hosted.jdk.HostedClassLoaderPackageManagement;
4440
import com.oracle.svm.util.ReflectionUtil;
@@ -123,11 +119,6 @@ public void duringSetup(DuringSetupAccess access) {
123119

124120
var config = (FeatureImpl.DuringSetupAccessImpl) access;
125121
if (ImageLayerBuildingSupport.firstImageBuild()) {
126-
LibGraalLoader libGraalLoader = ((DuringSetupAccessImpl) access).imageClassLoader.classLoaderSupport.getLibGraalLoader();
127-
if (libGraalLoader != null) {
128-
ClassLoader libGraalClassLoader = (ClassLoader) libGraalLoader;
129-
ClassForNameSupport.currentLayer().setLibGraalLoader(libGraalClassLoader);
130-
}
131122
access.registerObjectReplacer(this::runtimeClassLoaderObjectReplacer);
132123
if (ImageLayerBuildingSupport.buildingInitialLayer()) {
133124
config.registerObjectReachableCallback(ClassLoader.class, (a1, classLoader, reason) -> {

0 commit comments

Comments
 (0)