Package io.micronaut.reflection
The framework describes a type through AnnotationMetadata,
Argument, ExecutableMethod,
BeanIntrospection and BeanDefinition, all of them
generated when the type is compiled. A specification that has to handle any class - Jakarta Validation, Jakarta
REST, CDI - meets types that were not compiled with the processors, and has to describe them through
java.lang.reflect instead. This package builds the same metadata from reflection, in the shape the
processors give it, so that code written against generated metadata works unchanged:
ReflectionAnnotations- the annotation metadata of an element, with the stereotypes, the repeatable containers and the defaults the processors record;ReflectionArguments- the arguments of the parameters, fields and return types, with the type-use annotations of every level;ReflectionExecutableMethodandReflectionBeanConstructor- an executable over aMethodor aConstructor, andReflectionExecutablesto resolve one to the best metadata available;ReflectionBeanIntrospection- an introspection over a class, andReflectionBeanIntrospectorto serve the generated ones first;ReflectionBeanDefinition- a bean definition over a class, registered at runtime, with the injection points and the life cycle of a generated one;MethodHierarchy- what each level of a method hierarchy declares.
Every type of this package is Experimental: reading a class back is what
the framework is built to avoid, and an application says it wants it by depending on this module and, for the
shared introspector, by allowing the types through
ReflectionIntrospectionPolicy.
- Since:
- 5.2.0
-
ClassDescriptionAn
ExecutableMethodover theBeanMethodof a bean introspection, for a specification API that names a method by itsMethod: the arguments and the metadata are the ones the introspection carries, generated or reflective, and the method itself is the one the caller gave.What a method hierarchy declares: the method as a caller names it, what its declaring type itself declares, the declarations it overrides or implements, and the three merged into one view.One declaration of a method by one type of a hierarchy.The runtime counterpart of the annotation mappers, transformers and remappers of the annotation processors, for the metadataReflectionAnnotationsbuilds reflectively.BuildsAnnotationMetadataandAnnotationValues from the annotations read reflectively from anAnnotatedElement, in the shape the annotation processors give the metadata they generate at compilation time.BuildsArguments from the types read reflectively from parameters, fields, return types and type hierarchies, in the shape the annotation processors give the arguments they generate: the raw type, the type arguments recursively, the type variables asGenericPlaceholders, and the annotations of the element and of every level of its type as metadata built byReflectionAnnotations.ABeanConstructorover aConstructor, with the arguments and the annotation metadata a generated constructor would have.ABeanDefinitionover aClass, with the injection points, the executable methods and the life cycle a generated definition would have, to register a type the annotation processors never saw with abean contextat runtime.Builds the definition of a type, reading the class for what the builder does not set.ABeanIntrospectionover aClass, with the properties, the constructor and the methods a generated introspection would have.TheBeanIntrospectionFallbackdescribing reflectively the types the shared introspector has no generated introspection for, whenReflectionIntrospectionPolicyallows them.ABeanIntrospectorthat serves the generated introspections of another introspector first, and aReflectionBeanIntrospectionfor a type that has none.AnExecutableMethodover aMethod, with the arguments, the return type and the annotation metadata a generated executable method would have.The adapters of a specification API that names an executable by itsMethodorConstructor: the generated metadata is used when it describes the named executable, and the reflective metadata of this package otherwise - the one reflective step an API defined onjava.lang.reflectimposes.Applies the "micronaut.introspection.allow-reflection" property of the application configuration to theReflectionIntrospectionPolicywhen the context starts, and takes it back when the context closes, leaving the patterns of the contexts that are still running.The types matching a set of patterns, and theIntrospectedmembers the shared introspector describes them with.An annotation the properties carrying it are indexed by.The types the sharedBeanIntrospectormay describe reflectively when it has no generated introspection for them.The patterns oneReflectionIntrospectionPolicy.configure(Collection)call contributed, which closing takes back.What a reflective introspection knows beyond theBeanIntrospectioncontract: every constructor of the type, and the members a property is made of, each with the class declaring it and its own metadata.A member of a property, with the field or method reflection read it from.A generatedBeanIntrospectioncompleted by a reflective one: the properties, the constructor and the methods the processor generated are served as generated, and the executables it left out — the methods that are not@Executable, the other constructors — come from reflection.