Here you can find the source of getMethodByName(Object target, String methodName)
private static Method getMethodByName(Object target, String methodName)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { private static Method getMethodByName(Object target, String methodName) { Class<?> classToSearch = target.getClass(); Method method = null;/*from w ww . j a v a2s. c om*/ do { try { method = classToSearch.getDeclaredMethod(methodName); } catch (SecurityException | NoSuchMethodException exception) { classToSearch = classToSearch.getSuperclass(); } } while (method == null && classToSearch != null); return method; } }