Browse Source

Add warning to "enclosing classes" search strategy for MergedAnnotations

This commit adds a warning to the Javadoc for the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy in
MergedAnnotations with regard to the scope of the search
algorithm.

See gh-28079
pull/27953/head
Sam Brannen 4 years ago
parent
commit
29d98285be
  1. 10
      spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotations.java

10
spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotations.java

@ -483,12 +483,18 @@ public interface MergedAnnotations extends Iterable<MergedAnnotation<Annotation> @@ -483,12 +483,18 @@ public interface MergedAnnotations extends Iterable<MergedAnnotation<Annotation>
* <p>This strategy is similar to {@link #TYPE_HIERARCHY} except that
* {@linkplain Class#getEnclosingClass() enclosing classes} are also
* searched.
* <p>Superclass annotations do not need to be meta-annotated with
* {@link Inherited @Inherited}.
* <p>Superclass and enclosing class annotations do not need to be
* meta-annotated with {@link Inherited @Inherited}.
* <p>When searching a {@link Method} source, this strategy is identical
* to {@link #TYPE_HIERARCHY}.
* <p><strong>WARNING:</strong> This strategy searches recursively for
* annotations on the enclosing class for any source type, regardless
* whether the source type is an <em>inner class</em>, a {@code static}
* nested class, or a nested interface. Thus, it may find more annotations
* than you would expect.
*/
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
}
}

Loading…
Cancel
Save