Class StandardReflectionDriver
java.lang.Object
nonapi.io.github.classgraph.reflection.ReflectionDriver
nonapi.io.github.classgraph.reflection.StandardReflectionDriver
Standard reflection driver (uses
AccessibleObject.setAccessible(boolean) to access non-public fields if
necessary).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classNested classes/interfaces inherited from class nonapi.io.github.classgraph.reflection.ReflectionDriver
ReflectionDriver.ClassMemberCache -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> TdoPrivileged(Callable<T> callable) Call a method in the AccessController.doPrivileged(PrivilegedAction) context, using reflection, if possible (AccessController is deprecated in JDK 17).(package private) Class<?> Find a class by name.(package private) <T> Constructor<T>[]getDeclaredConstructors(Class<T> cls) Get declared constructors for class.(package private) Field[]getDeclaredFields(Class<?> cls) Get declared fields for class.(package private) Method[]getDeclaredMethods(Class<?> cls) Get declared methods for class.(package private) ObjectGet the value of a non-static field, boxing the value if necessary.(package private) ObjectgetStaticField(Field field) Get the value of a static field, boxing the value if necessary.(package private) ObjectinvokeMethod(Object object, Method method, Object... args) Invoke a non-static method, boxing the result if necessary.(package private) ObjectinvokeStaticMethod(Method method, Object... args) Invoke a static method, boxing the result if necessary.booleanmakeAccessible(Object instance, AccessibleObject obj) Make a field or method accessible.(package private) voidSet the value of a non-static field, unboxing the value if necessary.(package private) voidsetStaticField(Field field, Object value) Set the value of a static field, unboxing the value if necessary.private static booleanMethods inherited from class nonapi.io.github.classgraph.reflection.ReflectionDriver
findField, findInstanceField, findInstanceMethod, findMethod, findStaticField, findStaticMethod, isAccessible
-
Field Details
-
setAccessibleMethod
-
trySetAccessibleMethod
-
accessControllerClass
-
privilegedActionClass
-
accessControllerDoPrivileged
-
-
Constructor Details
-
StandardReflectionDriver
StandardReflectionDriver()
-
-
Method Details
-
doPrivileged
Call a method in the AccessController.doPrivileged(PrivilegedAction) context, using reflection, if possible (AccessController is deprecated in JDK 17).- Throws:
Throwable
-
tryMakeAccessible
-
makeAccessible
Description copied from class:ReflectionDriverMake a field or method accessible.- Specified by:
makeAccessiblein classReflectionDriver- Parameters:
instance- the object instance, or null if static.obj- the field or method.- Returns:
- true if successful.
-
findClass
Description copied from class:ReflectionDriverFind a class by name.- Specified by:
findClassin classReflectionDriver- Parameters:
className- the class name- Returns:
- the class reference
- Throws:
Exception
-
getDeclaredMethods
Description copied from class:ReflectionDriverGet declared methods for class.- Specified by:
getDeclaredMethodsin classReflectionDriver- Parameters:
cls- the class- Returns:
- the declared methods
- Throws:
Exception
-
getDeclaredConstructors
Description copied from class:ReflectionDriverGet declared constructors for class.- Specified by:
getDeclaredConstructorsin classReflectionDriver- Type Parameters:
T- the generic type- Parameters:
cls- the class- Returns:
- the declared constructors
- Throws:
Exception
-
getDeclaredFields
Description copied from class:ReflectionDriverGet declared fields for class.- Specified by:
getDeclaredFieldsin classReflectionDriver- Parameters:
cls- the class- Returns:
- the declared fields
- Throws:
Exception
-
getField
Description copied from class:ReflectionDriverGet the value of a non-static field, boxing the value if necessary.- Specified by:
getFieldin classReflectionDriver- Parameters:
object- the object instance to get the field value fromfield- the non-static field- Returns:
- the value of the field
- Throws:
Exception
-
setField
Description copied from class:ReflectionDriverSet the value of a non-static field, unboxing the value if necessary.- Specified by:
setFieldin classReflectionDriver- Parameters:
object- the object instance to get the field value fromfield- the non-static fieldvalue- the value to set- Throws:
Exception
-
getStaticField
Description copied from class:ReflectionDriverGet the value of a static field, boxing the value if necessary.- Specified by:
getStaticFieldin classReflectionDriver- Parameters:
field- the static field- Returns:
- the static field
- Throws:
Exception
-
setStaticField
Description copied from class:ReflectionDriverSet the value of a static field, unboxing the value if necessary.- Specified by:
setStaticFieldin classReflectionDriver- Parameters:
field- the static fieldvalue- the value to set- Throws:
Exception
-
invokeMethod
Description copied from class:ReflectionDriverInvoke a non-static method, boxing the result if necessary.- Specified by:
invokeMethodin classReflectionDriver- Parameters:
object- the object instance to invoke the method onmethod- the non-static methodargs- the method arguments (ornew Object[0]if there are no args)- Returns:
- the return value (possibly a boxed value)
- Throws:
Exception
-
invokeStaticMethod
Description copied from class:ReflectionDriverInvoke a static method, boxing the result if necessary.- Specified by:
invokeStaticMethodin classReflectionDriver- Parameters:
method- the static methodargs- the method arguments (ornew Object[0]if there are no args)- Returns:
- the return value (possibly a boxed value)
- Throws:
Exception
-