Java Reflection Method Parameter getMethod(Class clazz, String methodName, Class... parameterTypes)

Here you can find the source of getMethod(Class clazz, String methodName, Class... parameterTypes)

Description

get Method

License

Apache License

Declaration

public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) 

Method Source Code

//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;
    }
}

Related

  1. getMethod(Class type, String methodName, Class... parameterTypes)
  2. getMethod(Class type, String name, Class[] parameterTypes)
  3. getMethod(Class c, String methodName, Class... parameterTypes)
  4. getMethod(Class clazz, String functionName, Class[] parameterTypes)
  5. getMethod(Class clazz, String method, Class... parameterTypes)
  6. getMethod(Class clazz, String methodName, Class... parameterTypes)
  7. getMethod(Class clazz, String methodName, Class... parameterTypes)
  8. getMethod(Class clazz, String name, Class... parameterTypes)
  9. getMethod(Class clazz, String name, Class... parameterTypes)