List of utility methods to do Reflection Method Parameter
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 aClass, String name, Class... parameters) get Method return findMethod(aClass.getMethods(), name, parameters);
|
Method | getMethod(Class cl, String methodName, String obfName, Class... parameterTypes) get Method Method m = null; try { try { m = cl.getDeclaredMethod(methodName, parameterTypes); } catch (Exception e) { if (m == null) m = cl.getDeclaredMethod(obfName, parameterTypes); ... |
Method | getMethod(Class clazz, String methodName, Class>... parameterTypes) We cannot use clazz.getMethod(String name, Class>...
|
Method | getMethod(Class clazz, String methodName, Class>... parameterTypes) Search the method in the class and it's parent classes. return _getMethod(null, clazz, methodName, parameterTypes);
|
Method | getMethod(Class clazz, String name, Class... parameterTypes) Util method to get a method, ignoring checked exceptions Method method = null; try { method = clazz.getMethod(name, parameterTypes); } catch (Exception e) { e.printStackTrace(); return method; |
Method | getMethod(Class clazz, String name, Class[] parameters) get Method for (Method method : clazz.getMethods()) { if (name.equals(method.getName()) && isAssignable(method.getParameterTypes(), parameters)) return method; return clazz.getMethod(name, parameters); |
Method | getMethod(Class declaringClass, String name, Class... parameterTypes) Convenience for getting a method from a class. try { return declaringClass.getMethod(name, parameterTypes); } catch (Exception ex) { throw new RuntimeException(ex); |
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); |
Method | getMethod(Class target, String methodName, Class[] parameterTypes) get Method return findMethod(target.getClass().getMethods(), methodName, parameterTypes);
|