public final class ReflectionUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Set<Class<?>> |
getImplementedInterfaces(Class<?> aClass)
Returns a Set of all the interfaces implemented by the given class.
|
static Class<?>[] |
getImplementedInterfacesAsArray(Class<?> aClass)
Returns an array of all the interfaces implemented by the given class.
|
static <T> T |
newProxyInstance(ClassLoader contextClassLoader,
Class<T> interfaceType,
Class<? extends T> concreteImplementation,
InvocationHandler invocationHandler) |
static <T> T |
newProxyInstance(ClassLoader contextClassLoader,
Class<T> interfaceType,
InvocationHandler invocationHandler,
Class<?>... additionalInterfaces) |
static void |
removeFinalModifier(AccessibleObject accessibleObject)
Removes the
final modifier on an AccessibleObject ie Field, Constructor or Method. |
static <T> void |
setFinalFieldValue(Class<? super T> declaringClass,
T instance,
String fieldName,
Object value)
Modifies the value of a final field on an object.
|
@Nonnull public static Set<Class<?>> getImplementedInterfaces(@Nonnull Class<?> aClass)
aClass
- the class to examine@Nonnull public static Class<?>[] getImplementedInterfacesAsArray(@Nonnull Class<?> aClass)
aClass
- the class to examine@Nonnull public static <T> T newProxyInstance(@Nonnull ClassLoader contextClassLoader, @Nonnull Class<T> interfaceType, @Nonnull Class<? extends T> concreteImplementation, @Nonnull InvocationHandler invocationHandler)
@Nonnull public static <T> T newProxyInstance(@Nonnull ClassLoader contextClassLoader, @Nonnull Class<T> interfaceType, @Nonnull InvocationHandler invocationHandler, @Nonnull Class<?>... additionalInterfaces)
public static void removeFinalModifier(@Nonnull AccessibleObject accessibleObject)
final
modifier on an AccessibleObject
ie Field, Constructor or Method.accessibleObject
- the final accessibleObject which requires its final modifier to be removed.public static <T> void setFinalFieldValue(@Nonnull Class<? super T> declaringClass, @Nullable T instance, @Nonnull String fieldName, @Nullable Object value)
The final field can have any modifier including private or package-private.
T
- the typedeclaringClass
- the Class which declares the given final field.instance
- the object containing the given final field, maybe null for a static field.fieldName
- the name of the given final fieldvalue
- the value to set to the given final fieldCopyright © 2020. All Rights Reserved.