Slide 47
Slide 47 text
Panama tire parti des MethodHandle pour appeler le code natif
Dès Java 8, à la place de l’API de reflection
Étape 2: Appel de méthode sans paramètre
A method handle is a typed, directly executable reference to an underlying method,
constructor, field, or similar low-level operation, with optional transformations of arguments
or return values. These transformations are quite general, and include such patterns as
conversion, insertion, deletion, and substitution.
JDK 1.7
MethodHandle mh = MethodHandles.lookup().findVirtual(
TargetClass.class,
"targetMetbod",
MethodType.methodType(void.class, String.class)
);
mh.invokeExact(targetInstance, "...");