|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.ReflectionUtils
public abstract class ReflectionUtils
Simple utility class for handling reflection exceptions. Only intended for internal use.
Constructor Summary | |
---|---|
ReflectionUtils()
|
Method Summary | |
---|---|
static Method |
findMethod(Class type,
String name,
Class[] paramTypes)
Attempt to find a Method on the supplied type with the supplied name
and parameter types. |
static void |
handleInvocationTargetException(InvocationTargetException ex)
Handle the given invocation target exception. |
static void |
handleReflectionException(Exception ex)
Handle the given reflection exception. |
static Object |
invokeMethod(Method method,
Object target)
Invoke the specified Method against the supplied target object
with no arguments. |
static Object |
invokeMethod(Method method,
Object target,
Object[] args)
Invoke the specified Method against the supplied target object
with the supplied arguments. |
static boolean |
isPublicStaticFinal(Field field)
Determine whether the given field is a "public static final" constant. |
static void |
makeAccessible(Field field)
Make the given field accessible, explicitly setting it accessible if necessary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectionUtils()
Method Detail |
---|
public static void handleReflectionException(Exception ex)
Throws the underlying RuntimeException or Error in case of an InvocationTargetException with such a root cause. Throws an IllegalStateException with an appropriate message else.
ex
- the reflection exception to handlepublic static void handleInvocationTargetException(InvocationTargetException ex)
Throws the underlying RuntimeException or Error in case of such a root cause. Throws an IllegalStateException else.
ex
- the invocation target exception to handlepublic static Method findMethod(Class type, String name, Class[] paramTypes)
Method
on the supplied type with the supplied name
and parameter types. Searches all superclasses up to Object
.
Returns null
if no Method
can be found.
public static Object invokeMethod(Method method, Object target)
Method
against the supplied target object
with no arguments. The target object can be null
when
invoking a static Method
.
Thrown exceptions are handled via a call to handleReflectionException(java.lang.Exception)
.
public static Object invokeMethod(Method method, Object target, Object[] args)
Method
against the supplied target object
with the supplied arguments. The target object can be null
when invoking a static Method
.
Thrown exceptions are handled via a call to handleReflectionException(java.lang.Exception)
.
public static boolean isPublicStaticFinal(Field field)
field
- the field to checkpublic static void makeAccessible(Field field)
setAccessible(true)
method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
field
- the field to make accessibleAccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |