Here you can find the source of getMethod(Class> target, String methodName, Class>... parameterTypes)
public static Method getMethod(Class<?> target, String methodName, Class<?>... parameterTypes)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { public static Method getMethod(Class<?> target, String methodName, Class<?>... parameterTypes) { try {/*from www .java2s . co m*/ Method m = target.getDeclaredMethod(methodName, parameterTypes); if (m != null) { return m; } else { return target.equals(Object.class) ? null : getMethod(target.getSuperclass(), methodName, parameterTypes); } } catch (Exception e) { return target.equals(Object.class) ? null : getMethod(target.getSuperclass(), methodName, parameterTypes); } } }