mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8187826: Avoid using reflection to bootstrap NamedFunctions
Reviewed-by: psandoz
This commit is contained in:
parent
2e46c1508a
commit
0355224df8
3 changed files with 48 additions and 36 deletions
|
@ -611,23 +611,17 @@ class Invokers {
|
|||
try {
|
||||
switch (func) {
|
||||
case NF_checkExactType:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("checkExactType", MethodHandle.class, MethodType.class));
|
||||
return getNamedFunction("checkExactType", MethodType.methodType(void.class, MethodHandle.class, MethodType.class));
|
||||
case NF_checkGenericType:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("checkGenericType", MethodHandle.class, MethodType.class));
|
||||
return getNamedFunction("checkGenericType", MethodType.methodType(MethodHandle.class, MethodHandle.class, MethodType.class));
|
||||
case NF_getCallSiteTarget:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("getCallSiteTarget", CallSite.class));
|
||||
return getNamedFunction("getCallSiteTarget", MethodType.methodType(MethodHandle.class, CallSite.class));
|
||||
case NF_checkCustomized:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("checkCustomized", MethodHandle.class));
|
||||
return getNamedFunction("checkCustomized", MethodType.methodType(void.class, MethodHandle.class));
|
||||
case NF_checkVarHandleGenericType:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class));
|
||||
return getNamedFunction("checkVarHandleGenericType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
|
||||
case NF_checkVarHandleExactType:
|
||||
return new NamedFunction(Invokers.class
|
||||
.getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class));
|
||||
return getNamedFunction("checkVarHandleExactType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
|
||||
default:
|
||||
throw newInternalError("Unknown function: " + func);
|
||||
}
|
||||
|
@ -636,6 +630,15 @@ class Invokers {
|
|||
}
|
||||
}
|
||||
|
||||
private static NamedFunction getNamedFunction(String name, MethodType type)
|
||||
throws ReflectiveOperationException
|
||||
{
|
||||
MemberName member = new MemberName(Invokers.class, name, type, REF_invokeStatic);
|
||||
return new NamedFunction(
|
||||
MemberName.getFactory()
|
||||
.resolveOrFail(REF_invokeStatic, member, Invokers.class, NoSuchMethodException.class));
|
||||
}
|
||||
|
||||
private static class Lazy {
|
||||
private static final MethodHandle MH_asSpreader;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue