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(Class cls, String methodName, Class[] params)
get Method
return cls.getMethod(methodName, params);
MethodgetMethod(Class clz, String methodName, Class expectedTypes[])
get Method
Method method = null;
try {
    method = clz.getMethod(methodName, expectedTypes);
} catch (NoSuchMethodException e) {
    Method methods[] = clz.getMethods();
    for (int i = 0; i < methods.length; i++) {
        Method _method = methods[i];
        if (!_method.getName().equals(methodName)
...
MethodgetMethod(Class klazz, String[] methodNames, int argCount)
get Method
if (klazz == null) {
    return null;
for (String method : methodNames) {
    try {
        for (Method m : getAllMethods(klazz)) {
            if (m.getName().equals(method)
                    && (argCount == -1 || m.getParameterTypes().length == argCount)) {
...
MethodgetMethod(Class objClass, String methodName, Class argClass)
get Method
Class argClasses[] = (argClass == null) ? null : new Class[] { argClass };
return getMethod(objClass, methodName, argClasses);
MethodgetMethod(Class serviceClass, String methodName, Class... mapClass)
get Method
return null;
MethodgetMethod(Class targetClass, String methodName, Class[] paramTypes)
get Method
Method method = null;
NoSuchMethodException nsmex = null;
for (Class clazz = targetClass; clazz != null; clazz = clazz.getSuperclass())
    try {
        method = clazz.getDeclaredMethod(methodName, paramTypes);
        break;
    } catch (NoSuchMethodException ex) {
        if (nsmex == null)
...
MethodgetMethod(Class targetClass, String name, Class paramClass)
Get the method with the given name and with a single argument of the type specified by paramClass.
if (paramClass == null) {
    return getMethod(targetClass, name, EMPTY_CLASS_ARRAY);
} else {
    Class[] paramClasses = new Class[1];
    paramClasses[0] = paramClass;
    return getMethod(targetClass, name, paramClasses);
MethodgetMethod(Class targetClass, String targetMethodName)
get Method
return getMethod(targetClass, targetMethodName, null);
MethodgetMethod(Class theClass, String propertyName)
get Method
Method[] methods = theClass.getDeclaredMethods();
Method.setAccessible(methods, true);
for (Method method : methods) {
    if (method.getParameterTypes().length != 0) {
        continue;
    if (method.isBridge()) {
        continue;
...
MethodgetMethod(Class type, String name, Class[] paramTypes)
Returns Method object for specified method, which should always exist.
try {
    return type.getMethod(name, paramTypes);
} catch (NoSuchMethodException e) {
    throw new AssertionError(e);