==
public class MethodHandlesTest {
public static void main(String[] args) throws Throwable {
MethodHandles.Lookup lp = MethodHandles.lookup();
MethodHandle mhl = lp.findVirtual(Person.class, "work",
MethodType.methodType(int.class, int.class));
Person p = new Person();
int i = (int) mhl.invoke(p, 1);
System.out.println(i);
}
}
class Person {
public int work(int i) {
return i + 1;
}
}
==