-
Couldn't load subscription status.
- Fork 38.8k
Description
Dave Syer opened SPR-13448 and commented
AnnotatedElementUtils is now available for processing merged (overridden) attributes from meta-annotated custom annotations, but Spring doesn't use it uniformly (because of performance concerns). The one that bit me was an ImportBeanDefinitionRegistrar where the annotation was a custom one and the AnnotationMetadata that is passed in does not contain the overridden/inherited values.
The reason, it turns out, is that StandardAnnotationMetadata, while it uses AnnotatedElementUtils, explicitly chooses not to get the overridden attributes by invoking getAllAnnotationAttributes() instead of getMergedAnnotationAttributes() (and this is all that is directly available to the ImportBeanDefinitionRegistrar).
Maybe there's a way to address the performance concerns and use the deeper AnnotatedElementUtils.getMergedAnnotationAttributes() utility method(s) only if the user signals that the annotation needs to be processed this way -- for example, by introducing an annotation such as @Mergeable (or an explicit @AliasFor on the attribute).
See also: #18020
Affects: 4.2 GA
Issue Links:
- Use AnnotatedElementUtils instead of AnnotationUtils wherever feasible [SPR-13440] #18020 Use AnnotatedElementUtils instead of AnnotationUtils wherever feasible
- @AliasFor is needed on all attributes (even if they have the same name as the "parent") [SPR-13554] #18130
@AliasForis needed on all attributes (even if they have the same name as the "parent") - Support @ResponseStatus as a merged composed annotation [SPR-13441] #18021 Support
@ResponseStatusas a merged composed annotation
0 votes, 6 watchers