public final class ReflectionUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> java.lang.reflect.Constructor<T> |
findKnownConstructor(java.lang.Class<T> aClass,
java.lang.Class<?>... paramTypes)
Looks up a constructor that is explicitly identified.
|
static java.lang.reflect.Method |
findKnownMethod(java.lang.Class<?> aClass,
java.lang.String name,
java.lang.Class<?>... paramTypes)
Looks up a method that is explicitly identified.
|
static <T> T |
invokeUnchecked(java.lang.reflect.Constructor<T> constructor,
java.lang.Object... arguments)
Invokes the specified constructor without throwing any checked exceptions.
|
static <T> T |
invokeUnchecked(java.lang.reflect.Method method,
java.lang.Object target,
java.lang.Object... arguments)
Invokes the specified method without throwing any checked exceptions.
|
public static <T> T invokeUnchecked(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object... arguments)
T
- The return type of the method. The compiler can usually infer the
correct type.method
- The method to invoke. Both the method and its class must have
been declared public and non-abstract, otherwise they will be inaccessible.target
- The object on which to invoke the method.arguments
- The method arguments.public static <T> T invokeUnchecked(java.lang.reflect.Constructor<T> constructor, java.lang.Object... arguments)
T
- The return type of the method. The compiler can usually infer the
correct type.constructor
- The constructor to invoke. Both the constructor and its
class must have been declared public, and the class must not be abstract,
otherwise they will be inaccessible.arguments
- The method arguments.public static java.lang.reflect.Method findKnownMethod(java.lang.Class<?> aClass, java.lang.String name, java.lang.Class<?>... paramTypes)
aClass
- The class in which the method exists.name
- The name of the method.paramTypes
- The types of the method's parameters.public static <T> java.lang.reflect.Constructor<T> findKnownConstructor(java.lang.Class<T> aClass, java.lang.Class<?>... paramTypes)
T
- The type of object that the constructor creates.aClass
- The class in which the constructor exists.paramTypes
- The types of the constructor's parameters.