void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MethodHandles.lookup() .findStatic(MainActivity.class, "add", MethodType.methodType(int.class, int.class, int.class)) .invoke(2, 3); } static int add(int a, int b) { BiFunction<Integer, Integer, Integer> f = new BiFunction<Integer, Integer, Integer>() { @Override public Integer apply(Integer integer, Integer integer2) { return add0(a, b); } }; return f.apply(a, b); } @CalledByInvokeCustom(invokeMethodHandle = @LinkerMethodHandle(kind = MethodHandleKind.INVOKE_STATIC, enclosingType = MainActivity.class, name = "linkerMethod", argumentTypes = {MethodHandles.Lookup.class, String.class, MethodType.class}), name = "add0", returnType = Integer.class, argumentTypes = {Integer.class, Integer.class}) static Integer add0(Integer a, Integer b) { return a + b; } private static CallSite linkerMethod(MethodHandles.Lookup caller, String name, MethodType methodType) throws NoSuchMethodException, IllegalAccessException { return new ConstantCallSite(caller.findStatic(caller.lookupClass(), name, methodType)); } }