Here you can find the source of getMethod(Class clazz, String name, Class[] parameters)
private static Method getMethod(Class clazz, String name, Class[] parameters) throws NoSuchMethodException
//package com.java2s; /*//w w w . j a v a2 s . c om * Copyright (C) 2013, Peter Decsi. * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ import java.lang.reflect.Method; public class Main { private static Method getMethod(Class clazz, String name, Class[] parameters) throws NoSuchMethodException { for (Method method : clazz.getMethods()) { if (name.equals(method.getName()) && isAssignable(method.getParameterTypes(), parameters)) return method; } return clazz.getMethod(name, parameters); } private static boolean isAssignable(Class[] constructor, Class[] parameters) { int size = parameters.length; if (size != constructor.length) return false; for (int i = 0; i < size; i++) if (!constructor[i].isAssignableFrom(parameters[i])) return false; return true; } }