The list of methods to do Reflection Method Invoke are organized into topic(s).
Object
invoke(Method m, Object o, Object[] args) Reflection helper methods.
try {
return m.invoke(o, args);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
} catch (IllegalArgumentException iae) {
throw new RuntimeException(iae);
Object
invoke(Method m, Object o, String msg, Object... parameters) invoke
try {
return m.invoke(o, parameters);
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof Error) {
throw (Error) t;
throw new ReflectionException((Exception) t, "Exception thrown while invoking " + msg);
...
long
invoke(Method method) invoke
try {
Object value = (method == null) ? null : method.invoke(osBean);
return (value == null) ? VALUE_UNAVAILABLE : ((Number) value).longValue();
} catch (Throwable t) {
return VALUE_UNAVAILABLE;
Object
invoke(Method method, Object data, Object... arguments) Common method to invoke Method with reflection
Object value;
try {
value = method.invoke(data, arguments);
} catch (IllegalAccessException ex) {
throw new IOException(ex);
} catch (IllegalArgumentException ex) {
throw new IOException(ex);
} catch (InvocationTargetException ex) {
...
T
invoke(Method method, Object instance, Object... parameters) Invoke the method.
if (!method.isAccessible())
method.setAccessible(true);
if (Modifier.isStatic(method.getModifiers()) && instance != null)
instance = null;
try {
return (T) method.invoke(instance, parameters);
} catch (IllegalAccessException e) {
throw new RuntimeException("Failed to invoke method", e);
...
Object
invoke(Method method, Object it, Object... args) Invokes the specified method on the given it Object with the given arguments.
try {
method.setAccessible(true);
return method.invoke(it, args);
} catch (IllegalArgumentException e) {
throw new Error(
String.format("Method '%s' rejected arguments(%s)", method.getName(), argumentList(args)), e);
} catch (IllegalAccessException e) {
throw new Error("Method became inaccessible.", e);
...
Object
invoke(Method method, Object obj, Object... args) invoke
try {
return method.invoke(obj, args);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Can't invoke method " + method.getName(), e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Can't invoke method " + method.getName(), e);