public abstract class ReflectionUtils
extends java.lang.Object
ReflectionUtils| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectionUtils.InvocationCheckedExceptionWrapper
Runtime exception wrapper for checked exceptions thrown by invoked
methods.
|
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Exception |
getInvocationException(java.lang.Exception exception)
Analyze the given exception and, if it's of type
ReflectionUtils.InvocationCheckedExceptionWrapper then will return the actual
cause, otherwise return the original exception given. |
static void |
handleInvocationTargetException(java.lang.reflect.InvocationTargetException ex)
Handle the given invocation target exception.
|
static java.lang.Object |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object target)
Invoke the specified
Method against the supplied target object
with no arguments. |
static java.lang.Object |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object target,
java.lang.Object[] args)
Invoke the specified
Method against the supplied target object
with the supplied arguments. |
public static java.lang.Object invokeMethod(java.lang.reflect.Method method,
java.lang.Object target)
Method against the supplied target object
with no arguments. The target object can be null when
invoking a static Method.
This method is identical to
ReflectionUtils.invokeMethod(Method, Object)
except that if the target method throws a checked exception, the method
will throw a InvocationCheckedException.
Thrown exceptions are handled via a call to
#handleReflectionException.
method - the method to invoketarget - the target object to invoke the method oninvokeMethod(java.lang.reflect.Method, Object, Object[])public static java.lang.Object invokeMethod(java.lang.reflect.Method method,
java.lang.Object target,
java.lang.Object[] args)
Method against the supplied target object
with the supplied arguments. The target object can be null
when invoking a static Method.
This method is identical to
ReflectionUtils.invokeMethod(Method, Object)
except that if the target method throws a checked exception, the method
will throw a InvocationCheckedException.
Thrown exceptions are handled via a call to
#handleReflectionException.
method - the method to invoketarget - the target object to invoke the method onargs - the invocation arguments (may be null)invokeMethod(java.lang.reflect.Method, Object, Object[])public static void handleInvocationTargetException(java.lang.reflect.InvocationTargetException ex)
Throws the underlying RuntimeException or Error in case of such a root
cause. Throws an InvocationCheckedException else (the main difference
from
ReflectionUtils.handleInvocationTargetException(InvocationTargetException).
ex - the invocation target exception to handlepublic static java.lang.Exception getInvocationException(java.lang.Exception exception)
ReflectionUtils.InvocationCheckedExceptionWrapper then will return the actual
cause, otherwise return the original exception given.exception - invocation exception