@@ -24,7 +24,7 @@ public class NoAutoStartUtil {
24
24
/**
25
25
* Returns true if the class of the object 'o' passed as parameter is *not*
26
26
* marked with the NoAutoStart annotation. Return true otherwise.
27
- *
27
+ *
28
28
* @param o
29
29
* @return true for classes not marked with the NoAutoStart annotation
30
30
*/
@@ -48,7 +48,6 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
48
48
* <p>The algorithm operates as follows:
49
49
* <ol>
50
50
* <li>Search for the annotation on the given class and return it if found.
51
- * <li>Recursively search through all annotations that the given class declares.
52
51
* <li>Recursively search through all interfaces that the given class declares.
53
52
* <li>Recursively search through the superclass hierarchy of the given class.
54
53
* </ol>
@@ -62,7 +61,7 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
62
61
private static <A extends Annotation > A findAnnotation (Class <?> clazz , Class <A > annotationType ) {
63
62
return findAnnotation (clazz , annotationType , new HashSet <>());
64
63
}
65
-
64
+
66
65
/**
67
66
* Perform the search algorithm for {@link #findAnnotation(Class, Class)},
68
67
* avoiding endless recursion by tracking which annotations have already
@@ -75,21 +74,12 @@ private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A>
75
74
@ SuppressWarnings ("unchecked" )
76
75
private static <A extends Annotation > A findAnnotation (Class <?> clazz , Class <A > annotationType , Set <Annotation > visited ) {
77
76
78
- Annotation [] anns = clazz .getDeclaredAnnotations ();
79
- for (Annotation ann : anns ) {
80
- if (ann .annotationType () == annotationType ) {
81
- return (A ) ann ;
82
- }
83
- }
84
- for (Annotation ann : anns ) {
85
- if (visited .add (ann )) {
86
- A annotation = findAnnotation (ann .annotationType (), annotationType , visited );
87
- if (annotation != null ) {
88
- return annotation ;
89
- }
90
- }
77
+ Annotation foundAnnotation = clazz .getAnnotation (annotationType );
78
+ if (foundAnnotation != null ) {
79
+ return (A ) foundAnnotation ;
91
80
}
92
81
82
+
93
83
for (Class <?> ifc : clazz .getInterfaces ()) {
94
84
A annotation = findAnnotation (ifc , annotationType , visited );
95
85
if (annotation != null ) {
0 commit comments