Support implicit attribute aliases with @AliasFor [SPR-13345] #17929
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Sam Brannen opened SPR-13345 and commented
Status Quo
Spring Framework 4.2 introduced support for explicit annotation attribute overrides in meta-annotations via
@AliasFor
.For example, the following
@SingleAliasConfig
works as expected.xmlFiles
functions as an attribute override forlocations
in@ContextConfiguration
.However, the following
@ImplicitAliasesConfig
does not work as expected. One would intuitively expect that any one ofxmlFiles
,groovyScripts
, orvalue
could be used as an attribute override forlocations
in@ContextConfiguration
, but at runtime, we don't actually know which one of the aliases will be ultimately used. In other words, one would expectxmlFiles
,groovyScripts
, andvalue
to be considered implicit aliases for each other.The reason is that the merge algorithm in
MergedAnnotationAttributesProcessor
inAnnotatedElementUtils
overwrites previous aliased values with subsequent aliased values, thereby letting the last one win -- which happens silently and is unintuitive.Similarly, the following declaration of transitive implicit aliases is not supported:
xml
andgroovy
will not be considered as implicit aliases for each other even though they override attributes in@ImplicitAliasesConfig
which are implicit aliases for each other.Deliverables
@AliasFor
for the same attribute in a meta-annotation.Affects: 4.2 GA
Reference URL: spring-projects/spring-boot#3635
Issue Links:
@AliasFor
potentially overrides attribute in wrong meta-annotation ("depends on")@AliasFor
("is depended on by")Referenced from: commits 2a6716d, d40a35b, 3eacb83
The text was updated successfully, but these errors were encountered: