JBR-7276 Keep dynamic call targets after bootstrap

This commit is contained in:
Nikita Gubarkov
2024-06-10 21:55:14 +02:00
parent 0e0ebdbe0d
commit 15f85125e0
2 changed files with 7 additions and 1 deletions

View File

@@ -114,8 +114,11 @@ public class JBRApi {
}
public static MethodHandle bindDynamic(Lookup caller, String name, MethodType type) {
if (VERBOSE) {
System.out.println("Binding call site " + caller.lookupClass().getName() + "#" + name + ": " + type);
}
if (!caller.hasFullPrivilegeAccess()) throw new Error("Caller lookup must have full privilege access"); // Authenticity check.
return dynamicCallTargets.remove(new DynamicCallTargetKey(caller.lookupClass(), name, type.descriptorString())).get().asType(type);
return dynamicCallTargets.get(new DynamicCallTargetKey(caller.lookupClass(), name, type.descriptorString())).get().asType(type);
}
/**

View File

@@ -173,6 +173,9 @@ class ProxyGenerator {
* Initialize method handles used by generated class via {@code invokedynamic}.
*/
void init() {
if (JBRApi.VERBOSE) {
System.out.println("Initializing proxy " + interFace.getName());
}
for (var t : accessContext.dynamicCallTargets) {
JBRApi.dynamicCallTargets.put(new JBRApi.DynamicCallTargetKey(
generatedProxy.lookupClass(), t.name(), t.descriptor()