From 6b5e92123ac46367257fb4d6d3e02f63e5787deb Mon Sep 17 00:00:00 2001 From: Christian Wimmer Date: Tue, 25 Jun 2024 10:17:24 -0700 Subject: [PATCH] Execute bootstrap methods for Proxy at image build time (cherry picked from commit a8df9a20d3e24688f004e79794629c3b258894b3) --- .../core/bootstrap/BootstrapMethodConfiguration.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java index 2b02673af265..5dac245c3e14 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java @@ -33,13 +33,13 @@ import java.lang.invoke.TypeDescriptor; import java.lang.reflect.Executable; import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.lang.runtime.ObjectMethods; import java.lang.runtime.SwitchBootstraps; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.RuntimeReflection; @@ -47,6 +47,7 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.util.ReflectionUtil; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.vm.ci.meta.ResolvedJavaMethod; /** @@ -161,7 +162,14 @@ public boolean isIndyAllowedAtBuildTime(Executable method) { * Check if the provided method is allowed to be executed at build time. */ public boolean isCondyAllowedAtBuildTime(Executable method) { - return method != null && condyBuildTimeAllowList.contains(method); + return method != null && (condyBuildTimeAllowList.contains(method) || isProxyCondy(method)); + } + + /** + * Every {@link Proxy} class has its own bootstrap method that is used for a constant dynamic. + */ + private static boolean isProxyCondy(Executable method) { + return Proxy.isProxyClass(method.getDeclaringClass()) && method.getName().equals("$getMethod"); } /**