diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java index 30b31b7fc9a..af6986d8aee 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java @@ -16,6 +16,7 @@ package org.springframework.context.annotation; +import java.lang.annotation.Annotation; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; @@ -271,32 +272,26 @@ public abstract class AnnotationConfigUtils { } @Nullable - static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, Class annotationClass) { - return attributesFor(metadata, annotationClass.getName()); + static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, Class annotationType) { + return attributesFor(metadata, annotationType.getName()); } @Nullable - static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationClassName) { - return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName)); - } - - static Set attributesForRepeatable(AnnotationMetadata metadata, - Class containerClass, Class annotationClass) { - - return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName()); + static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationTypeName) { + return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationTypeName)); } @SuppressWarnings("unchecked") - static Set attributesForRepeatable( - AnnotationMetadata metadata, String containerClassName, String annotationClassName) { + static Set attributesForRepeatable(AnnotationMetadata metadata, + Class containerType, Class annotationType) { Set result = new LinkedHashSet<>(); - // Direct annotation present? - addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName)); + // Direct annotation present or meta-present? + addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationType.getName())); - // Container annotation present? - Map container = metadata.getAnnotationAttributes(containerClassName); + // Container annotation present or meta-present? + Map container = metadata.getAnnotationAttributes(containerType.getName()); if (container != null && container.containsKey("value")) { for (Map containedAttributes : (Map[]) container.get("value")) { addAttributesIfNotNull(result, containedAttributes); 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 f03b8fe7203..e55955b75d7 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 @@ -31,7 +31,8 @@ import org.springframework.util.MultiValueMap; /** * Defines access to the annotations of a specific type ({@link AnnotationMetadata class} * or {@link MethodMetadata method}), in a form that does not necessarily require - * class loading. + * class loading of the types being inspected. Note, however, that classes for + * encountered annotations will be loaded. * * @author Juergen Hoeller * @author Mark Fisher @@ -48,7 +49,7 @@ public interface AnnotatedTypeMetadata { /** * Get annotation details based on the direct annotations and meta-annotations * of the underlying element. - * @return merged annotations based on the direct annotations + * @return merged annotations based on the direct annotations and meta-annotations * @since 5.2 */ MergedAnnotations getAnnotations();