Class NarcissusReflectionDriver
java.lang.Object
nonapi.io.github.classgraph.reflection.ReflectionDriver
nonapi.io.github.classgraph.reflection.NarcissusReflectionDriver
Narcissus reflection driver (uses the Narcissus library,
if it is available, which allows access to non-public fields and methods, circumventing encapsulation and
visibility controls via JNI).
-
Nested Class Summary
Nested classes/interfaces inherited from class nonapi.io.github.classgraph.reflection.ReflectionDriver
ReflectionDriver.ClassMemberCache -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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.booleanisAccessible(Object instance, AccessibleObject obj) Check whether a field or method is accessible.booleanmakeAccessible(Object instance, AccessibleObject accessibleObject) 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.Methods inherited from class nonapi.io.github.classgraph.reflection.ReflectionDriver
findField, findInstanceField, findInstanceMethod, findMethod, findStaticField, findStaticMethod
-
Field Details
-
narcissusClass
-
getDeclaredMethods
-
findClass
-
getDeclaredConstructors
-
getDeclaredFields
-
getField
-
setField
-
getStaticField
-
setStaticField
-
invokeMethod
-
invokeStaticMethod
-
-
Constructor Details
-
Method Details
-
isAccessible
Description copied from class:ReflectionDriverCheck whether a field or method is accessible.N.B. this is overridden in Narcissus driver to just return true, since everything is accessible to JNI.
- Overrides:
isAccessiblein classReflectionDriver- Parameters:
instance- the object instance, or null if static.obj- the field or method.- Returns:
- true if accessible.
-
makeAccessible
Description copied from class:ReflectionDriverMake a field or method accessible.- Specified by:
makeAccessiblein classReflectionDriver- Parameters:
instance- the object instance, or null if static.accessibleObject- 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
-