Here you can find the source of getMethodInternal(Class> clazz, String methodName)
private static Method getMethodInternal(Class<?> clazz, String methodName) throws Exception
//package com.java2s; /**//from w w w. j a va2 s .com * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights * reserved. This program and the accompanying materials are made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal - Initial API and * implementation </copyright> $Id: FieldUtil.java,v 1.15 2008/06/02 07:15:29 mtaal Exp $ */ import java.lang.reflect.Method; import java.util.Hashtable; public class Main { /** The hashtable caches clazz field name combinations */ private static final Hashtable<String, Object> fieldMethodCache = new Hashtable<String, Object>(); /** Does the actual search for the method */ private static Method getMethodInternal(Class<?> clazz, String methodName) throws Exception { if (clazz == null) { return null; } final Method method = (Method) fieldMethodCache.get(clazz.getName() + "." + methodName); if (method != null) { return method; } final Method[] methods = clazz.getDeclaredMethods(); for (Method element : methods) { if (element.getName().compareToIgnoreCase(methodName) == 0) { element.setAccessible(true); fieldMethodCache.put(clazz.getName() + "." + methodName, element); return element; } } return getMethodInternal(clazz.getSuperclass(), methodName); } }