Here you can find the source of getMethod(Class> clazz, String name)
private static Method getMethod(Class<?> clazz, String name)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { private static Method getMethod(Class<?> clazz, String name) { if (clazz == null) { throw new RuntimeException("Could not find method " + name); }/*from ww w . java2 s . co m*/ try { Method method = clazz.getDeclaredMethod(name); method.setAccessible(true); return method; } catch (NoSuchMethodException e) { return getMethod(clazz.getSuperclass(), name); } } }