Java Reflection Method Name getMethod(Class clazz, String name)

Here you can find the source of getMethod(Class clazz, String name)

Description

get Method

License

Apache License

Declaration

private static Method getMethod(Class<?> clazz, String name) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    private static Method getMethod(Class<?> clazz, String name) {
        if (clazz == null) {
            throw new RuntimeException("Could not find method " + name);
        }/*from ww  w . java2 s . co m*/
        try {
            Method method = clazz.getDeclaredMethod(name);
            method.setAccessible(true);
            return method;
        } catch (NoSuchMethodException e) {
            return getMethod(clazz.getSuperclass(), name);
        }
    }
}

Related

  1. getMethod(Class clazz, String methodName, Class... params)
  2. getMethod(Class clazz, String methodName, final Class[] classes)
  3. getMethod(Class clazz, String methodName, int numParams)
  4. getMethod(Class clazz, String name)
  5. getMethod(Class clazz, String name)
  6. getMethod(Class clazz, String name)
  7. getMethod(Class clazz, String name)
  8. getMethod(Class clazz, String name, boolean declared, Class... args)
  9. getMethod(Class clazz, String name, Class... args)