< prev index next >
src/java.base/share/classes/java/lang/invoke/Invokers.java
Print this page
rev 47249 : 8187826: Avoid using reflection to bootstrap NamedFunctions
Reviewed-by: TBD
*** 609,643 ****
private static NamedFunction createFunction(byte func) {
try {
switch (func) {
case NF_checkExactType:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("checkExactType", MethodHandle.class, MethodType.class));
case NF_checkGenericType:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("checkGenericType", MethodHandle.class, MethodType.class));
case NF_getCallSiteTarget:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("getCallSiteTarget", CallSite.class));
case NF_checkCustomized:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("checkCustomized", MethodHandle.class));
case NF_checkVarHandleGenericType:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class));
case NF_checkVarHandleExactType:
! return new NamedFunction(Invokers.class
! .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class));
default:
throw newInternalError("Unknown function: " + func);
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
}
private static class Lazy {
private static final MethodHandle MH_asSpreader;
static {
try {
--- 609,646 ----
private static NamedFunction createFunction(byte func) {
try {
switch (func) {
case NF_checkExactType:
! return getNamedFunction("checkExactType", MethodType.methodType(void.class, MethodHandle.class, MethodType.class));
case NF_checkGenericType:
! return getNamedFunction("checkGenericType", MethodType.methodType(MethodHandle.class, MethodHandle.class, MethodType.class));
case NF_getCallSiteTarget:
! return getNamedFunction("getCallSiteTarget", MethodType.methodType(MethodHandle.class, CallSite.class));
case NF_checkCustomized:
! return getNamedFunction("checkCustomized", MethodType.methodType(void.class, MethodHandle.class));
case NF_checkVarHandleGenericType:
! return getNamedFunction("checkVarHandleGenericType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
case NF_checkVarHandleExactType:
! return getNamedFunction("checkVarHandleExactType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
default:
throw newInternalError("Unknown function: " + func);
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
}
+ 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;
static {
try {
< prev index next >