MethodHandles

来源:互联网 发布:mac 十六进制编辑器 编辑:程序博客网 时间:2024/05/01 16:21

==

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;}}


==

0 0