Top Description Inners Fields Constructors Methods
nonapi.io.github.classgraph.reflection

pack-priv Class StandardReflectionDriver

extends ReflectionDriver
Class Inheritance
Imports
java.lang.reflect.AccessibleObject, .Constructor, .Field, .InvocationHandler, .Method, .Proxy, java.util.concurrent.Callable

Standard reflection driver (uses AccessibleObject#setAccessible(boolean) to access non-public fields if necessary).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static Class<?>
private static Method
private static Class<?>
private static Method
private static Method

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private <T> T
doPrivileged(final Callable<T> callable)

Call a method in the AccessController.doPrivileged(PrivilegedAction) context, using reflection, if possible (AccessController is deprecated in JDK 17).

pack-priv Class<?>
findClass(final String
the class name
className
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.findClass.

Find a class by name.

pack-priv <T> Constructor<T>[]
getDeclaredConstructors(final Class<T>
the class
cls
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredConstructors.

Get declared constructors for class.

pack-priv Field[]
getDeclaredFields(final Class<?>
the class
cls
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredFields.

Get declared fields for class.

pack-priv Method[]
getDeclaredMethods(final Class<?>
the class
cls
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredMethods.

Get declared methods for class.

pack-priv Object
getField(final Object
the object instance to get the field value from
object
,
final Field
the non-static field
field
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getField.

Get the value of a non-static field, boxing the value if necessary.

pack-priv Object
getStaticField(final Field
the static field
field
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getStaticField.

Get the value of a static field, boxing the value if necessary.

pack-priv Object
invokeMethod(final Object
the object instance to invoke the method on
object
,
final Method
the non-static method
method
,
final Object...
the method arguments (or new Object[0] if there are no args)
args
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeMethod.

Invoke a non-static method, boxing the result if necessary.

pack-priv Object
invokeStaticMethod(final Method
the static method
method
,
final Object...
the method arguments (or new Object[0] if there are no args)
args
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeStaticMethod.

Invoke a static method, boxing the result if necessary.

public boolean
makeAccessible(final Object
the object instance, or null if static.
instance
,
final AccessibleObject
the field or method.
obj
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.makeAccessible.

Make a field or method accessible.

pack-priv void
setField(final Object
the object instance to get the field value from
object
,
final Field
the non-static field
field
,
final Object
the value to set
value
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.setField.

Set the value of a non-static field, unboxing the value if necessary.

pack-priv void
setStaticField(final Field
the static field
field
,
final Object
the value to set
value
)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.setStaticField.

Set the value of a static field, unboxing the value if necessary.

private static boolean
Inherited from nonapi.io.github.classgraph.reflection.ReflectionDriver:
findFieldfindInstanceFieldfindInstanceMethodfindMethodfindStaticFieldfindStaticMethodisAccessible

Field Detail

accessControllerClassback to summary
private static Class<?> accessControllerClass
accessControllerDoPrivilegedback to summary
private static Method accessControllerDoPrivileged
privilegedActionClassback to summary
private static Class<?> privilegedActionClass
setAccessibleMethodback to summary
private static Method setAccessibleMethod
trySetAccessibleMethodback to summary
private static Method trySetAccessibleMethod

Constructor Detail

StandardReflectionDriverback to summary
pack-priv StandardReflectionDriver()

Method Detail

doPrivilegedback to summary
private <T> T doPrivileged(final Callable<T> callable) throws Throwable

Call a method in the AccessController.doPrivileged(PrivilegedAction) context, using reflection, if possible (AccessController is deprecated in JDK 17).

Annotations
@SuppressWarnings:unchecked
findClassback to summary
pack-priv Class<?> findClass(final String className) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.findClass.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.findClass.

Find a class by name.

Parameters
className:String

the class name

Returns:Class<?>

the class reference

Annotations
@Override
getDeclaredConstructorsback to summary
pack-priv <T> Constructor<T>[] getDeclaredConstructors(final Class<T> cls) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredConstructors.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredConstructors.

Get declared constructors for class.

Parameters
<T>
the generic type
cls:Class<T>

the class

Returns:Constructor<T>[]

the declared constructors

Annotations
@SuppressWarnings:unchecked
@Override
getDeclaredFieldsback to summary
pack-priv Field[] getDeclaredFields(final Class<?> cls) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredFields.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredFields.

Get declared fields for class.

Parameters
cls:Class<?>

the class

Returns:Field[]

the declared fields

Annotations
@Override
getDeclaredMethodsback to summary
pack-priv Method[] getDeclaredMethods(final Class<?> cls) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredMethods.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.getDeclaredMethods.

Get declared methods for class.

Parameters
cls:Class<?>

the class

Returns:Method[]

the declared methods

Annotations
@Override
getFieldback to summary
pack-priv Object getField(final Object object, final Field field) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getField.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.getField.

Get the value of a non-static field, boxing the value if necessary.

Parameters
object:Object

the object instance to get the field value from

field:Field

the non-static field

Returns:Object

the value of the field

Annotations
@Override
getStaticFieldback to summary
pack-priv Object getStaticField(final Field field) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.getStaticField.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.getStaticField.

Get the value of a static field, boxing the value if necessary.

Parameters
field:Field

the static field

Returns:Object

the static field

Annotations
@Override
invokeMethodback to summary
pack-priv Object invokeMethod(final Object object, final Method method, final Object... args) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeMethod.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeMethod.

Invoke a non-static method, boxing the result if necessary.

Parameters
object:Object

the object instance to invoke the method on

method:Method

the non-static method

args:Object[]

the method arguments (or new Object[0] if there are no args)

Returns:Object

the return value (possibly a boxed value)

Annotations
@Override
invokeStaticMethodback to summary
pack-priv Object invokeStaticMethod(final Method method, final Object... args) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeStaticMethod.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.invokeStaticMethod.

Invoke a static method, boxing the result if necessary.

Parameters
method:Method

the static method

args:Object[]

the method arguments (or new Object[0] if there are no args)

Returns:Object

the return value (possibly a boxed value)

Annotations
@Override
makeAccessibleback to summary
public boolean makeAccessible(final Object instance, final AccessibleObject obj)

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.makeAccessible.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.makeAccessible.

Make a field or method accessible.

Parameters
instance:Object

the object instance, or null if static.

obj:AccessibleObject

the field or method.

Returns:boolean

true if successful.

Annotations
@Override
setFieldback to summary
pack-priv void setField(final Object object, final Field field, final Object value) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.setField.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.setField.

Set the value of a non-static field, unboxing the value if necessary.

Parameters
object:Object

the object instance to get the field value from

field:Field

the non-static field

value:Object

the value to set

Annotations
@Override
setStaticFieldback to summary
pack-priv void setStaticField(final Field field, final Object value) throws Exception

Implements abstract nonapi.io.github.classgraph.reflection.ReflectionDriver.setStaticField.

Doc from nonapi.io.github.classgraph.reflection.ReflectionDriver.setStaticField.

Set the value of a static field, unboxing the value if necessary.

Parameters
field:Field

the static field

value:Object

the value to set

Annotations
@Override
tryMakeAccessibleback to summary
private static boolean tryMakeAccessible(final AccessibleObject obj)
nonapi.io.github.classgraph.reflection back to summary

private Class StandardReflectionDriver.PrivilegedActionInvocationHandler<T>

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • nonapi.io.github.classgraph.reflection.StandardReflectionDriver.PrivilegedActionInvocationHandler
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Field Summary

Modifier and TypeField and Description
private final Callable<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(final Object
the proxy instance that the method was invoked on
proxy
,
final Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
final Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callableback to summary
private final Callable<T> callable

Constructor Detail

PrivilegedActionInvocationHandlerback to summary
public PrivilegedActionInvocationHandler(final Callable<T> callable)

Method Detail

invokeback to summary
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.