Honor contract of @Repeatable in AnnotationUtils

This commit introduces a minor bug fix for getRepeatableAnnotations()
so that it fully complies with the contract of Java's
getAnnotationsByType() method with regard to repeatable annotations
declared on multiple superclasses.

Issue: SPR-13068
This commit is contained in:
Sam Brannen
2015-06-20 16:53:46 +02:00
parent de9f27872e
commit 594c330205
2 changed files with 30 additions and 0 deletions

View File

@@ -305,6 +305,13 @@ public abstract class AnnotationUtils {
return annotations;
}
if (annotatedElement instanceof Class) {
Class<?> superclass = ((Class<?>) annotatedElement).getSuperclass();
if ((superclass != null) && (Object.class != superclass)) {
return getRepeatableAnnotations(superclass, annotationType, containerAnnotationType);
}
}
return getRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType, false);
}