diff --git a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java index e55955b75d..a9db6d3d59 100644 --- a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java @@ -69,8 +69,10 @@ public interface AnnotatedTypeMetadata { /** * Retrieve the attributes of the annotation of the given type, if any (i.e. if - * defined on the underlying element, as direct annotation or meta-annotation), - * also taking attribute overrides on composed annotations into account. + * defined on the underlying element, as direct annotation or meta-annotation). + *

{@link org.springframework.core.annotation.AliasFor @AliasFor} semantics + * are fully supported, both within a single annotation and within annotation + * hierarchies. * @param annotationName the fully-qualified class name of the annotation * type to look for * @return a {@link Map} of attributes, with each annotation attribute name @@ -84,8 +86,10 @@ public interface AnnotatedTypeMetadata { /** * Retrieve the attributes of the annotation of the given type, if any (i.e. if - * defined on the underlying element, as direct annotation or meta-annotation), - * also taking attribute overrides on composed annotations into account. + * defined on the underlying element, as direct annotation or meta-annotation). + *

{@link org.springframework.core.annotation.AliasFor @AliasFor} semantics + * are fully supported, both within a single annotation and within annotation + * hierarchies. * @param annotationName the fully-qualified class name of the annotation * type to look for * @param classValuesAsString whether to convert class references to String diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 6fe46cab75..082b7ecb4d 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -214,8 +214,8 @@ class AnnotationMetadataTests { private void assertMetaAnnotationOverrides(AnnotationMetadata metadata) { AnnotationAttributes attributes = (AnnotationAttributes) metadata.getAnnotationAttributes( TestComponentScan.class.getName(), false); + assertThat(attributes.getStringArray("value")).containsExactly("org.example.componentscan"); assertThat(attributes.getStringArray("basePackages")).containsExactly("org.example.componentscan"); - assertThat(attributes.getStringArray("value")).isEmpty(); assertThat(attributes.getClassArray("basePackageClasses")).isEmpty(); } @@ -536,8 +536,10 @@ class AnnotationMetadataTests { @Target(ElementType.TYPE) public @interface TestComponentScan { + @AliasFor("basePackages") String[] value() default {}; + @AliasFor("value") String[] basePackages() default {}; Class[] basePackageClasses() default {};