Here you can find the source of getMethod(Class> clazz, String methodName, final Class[] classes)
public static Method getMethod(Class<?> clazz, String methodName, final Class[] classes) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { public static Method getMethod(Class<?> clazz, String methodName, final Class[] classes) throws Exception { Method method = null;//from w w w .j a va2 s.com try { method = clazz.getDeclaredMethod(methodName, classes); } catch (NoSuchMethodException e) { try { method = clazz.getMethod(methodName, classes); } catch (NoSuchMethodException ex) { if (clazz.getSuperclass() == null) { return method; } else { method = getMethod(clazz.getSuperclass(), methodName, classes); } } } return method; } }