Here you can find the source of getMethod(Object target, String methodName)
private static Method getMethod(Object target, String methodName) throws Exception
//package com.java2s; // License as published by the Free Software Foundation; either import java.lang.reflect.Method; import java.util.Hashtable; import java.util.Map; public class Main { /** The classloader we should use to load javahelp classes */ private static ClassLoader classloader = null; private static Map METHOD_ARGS = new Hashtable(); private static Map METHODS = new Hashtable(); private static Method getMethod(Object target, String methodName) throws Exception { Method result = (Method) METHODS.get(methodName); if (result == null) { Object[] argTypes = (Object[]) METHOD_ARGS.get(methodName); result = getMethod(target, methodName, argTypes); METHODS.put(methodName, result); }/*from www. ja v a 2 s . c o m*/ return result; } private static Method getMethod(Object target, String methodName, Object[] argTypes) throws Exception { Class c = resolveClass(target); Class[] paramTypes = new Class[argTypes.length]; for (int i = 0; i < paramTypes.length; i++) paramTypes[i] = resolveClass(argTypes[i]); return c.getMethod(methodName, paramTypes); } private static Class resolveClass(Object obj) throws Exception { if (obj instanceof Class) return (Class) obj; else if (obj instanceof String) return classloader.loadClass((String) obj); else return obj.getClass(); } }