Skip to content

Commit 29d9828

Browse files
committed
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
1 parent ad70878 commit 29d9828

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,18 @@ enum SearchStrategy {
483483
* <p>This strategy is similar to {@link #TYPE_HIERARCHY} except that
484484
* {@linkplain Class#getEnclosingClass() enclosing classes} are also
485485
* searched.
486-
* <p>Superclass annotations do not need to be meta-annotated with
487-
* {@link Inherited @Inherited}.
486+
* <p>Superclass and enclosing class annotations do not need to be
487+
* meta-annotated with {@link Inherited @Inherited}.
488488
* <p>When searching a {@link Method} source, this strategy is identical
489489
* to {@link #TYPE_HIERARCHY}.
490+
* <p><strong>WARNING:</strong> This strategy searches recursively for
491+
* annotations on the enclosing class for any source type, regardless
492+
* whether the source type is an <em>inner class</em>, a {@code static}
493+
* nested class, or a nested interface. Thus, it may find more annotations
494+
* than you would expect.
490495
*/
491496
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
497+
492498
}
493499

494500
}

0 commit comments

Comments
 (0)