Here you can find the source of getMethod(Class> c, String name, Class>[] args)
public static Method getMethod(Class<?> c, String name, Class<?>[] args)
//package com.java2s; import java.lang.reflect.Method; public class Main { /**// ww w. j a va 2 s . c om * Get method from class */ public static Method getMethod(Class<?> c, String name, Class<?>[] args) { Method m = null; while (true) { try { m = c.getDeclaredMethod(name, args); break; } catch (NoSuchMethodException e) { c = c.getSuperclass(); if (c == null) { return null; } } } m.setAccessible(true); return m; } }