Enum Class ReflectionCategory
- All Implemented Interfaces:
Serializable, Comparable<ReflectionCategory>, Constable
The kinds of reflection the checks tell apart, which is what a project allows when it allows any.
The kinds follow what the platform does when it is called. Most fill a cache the virtual machine keeps for a class or a member - the reflection data of a class (its members, names and interfaces), its enum constants, its generic signature and annotations, the accessor of a method or a field - and the others load, define or proxy classes, or reach members by name. A call is reported under the first category, in the order declared here, that it belongs to.
The names are what the flags of the checks take and what the Gradle plugin's
noReflection { allow(...) } names. The flags are declared here rather than on the check so that the
plugin reads them without loading a class that needs ErrorProne.
- Since:
- 1.0.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionBuilding an annotation instance from Micronaut's annotation metadata, which defines a proxy class to do it.Annotations read from a class, a member, a parameter or a type use, rather than from Micronaut's metadata.java.beans: introspection, feature descriptors, statements, encoders and event handlers.Classes loaded by name or defined at run time:Class.forName, aClassLoader, module layers, resource bundles and Micronaut'sClassUtils.forName.The members of a class looked up: its methods, constructors and fields, record components, nested and permitted classes, nest members, enclosing method, and the parameters of a method.Class.getSimpleNameandClass.getCanonicalName, which fill the reflection data of the class.A call the build forbids besides the categories above, withnoReflection { forbid(...) }.The enum constants a class caches:Class.getEnumConstants,Enum.valueOfand thevalueOf(String)of every enum, which calls it,EnumSetandEnumMap.AtomicReferenceFieldUpdater,AtomicIntegerFieldUpdaterandAtomicLongFieldUpdater, which look their field up.Generic signatures, parsed and cached for a class or a member, the types they produce, and Micronaut'sGenericTypeUtils.All ofjava.lang.invokebut its exceptions - method and variable handles, lookups, call sites, and the factories and bootstraps behind lambdas and string concatenation - with the bootstraps ofjava.lang.runtimefor records and switches, the resolution ofjava.lang.constantdescriptions, and the handles ofjava.lang.foreign.Linker.java.lang.instrument.Instrumentation, which lists, redefines and retransforms loaded classes.Class.getInterfaces, which fills the reflection data of the class, and Micronaut'sClassUtils.resolveHierarchy.Proxy classes:java.lang.reflect.Proxy,MethodHandleProxiesandInvocationHandler.invokeDefault.Micronaut'sReflectionUtils, but for its table mapping primitive types to their wrappers and back.A member reached once it is found:setAccessible, invoking a method, reading or writing a field, creating an instance reflectively,Array, opening a module, and Micronaut'sInstantiationUtils.Java serialization, which reads the fields, constructors and private methods of the classes it meets.java.util.ServiceLoaderand Micronaut'sSoftServiceLoader, which instantiate what they find reflectively.Thejava.lang.reflectmember behind a Micronaut method or field:getTargetMethod,FieldInjectionPoint.getField.sun.misc.Unsafeandsun.reflect.ReflectionFactory. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe flag naming the calls allowed throughout the project, asCallPatterns separated by commas.static final StringThe flag naming the categories allowed throughout the project, separated by commas.static final StringThe flag naming the classes and packages in which reflection is allowed, asAllowedScopes separated by commas.static final StringThe flag naming the calls reported asCUSTOM, asCallPatterns separated by commas.static final StringThe flag saying whether a@SuppressWarnings("NoReflection")in the source is honoured, unless it isfalse. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReflectionCategorystatic ReflectionCategoryReturns the enum constant of this class with the specified name.static ReflectionCategory[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ANNOTATION_SYNTHESIS
Building an annotation instance from Micronaut's annotation metadata, which defines a proxy class to do it. -
TARGET_MEMBERS
Thejava.lang.reflectmember behind a Micronaut method or field:getTargetMethod,FieldInjectionPoint.getField. -
REFLECTION_UTILS
Micronaut'sReflectionUtils, but for its table mapping primitive types to their wrappers and back. -
BEANS
java.beans: introspection, feature descriptors, statements, encoders and event handlers. -
SERIALIZATION
Java serialization, which reads the fields, constructors and private methods of the classes it meets. -
UNSAFE
sun.misc.Unsafeandsun.reflect.ReflectionFactory. -
INSTRUMENTATION
java.lang.instrument.Instrumentation, which lists, redefines and retransforms loaded classes. -
PROXY
Proxy classes:java.lang.reflect.Proxy,MethodHandleProxiesandInvocationHandler.invokeDefault. -
HANDLES
All ofjava.lang.invokebut its exceptions - method and variable handles, lookups, call sites, and the factories and bootstraps behind lambdas and string concatenation - with the bootstraps ofjava.lang.runtimefor records and switches, the resolution ofjava.lang.constantdescriptions, and the handles ofjava.lang.foreign.Linker. -
SERVICE_LOADING
java.util.ServiceLoaderand Micronaut'sSoftServiceLoader, which instantiate what they find reflectively. -
CLASS_LOADING
Classes loaded by name or defined at run time:Class.forName, aClassLoader, module layers, resource bundles and Micronaut'sClassUtils.forName. -
FIELD_UPDATERS
AtomicReferenceFieldUpdater,AtomicIntegerFieldUpdaterandAtomicLongFieldUpdater, which look their field up. -
ENUM_CONSTANTS
The enum constants a class caches:Class.getEnumConstants,Enum.valueOfand thevalueOf(String)of every enum, which calls it,EnumSetandEnumMap. -
CLASS_NAMES
Class.getSimpleNameandClass.getCanonicalName, which fill the reflection data of the class. -
INTERFACES
Class.getInterfaces, which fills the reflection data of the class, and Micronaut'sClassUtils.resolveHierarchy. -
GENERIC_SIGNATURES
Generic signatures, parsed and cached for a class or a member, the types they produce, and Micronaut'sGenericTypeUtils. -
ANNOTATIONS
Annotations read from a class, a member, a parameter or a type use, rather than from Micronaut's metadata. -
CLASS_MEMBERS
The members of a class looked up: its methods, constructors and fields, record components, nested and permitted classes, nest members, enclosing method, and the parameters of a method. -
REFLECTIVE_ACCESS
A member reached once it is found:setAccessible, invoking a method, reading or writing a field, creating an instance reflectively,Array, opening a module, and Micronaut'sInstantiationUtils. -
CUSTOM
A call the build forbids besides the categories above, withnoReflection { forbid(...) }.
-
-
Field Details
-
ALLOWED_FLAG
The flag naming the categories allowed throughout the project, separated by commas.- See Also:
-
ALLOWED_CALLS_FLAG
The flag naming the calls allowed throughout the project, asCallPatterns separated by commas.- See Also:
-
ALLOWED_IN_FLAG
The flag naming the classes and packages in which reflection is allowed, asAllowedScopes separated by commas.- See Also:
-
FORBIDDEN_CALLS_FLAG
The flag naming the calls reported asCUSTOM, asCallPatterns separated by commas.- See Also:
-
SUPPRESSIBLE_FLAG
The flag saying whether a@SuppressWarnings("NoReflection")in the source is honoured, unless it isfalse.- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
named
- Parameters:
name- The name of a category, in any case- Returns:
- The category
- Throws:
IllegalArgumentException- When no category has the name, naming the ones there are
-