diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 8250a3dacdda717f982715e890e5421085b1ad13..237385466876d3f8c1d2f7106f4d100f0f7d0533 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -240,52 +240,68 @@ public abstract class AnnotationUtils { } /** - * Find a single {@link Annotation} of {@code annotationType} from the supplied - * {@link Class}, traversing its annotations, interfaces, and superclasses if - * no annotation can be found on the given class itself. + * Find a single {@link Annotation} of {@code annotationType} on the + * supplied {@link Class}, traversing its interfaces, annotations, and + * superclasses if the annotation is not present on the given class + * itself. *
This method explicitly handles class-level annotations which are not - * declared as {@link java.lang.annotation.Inherited inherited} as well - * as meta-annotations and annotations on interfaces. + * declared as {@link java.lang.annotation.Inherited inherited} as well + * as meta-annotations and annotations on interfaces. *
The algorithm operates as follows: *
Note: in this context, the term recursively means that the search
+ * process continues by returning to step #1 with the current interface,
+ * annotation, or superclass as the class to look for annotations on.
* @param clazz the class to look for annotations on
- * @param annotationType the annotation class to look for
- * @return the annotation found, or {@code null} if none found
+ * @param annotationType the type of annotation to look for
+ * @return the annotation if found, or {@code null} if not found
*/
public static A findAnnotation(Class> clazz, Class annotationType) {
+ return findAnnotation(clazz, annotationType, new HashSet