File tree 2 files changed +9
-4
lines changed
spring-core/src/main/java/org/springframework/core
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ public static <T extends Annotation> T getAnnotation(AnnotatedElement annotatedE
127
127
/**
128
128
* Get all {@link Annotation Annotations} from the supplied Method, Constructor or Field.
129
129
* @param annotatedElement the Method, Constructor or Field to retrieve annotations from
130
- * @return the annotations found
130
+ * @return the annotations found, or {@code null} if not resolvable (e.g. because nested
131
+ * Class values in annotation attributes failed to resolve at runtime)
131
132
* @since 4.0.8
132
133
*/
133
134
public static Annotation [] getAnnotations (AnnotatedElement annotatedElement ) {
Original file line number Diff line number Diff line change 26
26
import org .springframework .core .annotation .AnnotationAttributes ;
27
27
import org .springframework .core .annotation .AnnotationUtils ;
28
28
import org .springframework .util .MultiValueMap ;
29
+ import org .springframework .util .ObjectUtils ;
29
30
30
31
/**
31
32
* ASM visitor which looks for the annotations defined on a class or method, including
@@ -72,9 +73,12 @@ public void doVisitEnd(Class<?> annotationClass) {
72
73
attributes .add (0 , this .attributes );
73
74
}
74
75
Set <String > metaAnnotationTypeNames = new LinkedHashSet <String >();
75
- for (Annotation metaAnnotation : AnnotationUtils .getAnnotations (annotationClass )) {
76
- if (!AnnotationUtils .isInJavaLangAnnotationPackage (metaAnnotation )) {
77
- recursivelyCollectMetaAnnotations (metaAnnotationTypeNames , metaAnnotation );
76
+ Annotation [] metaAnnotations = AnnotationUtils .getAnnotations (annotationClass );
77
+ if (!ObjectUtils .isEmpty (metaAnnotations )) {
78
+ for (Annotation metaAnnotation : metaAnnotations ) {
79
+ if (!AnnotationUtils .isInJavaLangAnnotationPackage (metaAnnotation )) {
80
+ recursivelyCollectMetaAnnotations (metaAnnotationTypeNames , metaAnnotation );
81
+ }
78
82
}
79
83
}
80
84
if (this .metaAnnotationMap != null ) {
You can’t perform that action at this time.
0 commit comments