From 84a8fb517cbe6662ac5de25a8b67decc1a523d2d Mon Sep 17 00:00:00 2001 From: Loic Ottet Date: Mon, 30 Mar 2026 11:18:31 +0200 Subject: [PATCH] Register negative queries when runtime class loading is enabled --- .../oracle/svm/hosted/reflect/ReflectionDataBuilder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index 82b2d07c9d69..6e5e53d1a48d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java @@ -89,7 +89,6 @@ import com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberAccessibility; import com.oracle.svm.core.configure.ConditionalRuntimeValue; import com.oracle.svm.core.configure.RuntimeDynamicAccessMetadata; -import com.oracle.svm.shared.singletons.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.PredefinedClassesSupport; import com.oracle.svm.core.hub.RuntimeClassLoading; @@ -106,6 +105,7 @@ import com.oracle.svm.hosted.SVMHost; import com.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor; import com.oracle.svm.hosted.substitute.SubstitutionReflectivityFilter; +import com.oracle.svm.shared.singletons.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.shared.singletons.ImageSingletonLoader; import com.oracle.svm.shared.singletons.ImageSingletonWriter; import com.oracle.svm.shared.singletons.LayeredPersistFlags; @@ -401,7 +401,11 @@ public void registerClassLookup(AccessCondition condition, boolean preserved, St } private void registerClassLookupException(AccessCondition condition, String typeName, Throwable t, boolean preserved) { - if (RuntimeClassLoading.isSupported()) { + if (RuntimeClassLoading.isSupported() && t != null) { + /* + * Linkage errors don't need to be stored in the image when runtime class loading is + * enabled as they can be recreated when trying to load the class at run-time. + */ return; } if (layeredReflectionDataBuilder != null && layeredReflectionDataBuilder.isTypeNameRegistered(typeName)) {