- 
                Notifications
    
You must be signed in to change notification settings  - Fork 38.8k
 
Description
Sam Brannen opened SPR-14069 and commented
Status Quo
For the most post, transitive implicit aliases for annotation attribute overrides configured via @AliasFor work. However, I have detected a corner case that fails.
Failing Example
Given the following three annotations, if an attempt is made to look up a merged @ContextConfig annotation via AnnotatedElementUtils (e.g., using getMergedAnnotation() or findMergedAnnotation()) on an element annotated with @TransitiveImplicitAliasesContextConfig then the look up will fail with an AnnotationConfigurationException stating something similar to the following:
attribute 'value' and its alias 'locations' are declared with values of [{}] and [{test.groovy}], but only one is permitted.
If the value attribute in ImplicitAliasesContextConfig declares attribute = "locations" via @AliasFor, the code then works as expected. Thus, there is obviously a bug in the lookup mechanism for names of overridden attributes in conjunction with transitive implicit aliases.
@Retention(RetentionPolicy.RUNTIME)
@interface ContextConfig {
	@AliasFor(attribute = "locations")
	String[] value() default {};
	@AliasFor(attribute = "value")
	String[] locations() default {};
	Class<?>[] classes() default {};
}@ContextConfig
@Retention(RetentionPolicy.RUNTIME)
@interface ImplicitAliasesContextConfig {
	@AliasFor(annotation = ContextConfig.class, attribute = "locations")
	String[] groovyScripts() default {};
	@AliasFor(annotation = ContextConfig.class, attribute = "locations")
	String[] xmlFiles() default {};
	// intentionally omitted: attribute = "locations"
	@AliasFor(annotation = ContextConfig.class)
	String[] locations() default {};
	// intentionally omitted: attribute = "locations"
	@AliasFor(annotation = ContextConfig.class)
	String[] value() default {};
}@ImplicitAliasesContextConfig
@Retention(RetentionPolicy.RUNTIME)
@interface TransitiveImplicitAliasesContextConfig {
	@AliasFor(annotation = ImplicitAliasesContextConfig.class, attribute = "xmlFiles")
	String[] xml() default {};
	@AliasFor(annotation = ImplicitAliasesContextConfig.class, attribute = "groovyScripts")
	String[] groovy() default {};
}Deliverables
-  Determine why the aforementioned example fails and fix the bug.
- See 
TODOinAnnotatedElementUtilsTests. 
 - See 
 
Affects: 4.2.2