field on the supplied java.lang.Class with
the supplied name. Searches all superclasses up to java.lang.Object.
clazz the class to introspectname the name of the fieldnull if not foundfield on the supplied java.lang.Class with
the supplied name and/or type. Searches all
superclasses up to java.lang.Object.
clazz the class to introspectname the name of the field (may be null if type is specified)type the type of the field (may be null if name is specified)null if not foundAssert.isTrue(name != null || type != null, "Either name or type of the field must be specified");
field object on
the specified target object to the specified
value. In accordance with
java.lang.reflect.Field.set(java.lang.Object,java.lang.Object) semantics, the new value is
automatically unwrapped if the underlying field has a primitive type.
Thrown exceptions are handled via a call to
.
handleReflectionException(java.lang.Exception)
field the field to settarget the target object on which to set the fieldvalue the value to set; may be nullfield object on
the specified target object. In accordance with
java.lang.reflect.Field.get(java.lang.Object) semantics, the returned value is
automatically wrapped if the underlying field has a primitive type.
Thrown exceptions are handled via a call to
.
handleReflectionException(java.lang.Exception)
field the field to gettarget the target object from which to get the fieldjava.lang.reflect.Method on the supplied class with the supplied name
and no parameters. Searches all superclasses up to Object.
Returns null if no can be found.
java.lang.reflect.Method
clazz the class to introspectname the name of the methodnull if none foundjava.lang.reflect.Method on the supplied class with the supplied name
and parameter types. Searches all superclasses up to Object.
Returns null if no can be found.
java.lang.reflect.Method
clazz the class to introspectname the name of the methodparamTypes the parameter types of the method
(may be null to indicate any signature)null if none foundMethod[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods());
java.lang.reflect.Method against the supplied target object
with no arguments. The target object can be null when
invoking a static java.lang.reflect.Method.
Thrown exceptions are handled via a call to .
handleReflectionException(java.lang.Exception)
method the method to invoketarget the target object to invoke the method oninvokeMethod(java.lang.reflect.Method,java.lang.Object,java.lang.Object[])java.lang.reflect.Method against the supplied target object
with the supplied arguments. The target object can be null
when invoking a static java.lang.reflect.Method.
Thrown exceptions are handled via a call to .
handleReflectionException(java.lang.Exception)
method the method to invoketarget the target object to invoke the method onargs the invocation arguments (may be null)java.lang.reflect.Method against the supplied
target object with no arguments.
method the method to invoketarget the target object to invoke the method onjava.sql.SQLException the JDBC API SQLException to rethrow (if any)invokeJdbcMethod(java.lang.reflect.Method,java.lang.Object,java.lang.Object[])java.lang.reflect.Method against the supplied
target object with the supplied arguments.
method the method to invoketarget the target object to invoke the method onargs the invocation arguments (may be null)java.sql.SQLException the JDBC API SQLException to rethrow (if any)invokeMethod(java.lang.reflect.Method,java.lang.Object,java.lang.Object[])public static ObjectinvokeJdbcMethod(Method method, Object target, Object[] args) throws SQLException {
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 handleThrows the underlying RuntimeException or Error in case of such a root cause. Throws an IllegalStateException else.
ex the invocation target exception to handleexception, which is presumably the
target exception of an java.lang.reflect.InvocationTargetException.
Should only be called if no checked exception is expected to be thrown by
the target method.
Rethrows the underlying exception cast to an
or java.lang.RuntimeException if appropriate; otherwise, throws an
java.lang.Error.
java.lang.IllegalStateException
ex the exception to rethrowjava.lang.RuntimeException the rethrown exceptionexception, which is presumably the
target exception of an java.lang.reflect.InvocationTargetException.
Should only be called if no checked exception is expected to be thrown by
the target method.
Rethrows the underlying exception cast to an or
java.lang.Exception if appropriate; otherwise, throws an
java.lang.Error.
java.lang.IllegalStateException
ex the exception to rethrowjava.lang.Exception the rethrown exception (in case of a checked exception)method the declaring methodexceptionType the exception to throwtrue if the exception can be thrown as-is;
false if it needs to be wrappedreturn (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers));
setAccessible(true) method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
field the field to make accessiblejava.lang.reflect.AccessibleObject.setAccessible(boolean)setAccessible(true) method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
method the method to make accessiblejava.lang.reflect.AccessibleObject.setAccessible(boolean)setAccessible(true) method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
ctor the constructor to make accessiblejava.lang.reflect.AccessibleObject.setAccessible(boolean)The same named method occurring on subclass and superclass will
appear twice, unless excluded by a .
ReflectionUtils.MethodFilter
targetClass class to start looking atmc the callback to invoke for each methoddoWithMethods(java.lang.Class,org.springframework.util.ReflectionUtils.MethodCallback,org.springframework.util.ReflectionUtils.MethodFilter)public static voiddoWithMethods(Class targetClass, MethodCallback mc) throws IllegalArgumentException {
The same named method occurring on subclass and superclass will
appear twice, unless excluded by the specified .
ReflectionUtils.MethodFilter
targetClass class to start looking atmc the callback to invoke for each methodmf the filter that determines the methods to apply the callback topublic static voiddoWithFields(Class targetClass, FieldCallback fc) throws IllegalArgumentException {
java.lang.IllegalArgumentException if the arguments are incompatiblepublic static voidshallowCopyFieldState(final Object src, final Object dest) throws IllegalArgumentException {