public final class RuntimeReflection extends Object
Modifier and Type | Method and Description |
---|---|
static void |
register(Class<?>... classes)
Makes the provided classes available for reflection at run time.
|
static void |
register(Executable... methods)
Makes the provided methods available for reflection at run time.
|
static void |
register(Field... fields)
Makes the provided fields available for reflection at run time.
|
static void |
registerAllClasses(Class<?> declaringClass)
Allows calling
Class.getClasses() on the provided class at run time. |
static void |
registerAllConstructors(Class<?> declaringClass)
Allows calling
Class.getConstructors() on the provided class at run time. |
static void |
registerAllDeclaredClasses(Class<?> declaringClass)
Allows calling
Class.getDeclaredClasses() on the provided class at run time. |
static void |
registerAllDeclaredConstructors(Class<?> declaringClass)
Allows calling
Class.getDeclaredConstructors() on the provided class at run time. |
static void |
registerAllDeclaredFields(Class<?> declaringClass)
Allows calling
Class.getDeclaredFields() on the provided class at run time. |
static void |
registerAllDeclaredMethods(Class<?> declaringClass)
Allows calling
Class.getDeclaredMethods() on the provided class at run time. |
static void |
registerAllFields(Class<?> declaringClass)
Allows calling
Class.getFields() on the provided class at run time. |
static void |
registerAllMethods(Class<?> declaringClass)
Allows calling
Class.getMethods() on the provided class at run time. |
static void |
registerAllNestMembers(Class<?> declaringClass)
Allows calling
Class.getNestMembers() on the provided class at run time. |
static void |
registerAllPermittedSubclasses(Class<?> declaringClass)
Allows calling
Class.getPermittedSubclasses() on the provided class at run time. |
static void |
registerAllRecordComponents(Class<?> declaringClass)
Allows calling
Class.getRecordComponents() on the provided class at run time. |
static void |
registerAllSigners(Class<?> declaringClass)
Allows calling
Class.getSigners() on the provided class at run time. |
static void |
registerAsQueried(Executable... methods)
Makes the provided methods available for reflection queries at run time.
|
static void |
registerClassLookup(String className)
Makes the provided class available for reflection at run time.
|
static void |
registerConstructorLookup(Class<?> declaringClass,
Class<?>... parameterTypes)
Makes the provided constructor available for reflection queries at run time.
|
static void |
registerFieldLookup(Class<?> declaringClass,
String fieldName)
Makes the provided field available for reflection at run time.
|
static void |
registerForReflectiveInstantiation(Class<?>... classes)
Makes the provided classes available for reflective instantiation by
Class.newInstance() . |
static void |
registerMethodLookup(Class<?> declaringClass,
String methodName,
Class<?>... parameterTypes)
Makes the provided method available for reflection queries at run time.
|
public static void register(Class<?>... classes)
Class.forName(java.lang.String)
for the names of the classes will return the classes at run time.public static void registerClassLookup(String className)
Class.forName(java.lang.String)
for the name of the class will return the class (if it exists) or a
ClassNotFoundException
at run time.public static void register(Executable... methods)
Class.getMethod(java.lang.String, java.lang.Class<?>...)
, Class.getDeclaredMethod(String, Class[])
, and all the
other methods on Class
that return a single method.public static void registerAsQueried(Executable... methods)
Class.getMethod(java.lang.String, java.lang.Class<?>...)
, Class.getDeclaredMethod(String, Class[])
, and
all the other methods on Class
that return a single method, but will not be invocable
and will not be considered reachable.public static void registerMethodLookup(Class<?> declaringClass, String methodName, Class<?>... parameterTypes)
Class.getMethod(java.lang.String, java.lang.Class<?>...)
, Class.getDeclaredMethod(String, Class[])
, and
all the other methods on Class
that return a single method, but will not be invocable
and will not be considered reachable. If the method doesn't exist a
NoSuchMethodException
will be thrown when calling these methods at run-time.public static void registerConstructorLookup(Class<?> declaringClass, Class<?>... parameterTypes)
Class.getConstructor(java.lang.Class<?>...)
,
Class.getDeclaredConstructor(Class[])
, and all the other methods on Class
that return a single constructor, but will not be invocable and will not be considered
reachable. If the constructor doesn't exist a NoSuchMethodException
will be thrown
when calling these methods at run-time.public static void register(Field... fields)
Class.getField(java.lang.String)
, Class.getDeclaredField(String)
,and all the other methods
on Class
that return a single field.public static void registerFieldLookup(Class<?> declaringClass, String fieldName)
Class.getField(java.lang.String)
, Class.getDeclaredField(String)
, and all the other methods on
Class
that return a single field. If the field doesn't exist a
NoSuchFieldException
will be thrown when calling these methods at run-time.public static void registerAllClasses(Class<?> declaringClass)
Class.getClasses()
on the provided class at run time.public static void registerAllDeclaredClasses(Class<?> declaringClass)
Class.getDeclaredClasses()
on the provided class at run time.public static void registerAllMethods(Class<?> declaringClass)
Class.getMethods()
on the provided class at run time. The methods will
also be registered for individual queries.public static void registerAllDeclaredMethods(Class<?> declaringClass)
Class.getDeclaredMethods()
on the provided class at run time. The
methods will also be registered for individual queries.public static void registerAllConstructors(Class<?> declaringClass)
Class.getConstructors()
on the provided class at run time. The
constructors will also be registered for individual queries.public static void registerAllDeclaredConstructors(Class<?> declaringClass)
Class.getDeclaredConstructors()
on the provided class at run time. The
constructors will also be registered for individual queries.public static void registerAllFields(Class<?> declaringClass)
Class.getFields()
on the provided class at run time. The fields will
also be registered for individual queries.public static void registerAllDeclaredFields(Class<?> declaringClass)
Class.getDeclaredFields()
on the provided class at run time. The
fields will also be registered for individual queries.public static void registerAllNestMembers(Class<?> declaringClass)
Class.getNestMembers()
on the provided class at run time.public static void registerAllPermittedSubclasses(Class<?> declaringClass)
Class.getPermittedSubclasses()
on the provided class at run time.public static void registerAllRecordComponents(Class<?> declaringClass)
Class.getRecordComponents()
on the provided class at run time.public static void registerAllSigners(Class<?> declaringClass)
Class.getSigners()
on the provided class at run time.public static void registerForReflectiveInstantiation(Class<?>... classes)
Class.newInstance()
. This is equivalent to registering the nullary constructors of the
classes.