Here you can find the source of getMethodHandle(final Lookup lookup, final Class
public static <T> MethodHandle getMethodHandle(final Lookup lookup, final Class<T> receiver, final String methodName, final Class<?>... parameterTypes)
//package com.java2s; //License from project: Apache License import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Method; public class Main { public static <T> MethodHandle getMethodHandle(final Lookup lookup, final Class<T> receiver, final String methodName, final Class<?>... parameterTypes) { return unreflect(lookup, getMethod(receiver, methodName, parameterTypes)); }/*w w w. ja v a 2 s. c o m*/ public static <T> MethodHandle getMethodHandle(final Class<T> receiver, final String methodName, final Class<?>... parameterTypes) { return unreflect(MethodHandles.publicLookup(), getMethod(receiver, methodName, parameterTypes)); } public static MethodHandle unreflect(final Method m) { return unreflect(MethodHandles.publicLookup(), m); } public static MethodHandle unreflect(final Lookup lookup, final Method m) { try { return lookup.unreflect(m); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } } public static MethodHandle unreflect(final Lookup lookup, final Class<?> klass, final String methodName, final Class<?>... args) { try { return unreflect(lookup, klass.getDeclaredMethod(methodName, args)); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException(e); } } public static <T> Method getMethod(final Class<T> receiver, final String methodName, final Class<?>... parameterTypes) { try { return receiver.getMethod(methodName, parameterTypes); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException(e); } } public static <T> Method getDeclaredMethod(final Class<T> receiver, final String methodName, final Class<?>... parameterTypes) { try { return receiver.getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException(e); } } }