Enum Class ReflectionCategory

java.lang.Object
java.lang.Enum<ReflectionCategory>
io.micronaut.errorprone.noreflection.ReflectionCategory
All Implemented Interfaces:
Serializable, Comparable<ReflectionCategory>, Constable

public enum ReflectionCategory extends Enum<ReflectionCategory>
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 Constants
    Enum Constant
    Description
    Building 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, a ClassLoader, module layers, resource bundles and Micronaut's ClassUtils.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.getSimpleName and Class.getCanonicalName, which fill the reflection data of the class.
    A call the build forbids besides the categories above, with noReflection { forbid(...) }.
    The enum constants a class caches: Class.getEnumConstants, Enum.valueOf and the valueOf(String) of every enum, which calls it, EnumSet and EnumMap.
    AtomicReferenceFieldUpdater, AtomicIntegerFieldUpdater and AtomicLongFieldUpdater, which look their field up.
    Generic signatures, parsed and cached for a class or a member, the types they produce, and Micronaut's GenericTypeUtils.
    All of java.lang.invoke but its exceptions - method and variable handles, lookups, call sites, and the factories and bootstraps behind lambdas and string concatenation - with the bootstraps of java.lang.runtime for records and switches, the resolution of java.lang.constant descriptions, and the handles of java.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's ClassUtils.resolveHierarchy.
    Proxy classes: java.lang.reflect.Proxy, MethodHandleProxies and InvocationHandler.invokeDefault.
    Micronaut's ReflectionUtils, 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's InstantiationUtils.
    Java serialization, which reads the fields, constructors and private methods of the classes it meets.
    java.util.ServiceLoader and Micronaut's SoftServiceLoader, which instantiate what they find reflectively.
    The java.lang.reflect member behind a Micronaut method or field: getTargetMethod, FieldInjectionPoint.getField.
    sun.misc.Unsafe and sun.reflect.ReflectionFactory.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The flag naming the calls allowed throughout the project, as CallPatterns separated by commas.
    static final String
    The flag naming the categories allowed throughout the project, separated by commas.
    static final String
    The flag naming the classes and packages in which reflection is allowed, as AllowedScopes separated by commas.
    static final String
    The flag naming the calls reported as CUSTOM, as CallPatterns separated by commas.
    static final String
    The flag saying whether a @SuppressWarnings("NoReflection") in the source is honoured, unless it is false.
  • Method Summary

    Modifier and Type
    Method
    Description
    named(String name)
     
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ANNOTATION_SYNTHESIS

      public static final ReflectionCategory ANNOTATION_SYNTHESIS
      Building an annotation instance from Micronaut's annotation metadata, which defines a proxy class to do it.
    • TARGET_MEMBERS

      public static final ReflectionCategory TARGET_MEMBERS
      The java.lang.reflect member behind a Micronaut method or field: getTargetMethod, FieldInjectionPoint.getField.
    • REFLECTION_UTILS

      public static final ReflectionCategory REFLECTION_UTILS
      Micronaut's ReflectionUtils, but for its table mapping primitive types to their wrappers and back.
    • BEANS

      public static final ReflectionCategory BEANS
      java.beans: introspection, feature descriptors, statements, encoders and event handlers.
    • SERIALIZATION

      public static final ReflectionCategory SERIALIZATION
      Java serialization, which reads the fields, constructors and private methods of the classes it meets.
    • UNSAFE

      public static final ReflectionCategory UNSAFE
      sun.misc.Unsafe and sun.reflect.ReflectionFactory.
    • INSTRUMENTATION

      public static final ReflectionCategory INSTRUMENTATION
      java.lang.instrument.Instrumentation, which lists, redefines and retransforms loaded classes.
    • PROXY

      public static final ReflectionCategory PROXY
      Proxy classes: java.lang.reflect.Proxy, MethodHandleProxies and InvocationHandler.invokeDefault.
    • HANDLES

      public static final ReflectionCategory HANDLES
      All of java.lang.invoke but its exceptions - method and variable handles, lookups, call sites, and the factories and bootstraps behind lambdas and string concatenation - with the bootstraps of java.lang.runtime for records and switches, the resolution of java.lang.constant descriptions, and the handles of java.lang.foreign.Linker.
    • SERVICE_LOADING

      public static final ReflectionCategory SERVICE_LOADING
      java.util.ServiceLoader and Micronaut's SoftServiceLoader, which instantiate what they find reflectively.
    • CLASS_LOADING

      public static final ReflectionCategory CLASS_LOADING
      Classes loaded by name or defined at run time: Class.forName, a ClassLoader, module layers, resource bundles and Micronaut's ClassUtils.forName.
    • FIELD_UPDATERS

      public static final ReflectionCategory FIELD_UPDATERS
      AtomicReferenceFieldUpdater, AtomicIntegerFieldUpdater and AtomicLongFieldUpdater, which look their field up.
    • ENUM_CONSTANTS

      public static final ReflectionCategory ENUM_CONSTANTS
      The enum constants a class caches: Class.getEnumConstants, Enum.valueOf and the valueOf(String) of every enum, which calls it, EnumSet and EnumMap.
    • CLASS_NAMES

      public static final ReflectionCategory CLASS_NAMES
      Class.getSimpleName and Class.getCanonicalName, which fill the reflection data of the class.
    • INTERFACES

      public static final ReflectionCategory INTERFACES
      Class.getInterfaces, which fills the reflection data of the class, and Micronaut's ClassUtils.resolveHierarchy.
    • GENERIC_SIGNATURES

      public static final ReflectionCategory GENERIC_SIGNATURES
      Generic signatures, parsed and cached for a class or a member, the types they produce, and Micronaut's GenericTypeUtils.
    • ANNOTATIONS

      public static final ReflectionCategory ANNOTATIONS
      Annotations read from a class, a member, a parameter or a type use, rather than from Micronaut's metadata.
    • CLASS_MEMBERS

      public static final ReflectionCategory 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

      public static final ReflectionCategory 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's InstantiationUtils.
    • CUSTOM

      public static final ReflectionCategory CUSTOM
      A call the build forbids besides the categories above, with noReflection { forbid(...) }.
  • Field Details

    • ALLOWED_FLAG

      public static final String ALLOWED_FLAG
      The flag naming the categories allowed throughout the project, separated by commas.
      See Also:
    • ALLOWED_CALLS_FLAG

      public static final String ALLOWED_CALLS_FLAG
      The flag naming the calls allowed throughout the project, as CallPatterns separated by commas.
      See Also:
    • ALLOWED_IN_FLAG

      public static final String ALLOWED_IN_FLAG
      The flag naming the classes and packages in which reflection is allowed, as AllowedScopes separated by commas.
      See Also:
    • FORBIDDEN_CALLS_FLAG

      public static final String FORBIDDEN_CALLS_FLAG
      The flag naming the calls reported as CUSTOM, as CallPatterns separated by commas.
      See Also:
    • SUPPRESSIBLE_FLAG

      public static final String SUPPRESSIBLE_FLAG
      The flag saying whether a @SuppressWarnings("NoReflection") in the source is honoured, unless it is false.
      See Also:
  • Method Details

    • values

      public static ReflectionCategory[] 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

      public static ReflectionCategory valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • named

      public static ReflectionCategory named(String name)
      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