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(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types)
get Method
Method res = null;
try {
    res = clazz.getDeclaredMethod(methodName, types);
    if (res != null && (Modifier.isPrivate(res.getModifiers()) || Modifier.isFinal(res.getModifiers())
            || Modifier.isStatic(res.getModifiers()))) {
        res = null;
} catch (NoSuchMethodException e) {
...
MethodgetMethod(Class c, String methodName)
get Method
Method result = null;
Method[] methods = c.getMethods();
for (Method m : methods) {
    String name = m.getName();
    if (name.equalsIgnoreCase(methodName)) {
        result = m;
        break;
return result;
MethodgetMethod(Class c, String name)
get Method
for (Method method : c.getDeclaredMethods()) {
    if (method.getName().equals(name)) {
        return method;
throw new IllegalArgumentException("Unknown method '" + name + "' on " + c);
MethodgetMethod(Class cl, String methodName, Class[] paramTypes)
get Method
Method m = null;
try {
    m = cl.getMethod(methodName, paramTypes);
} catch (NoSuchMethodException ex) {
    return null;
Class dclass = m.getDeclaringClass();
if (Modifier.isPublic(dclass.getModifiers())) {
...
MethodgetMethod(Class clazz, String methodName)
get Method
Method[] methods = clazz.getMethods();
return findUniqueMethodByName(methods, methodName);
java.lang.reflect.MethodgetMethod(Class clazz, String methodName, Class argType)
get Method
try {
    return clazz.getMethod(methodName, new Class[] { argType });
} catch (Throwable ex) {
final java.lang.reflect.Method[] ms = clazz.getMethods();
for (java.lang.reflect.Method m : ms) {
    if (!m.getName().equals(methodName))
        continue;
...
MethodgetMethod(Class clazz, String methodName, Class[] classes)
get Method
try {
    return clazz.getDeclaredMethod(methodName, classes);
} catch (NoSuchMethodException e) {
    return null;
MethodgetMethod(Class clazz, String methodName, Class[] params)
Determines the method with the specified signature via reflection look-up.
try {
    return clazz.getMethod(methodName, params);
} catch (Exception ignored) {
return null;
MethodgetMethod(Class clazz, String name)
get Method
Method[] methods = clazz.getMethods();
if (methods == null) {
    return null;
for (int i = 0; i < methods.length; i++) {
    Method method = methods[i];
    if (name.equals(method.getName())) {
        return method;
...
MethodgetMethod(Class clazz, String name, Class... args)
get Method
Method method = null;
try {
    method = clazz.getMethod(name, args);
} catch (NoSuchMethodException e) {
    try {
        method = clazz.getDeclaredMethod(name, args);
    } catch (NoSuchMethodException e2) {
return method;