Here you can find the source of getMethod(String methodName, Class>[] paramTypes, Class> targetClass)
public static Method getMethod(String methodName, Class<?>[] paramTypes, Class<?> targetClass)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static Method getMethod(String methodName, Class<?>[] paramTypes, Class<?> targetClass) { try {/*w w w . ja v a2s. c o m*/ return targetClass.getDeclaredMethod(methodName, paramTypes); } catch (Exception e) { Class<?> superClass = targetClass.getSuperclass(); if (superClass == null || superClass.equals(Object.class)) { return null; } return getMethod(methodName, paramTypes, superClass); } } }