Java Utililty Methods Reflection Method Name

List of utility methods to do Reflection Method Name

Description

The list of methods to do Reflection Method Name are organized into topic(s).

Method

MethodgetMethod(final String methodName, final Class objClass, final Class[] paramClasses)
get Method
if (objClass == Object.class) {
    return objClass.getDeclaredMethod(methodName, paramClasses);
try {
    return objClass.getDeclaredMethod(methodName, paramClasses);
} catch (final NoSuchMethodException e) {
    return getMethod(methodName, objClass.getSuperclass(), paramClasses);
MethodgetMethod(int requireMod, int bannedMod, Class clazz, String methodName, Class... params)
Search for the first publically and privately defined method of the given name and parameter count.
for (Method method : clazz.getDeclaredMethods()) {
    if ((method.getModifiers() & requireMod) == requireMod && (method.getModifiers() & bannedMod) == 0
            && (methodName == null || method.getName().equals(methodName))
            && Arrays.equals(method.getParameterTypes(), params)) {
        method.setAccessible(true);
        return method;
if (clazz.getSuperclass() != null) {
    return getMethod(requireMod, bannedMod, clazz.getSuperclass(), methodName, params);
throw new IllegalStateException(
        String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
MethodgetMethod(Method[] methods, String name)
get Method
Method method = null;
for (int i = 0; i < methods.length; i++) {
    method = methods[i];
    if (!Modifier.isPublic(method.getModifiers()))
        continue;
    if (method.getName().equals(name))
        return method;
return null;
MethodgetMethod(Method[] methods, String name, Class[] params)
Returns the method matching the name.
Method method = null;
loop: for (int i = 0; i < methods.length; i++) {
    method = methods[i];
    if (!Modifier.isPublic(method.getModifiers()))
        continue;
    if (!Modifier.isPublic(method.getDeclaringClass().getModifiers()))
        continue;
    if (!method.getName().equals(name))
...
String[]getMethod(String className)
get Method
Class<?> classz = Class.forName(className);
Method[] methods = classz.getMethods();
Set<String> set = new HashSet<>();
for (Method f : methods) {
    set.add(f.getName());
return set.toArray(new String[set.size()]);
MethodgetMethod(String className, String functionName, Class[] paramTypes)
get Method
Method method = null;
Class actionClassObj;
actionClassObj = Class.forName(className);
method = actionClassObj.getMethod(functionName, paramTypes);
return method;
MethodgetMethod(String className, String functionName, Class[] paramTypes)
get Method
Method method = null;
Class actionClassObj;
actionClassObj = Class.forName(className);
method = actionClassObj.getMethod(functionName, paramTypes);
return method;
MethodgetMethod(String className, String methodName, Class[] params)
get Method
Class<?> clazz = Class.forName(className);
return clazz.getMethod(methodName, params);
MethodgetMethod(String methodName, Class clazz)
get Method
Method method = getDeclaredMethod(methodName, clazz);
if (method == null) {
    Class<?> parent = clazz.getSuperclass();
    while (parent != null) {
        method = getDeclaredMethod(methodName, parent);
        if (method != null)
            break;
        parent = parent.getSuperclass();
...
MethodgetMethod(String methodName, Class clazz, Class... args)
get Method
Method method;
try {
    method = clazz.getMethod(methodName, args);
} catch (NoSuchMethodException e1) {
    method = null;
return method;