我未能为 Java 中的方法查找创建 MethodType。下面是我的代码。在这段代码中,我想为 sample::gwd 方法创建一个 MethodType,然后通过 lookup().findStatic 检索对该函数的引用。很明显,我无法获得方法参考,因为 MethodType 构造错误。
//I want to construct MethodType for Sample:gwd method, but do not know how to handle array parameters for 'gwd' method
MethodType mt = MethodType.methodType(Object.class, MethodHandle.class, MethodHandle.class, MethodHandle.class);
MethodHandle myMH = MethodHandles.lookup().findStatic(Sample.Class, "gwd", mt);
public class Sample
{
public static Object gwd(MethodHandle methodhandle, MethodHandle methodhandle1, MethodHandle methodhandle2, Object aobj[])
throws Throwable
{ .......... }
}
有谁能帮忙吗?谢谢