Here you can find the source of getMethod(Class> clazz, String methodName, Class>... parameterTypes)
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; public class Main { private final static Map<String, Method> methodMap = new HashMap<>(); public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) { String key = clazz + methodName; Method method = methodMap.get(key); if (method == null) { synchronized (clazz) { if (method == null) { try { method = clazz.getDeclaredMethod(methodName, parameterTypes); methodMap.put(key, method); } catch (Exception e) { e.printStackTrace(); }/*w ww. jav a2 s . co m*/ } } } return method; } }