There are 2 ways i have tried to obtain the MethodHandle to a given function.
Method 1
Method m = MyClass.class.getMethod("myMethod", String.class, Map.class);
MethodHandle mh = MethodHandles.lookup().unreflect(m);
Method 2
MethodType type = MethodType.methodType(void.class, String.class, Map.class);
MethodHandle mh = MethodHandles.lookup().findVirtual(MyClass.class, "myMethod", type);
What is the difference between both of them?
Aucun commentaire:
Enregistrer un commentaire