The list of methods to do Reflection Method Parameter are organized into topic(s).
Method
getMethod(Class aClass, String methodName, Class[] parameterTypesToCheck, Class stopClass) get Method
while (aClass != null && aClass != stopClass) {
Method[] methods = aClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
if (method.getName().equals(methodName) && !Modifier.isAbstract(method.getModifiers())) {
Class[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length == 0 && parameterTypesToCheck == null) {
return method;
...
Method
getMethod(Class clazz, String methodName, Class>... parameterTypes) We cannot use
clazz.getMethod(String name, Class>...
Class currentClass = clazz;
while (currentClass != null) {
try {
Method method = currentClass.getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
return method;
} catch (NoSuchMethodException e) {
currentClass = currentClass.getSuperclass();
...
Method
getMethod(Class klass, String methodName, Class[] parameterTypes) Returns the method object identified by the specified class, name and paramater types.
try {
return klass.getDeclaredMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
if (klass.equals(Object.class))
return null;
return getMethod(klass.getSuperclass(), methodName, parameterTypes);