Here you can find the source of invoke(Object targetObject, String method, Class>[] paramTypes, Object[] paramValues)
public static Object invoke(Object targetObject, String method, Class<?>[] paramTypes, Object[] paramValues) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.concurrent.ConcurrentHashMap; public class Main { private static final ConcurrentHashMap<String, Method> METHOD_CACHE = new ConcurrentHashMap<String, Method>(); public static Object invoke(Object targetObject, String method, Class<?>[] paramTypes, Object[] paramValues) throws Exception { String methodKey = getMethodKey(targetObject.getClass(), method, paramTypes); Method methodObject = METHOD_CACHE.get(methodKey); if (methodObject == null) { methodObject = targetObject.getClass().getMethod(method, paramTypes); if (methodObject != null) { METHOD_CACHE.put(methodKey, methodObject); }/*from w w w . ja v a2 s . c om*/ } return methodObject.invoke(targetObject, paramValues); } private static String getMethodKey(Class<?> clazz, String method, Class<?>[] paramTypes) { StringBuilder sb = new StringBuilder(clazz.getName()).append(".").append(method); if (paramTypes != null && paramTypes.length > 0) { for (Class<?> c : paramTypes) { sb.append("-").append(c.getName()); } } return sb.toString(); } }