public final class ReflectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Constructor<T> |
findKnownConstructor(Class<T> aClass,
Class<?>... paramTypes)
Looks up a constructor that is explicitly identified.
|
static Method |
findKnownMethod(Class<?> aClass,
String name,
Class<?>... paramTypes)
Looks up a method that is explicitly identified.
|
static <T> T |
invokeUnchecked(Constructor<T> constructor,
Object... arguments)
Invokes the specified constructor without throwing any checked exceptions.
|
static <T> T |
invokeUnchecked(Method method,
Object target,
Object... arguments)
Invokes the specified method without throwing any checked exceptions.
|
public static <T> T invokeUnchecked(Method method, Object target, 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(Constructor<T> constructor, 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 Method findKnownMethod(Class<?> aClass, String name, 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> Constructor<T> findKnownConstructor(Class<T> aClass, 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.