The list of methods to do Method Call are organized into topic(s).
T
invoke(@Nonnull Object source, @Nonnull String name, Object... args) invoke
Class<?>[] argTypes = new Class<?>[args.length];
for (int i = 0; i < args.length; i++) {
argTypes[i] = args[i] == null ? Object.class : args[i].getClass();
final Method method = findMethod(source.getClass(), name, argTypes);
if (method == null) {
throw new IllegalArgumentException(String.format("Unable to find '%s' with '%s' on '%s'!", name,
Arrays.toString(argTypes), source.getClass()));
...
void
invoke(Class extends Annotation> annotationClass, Object instance, Object[] parameters) Invokes the method of the object instance annotated with the specified annotation.
Class<?> instanceClass = instance.getClass();
Method[] methods = instanceClass.getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(annotationClass)) {
method.setAccessible(true);
try {
method.invoke(instance, parameters);
} catch (Exception e) {
...
Object
invoke(Class> clazz, String methodName, Object instance, Class>[] signature, Object... args) Reflectively invokes a method
boolean mod = false;
Method m = null;
try {
try {
m = clazz.getDeclaredMethod(methodName, signature == null ? NO_ARG_SIG : signature);
} catch (NoSuchMethodException e) {
m = clazz.getMethod(methodName, signature == null ? NO_ARG_SIG : signature);
if (!m.isAccessible()) {
m.setAccessible(true);
mod = true;
return m.invoke(instance, args);
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
if (mod && m != null) {
m.setAccessible(false);
Object
invoke(Class> cls, String methodName, Object... parameter) invoke
Class<?>[] parameterTypes = new Class<?>[parameter.length];
for (int i = 0; i < parameterTypes.length; i++) {
parameterTypes[i] = parameter[i].getClass();
try {
return getMethod(cls, methodName, parameterTypes).invoke(null, parameter);
} catch (Exception e) {
e.printStackTrace();
...