This commit is contained in:
Looly 2023-04-23 00:50:28 +08:00
parent 548dcc6369
commit 1a82747d94

View File

@ -125,6 +125,8 @@ public class LambdaFactory {
final Class<?>[] paramTypes = funcMethod.getParameterTypes(); final Class<?>[] paramTypes = funcMethod.getParameterTypes();
// 函数对象将要实现的接口方法类型 // 函数对象将要实现的接口方法类型
final MethodType samMethodType = MethodType.methodType(funcMethod.getReturnType(), paramTypes); final MethodType samMethodType = MethodType.methodType(funcMethod.getReturnType(), paramTypes);
// 一个直接方法句柄(DirectMethodHandle), 描述调用时将被执行的具体实现方法
final MethodHandle implMethodHandle = LookupUtil.unreflect(executable);
if (ClassUtil.isSerializable(funcType)) { if (ClassUtil.isSerializable(funcType)) {
return LambdaMetafactory.altMetafactory( return LambdaMetafactory.altMetafactory(
@ -132,7 +134,7 @@ public class LambdaFactory {
invokeName, invokeName,
invokedType, invokedType,
samMethodType, samMethodType,
LookupUtil.unreflect(executable), implMethodHandle,
MethodTypeUtil.methodType(executable), MethodTypeUtil.methodType(executable),
LambdaMetafactory.FLAG_SERIALIZABLE LambdaMetafactory.FLAG_SERIALIZABLE
); );
@ -143,7 +145,7 @@ public class LambdaFactory {
invokeName, invokeName,
invokedType, invokedType,
samMethodType, samMethodType,
LookupUtil.unreflect(executable), implMethodHandle,
MethodTypeUtil.methodType(executable) MethodTypeUtil.methodType(executable)
); );
} }