You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce support for synthesizing AnnotationAttributes into an annotation [SPR-13067] #17659
This issue picks up where #16137 and #16138 left off, with the primary goal of providing support for synthesizing an annotation from merged AnnotationAttributes like those returned from the getAnnotationAttributes(\*) and findAnnotationAttributes(\*) methods in AnnotatedElementUtils.
Spring Framework 4.2 RC1 introduced support for synthesizing an
annotation from an existing annotation in order to provide additional
functionality above and beyond that provided by Java. Specifically,
such synthesized annotations provide support for @AliasFor semantics.
As luck would have it, the same principle can be used to synthesize an
annotation from any map of attributes, and in particular, from an
instance of AnnotationAttributes.
The following highlight the major changes in this commit toward
achieving this goal.
Introduced AnnotationAttributeExtractor abstraction and refactored
SynthesizedAnnotationInvocationHandler to delegate to an
AnnotationAttributeExtractor.
Extracted code from SynthesizedAnnotationInvocationHandler into new
AbstractAliasAwareAnnotationAttributeExtractor and
DefaultAnnotationAttributeExtractor implementation classes.
Introduced MapAnnotationAttributeExtractor for synthesizing an
annotation that is backed by a map or AnnotationAttributes instance.
Introduced a variant of synthesizeAnnotation() in AnnotationUtils
that accepts a map.
Introduced findAnnotation(*) methods in AnnotatedElementUtils that
synthesize merged AnnotationAttributes back into an annotation of the
target type.
The following classes have been refactored to use the new support for
synthesizing AnnotationAttributes back into an annotation.
ApplicationListenerMethodAdapter
TestAnnotationUtils
AbstractTestContextBootstrapper
ActiveProfilesUtils
ContextLoaderUtils
DefaultActiveProfilesResolver
DirtiesContextTestExecutionListener
TestPropertySourceAttributes
TestPropertySourceUtils
TransactionalTestExecutionListener
MetaAnnotationUtils
MvcUriComponentsBuilder
RequestMappingHandlerMapping
In addition, this commit also includes changes to ensure that arrays
returned by synthesized annotations are properly cloned first.
Activity
spring-projects-issues commentedon May 25, 2015
Sam Brannen commented
The "holy grail of annotation processing" is in the air... ;)
I have pushed a working prototype for this issue to a #17659 feature branch.
Fee free to follow along or make comments!
spring-projects-issues commentedon May 28, 2015
Sam Brannen commented
Update: the latest and greatest has been pushed to #17659.
Feedback is welcome!
spring-projects-issues commentedon May 28, 2015
Sam Brannen commented
This has been implemented as described in the comments for GitHub commit e30c9b2: