Java Reflection Method Name getMethod(Class theClass, String methodName, Class[] paramTypes)

Here you can find the source of getMethod(Class theClass, String methodName, Class[] paramTypes)

Description

get Method

License

Apache License

Declaration

public static Method getMethod(Class<?> theClass, String methodName, Class<?>[] paramTypes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(Class<?> theClass, String methodName, Class<?>[] paramTypes) {
        Method method = null;/*w  w w.  j  a  v  a2  s . c  o m*/

        try {
            method = theClass.getDeclaredMethod(methodName, paramTypes);
            method.setAccessible(true);
        } catch (NoSuchMethodException | SecurityException e) {
        }

        if (method == null) {
            Class<?> superClasss = theClass.getSuperclass();

            if (superClasss != null)
                method = getMethod(superClasss, methodName, paramTypes);
        }

        return method;
    }
}

Related

  1. getMethod(Class clz, String name)
  2. getMethod(Class klass, String methodName)
  3. getMethod(Class klass, String methodName, Class requestClass)
  4. getMethod(Class klass, String methodName, Class... paramTypes)
  5. getMethod(Class klass, String name, String name2)
  6. getMethod(Class c, String name, Class... argTypes)
  7. getMethod(Class clazz, String methodName)
  8. getMethod(Class clazz, String methodName, Class[] calledTypes)
  9. getMethod(Class type, String methodName, Class... params)