Skip to content

Commit

Permalink
Execute bootstrap methods for Proxy at image build time
Browse files Browse the repository at this point in the history
(cherry picked from commit a8df9a2)
  • Loading branch information
Christian Wimmer authored and zakkak committed Jul 1, 2024
1 parent c7c6279 commit 6b5e921
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@
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;

import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
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;

/**
Expand Down Expand Up @@ -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");
}

/**
Expand Down

0 comments on commit 6b5e921

Please sign in to comment.