Skip to content

Commit fe41cd6

Browse files
committed
Merge branch '6.2.x'
2 parents e64243d + 9e45178 commit fe41cd6

File tree

4 files changed

+47
-33
lines changed

4 files changed

+47
-33
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@
3737
*
3838
* <p>{@code AnnotatedElementUtils} defines the public API for Spring's
3939
* meta-annotation programming model with support for <em>annotation attribute
40-
* overrides</em>. If you do not need support for annotation attribute
41-
* overrides, consider using {@link AnnotationUtils} instead.
40+
* overrides</em> and {@link AliasFor @AliasFor}. Note, however, that
41+
* {@code AnnotatedElementUtils} is effectively a facade for the
42+
* {@link MergedAnnotations} API. For fine-grained support consider using the
43+
* {@code MergedAnnotations} API directly. If you do not need support for
44+
* annotation attribute overrides, {@code @AliasFor}, or merged annotations,
45+
* consider using {@link AnnotationUtils} instead.
4246
*
4347
* <p>Note that the features of this class are not provided by the JDK's
4448
* introspection facilities themselves.
@@ -88,6 +92,7 @@
8892
* @since 4.0
8993
* @see AliasFor
9094
* @see AnnotationAttributes
95+
* @see MergedAnnotations
9196
* @see AnnotationUtils
9297
* @see BridgeMethodResolver
9398
*/

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

+18-18
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* <h3>Terminology</h3>
6262
* The terms <em>directly present</em>, <em>indirectly present</em>, and
6363
* <em>present</em> have the same meanings as defined in the class-level
64-
* javadoc for {@link AnnotatedElement} (in Java 8).
64+
* javadoc for {@link AnnotatedElement}.
6565
*
6666
* <p>An annotation is <em>meta-present</em> on an element if the annotation
6767
* is declared as a meta-annotation on some other annotation which is
@@ -74,7 +74,8 @@
7474
* provide support for finding annotations used as meta-annotations. Consult the
7575
* javadoc for each method in this class for details. For fine-grained support for
7676
* meta-annotations with <em>attribute overrides</em> in <em>composed annotations</em>,
77-
* consider using {@link AnnotatedElementUtils}'s more specific methods instead.
77+
* consider using the {@link MergedAnnotations} API directly or the more specific
78+
* methods in {@link AnnotatedElementUtils} instead.
7879
*
7980
* <h3>Attribute Aliases</h3>
8081
* <p>All public methods in this class that return annotations, arrays of
@@ -98,6 +99,7 @@
9899
* @since 2.0
99100
* @see AliasFor
100101
* @see AnnotationAttributes
102+
* @see MergedAnnotations
101103
* @see AnnotatedElementUtils
102104
* @see BridgeMethodResolver
103105
* @see java.lang.reflect.AnnotatedElement#getAnnotations()
@@ -303,11 +305,11 @@ private static <A extends Annotation> boolean isSingleLevelPresent(MergedAnnotat
303305
* {@code annotationType} from the supplied {@link AnnotatedElement}, where
304306
* such annotations are either <em>present</em>, <em>indirectly present</em>,
305307
* or <em>meta-present</em> on the element.
306-
* <p>This method mimics the functionality of Java 8's
308+
* <p>This method mimics the functionality of
307309
* {@link java.lang.reflect.AnnotatedElement#getAnnotationsByType(Class)}
308310
* with support for automatic detection of a <em>container annotation</em>
309-
* declared via @{@link java.lang.annotation.Repeatable} (when running on
310-
* Java 8 or higher) and with additional support for meta-annotations.
311+
* declared via {@link java.lang.annotation.Repeatable @Repeatable} and with
312+
* additional support for meta-annotations.
311313
* <p>Handles both single annotations and annotations nested within a
312314
* <em>container annotation</em>.
313315
* <p>Correctly handles <em>bridge methods</em> generated by the
@@ -338,7 +340,7 @@ public static <A extends Annotation> Set<A> getRepeatableAnnotations(AnnotatedEl
338340
* {@code annotationType} from the supplied {@link AnnotatedElement}, where
339341
* such annotations are either <em>present</em>, <em>indirectly present</em>,
340342
* or <em>meta-present</em> on the element.
341-
* <p>This method mimics the functionality of Java 8's
343+
* <p>This method mimics the functionality
342344
* {@link java.lang.reflect.AnnotatedElement#getAnnotationsByType(Class)}
343345
* with additional support for meta-annotations.
344346
* <p>Handles both single annotations and annotations nested within a
@@ -349,10 +351,9 @@ public static <A extends Annotation> Set<A> getRepeatableAnnotations(AnnotatedEl
349351
* <em>present</em> on the supplied element.
350352
* @param annotatedElement the element to look for annotations on
351353
* @param annotationType the annotation type to look for
352-
* @param containerAnnotationType the type of the container that holds
353-
* the annotations; may be {@code null} if a container is not supported
354-
* or if it should be looked up via @{@link java.lang.annotation.Repeatable}
355-
* when running on Java 8 or higher
354+
* @param containerAnnotationType the type of the container that holds the
355+
* annotations; may be {@code null} if a container is not supported or if it
356+
* should be looked up via {@link java.lang.annotation.Repeatable @Repeatable}
356357
* @return the annotations found or an empty set (never {@code null})
357358
* @since 4.2
358359
* @see #getRepeatableAnnotations(AnnotatedElement, Class)
@@ -384,11 +385,11 @@ public static <A extends Annotation> Set<A> getRepeatableAnnotations(AnnotatedEl
384385
* of {@code annotationType} from the supplied {@link AnnotatedElement},
385386
* where such annotations are either <em>directly present</em>,
386387
* <em>indirectly present</em>, or <em>meta-present</em> on the element.
387-
* <p>This method mimics the functionality of Java 8's
388+
* <p>This method mimics the functionality of
388389
* {@link java.lang.reflect.AnnotatedElement#getDeclaredAnnotationsByType(Class)}
389390
* with support for automatic detection of a <em>container annotation</em>
390-
* declared via @{@link java.lang.annotation.Repeatable} (when running on
391-
* Java 8 or higher) and with additional support for meta-annotations.
391+
* declared via {@link java.lang.annotation.Repeatable @Repeatable} and with
392+
* additional support for meta-annotations.
392393
* <p>Handles both single annotations and annotations nested within a
393394
* <em>container annotation</em>.
394395
* <p>Correctly handles <em>bridge methods</em> generated by the
@@ -420,7 +421,7 @@ public static <A extends Annotation> Set<A> getDeclaredRepeatableAnnotations(Ann
420421
* of {@code annotationType} from the supplied {@link AnnotatedElement},
421422
* where such annotations are either <em>directly present</em>,
422423
* <em>indirectly present</em>, or <em>meta-present</em> on the element.
423-
* <p>This method mimics the functionality of Java 8's
424+
* <p>This method mimics the functionality of
424425
* {@link java.lang.reflect.AnnotatedElement#getDeclaredAnnotationsByType(Class)}
425426
* with additional support for meta-annotations.
426427
* <p>Handles both single annotations and annotations nested within a
@@ -431,10 +432,9 @@ public static <A extends Annotation> Set<A> getDeclaredRepeatableAnnotations(Ann
431432
* <em>present</em> on the supplied element.
432433
* @param annotatedElement the element to look for annotations on
433434
* @param annotationType the annotation type to look for
434-
* @param containerAnnotationType the type of the container that holds
435-
* the annotations; may be {@code null} if a container is not supported
436-
* or if it should be looked up via @{@link java.lang.annotation.Repeatable}
437-
* when running on Java 8 or higher
435+
* @param containerAnnotationType the type of the container that holds the
436+
* annotations; may be {@code null} if a container is not supported or if it
437+
* should be looked up via {@link java.lang.annotation.Repeatable @Repeatable}
438438
* @return the annotations found or an empty set (never {@code null})
439439
* @since 4.2
440440
* @see #getRepeatableAnnotations(AnnotatedElement, Class)

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
3838
* <ul>
3939
* <li>Explicit and Implicit {@link AliasFor @AliasFor} declarations on one or
4040
* more attributes within the annotation</li>
41-
* <li>Explicit {@link AliasFor @AliasFor} declarations for a meta-annotation</li>
41+
* <li>Explicit {@code @AliasFor} declarations for a meta-annotation</li>
4242
* <li>Convention based attribute aliases for a meta-annotation</li>
4343
* <li>From a meta-annotation declaration</li>
4444
* </ul>
@@ -141,6 +141,9 @@
141141
* @see MergedAnnotationCollectors
142142
* @see MergedAnnotationPredicates
143143
* @see MergedAnnotationSelectors
144+
* @see AliasFor
145+
* @see AnnotationUtils
146+
* @see AnnotatedElementUtils
144147
*/
145148
public interface MergedAnnotations extends Iterable<MergedAnnotation<Annotation>> {
146149

@@ -561,6 +564,7 @@ private Search(SearchStrategy searchStrategy) {
561564
* @see #withRepeatableContainers(RepeatableContainers)
562565
* @see #withAnnotationFilter(AnnotationFilter)
563566
* @see #from(AnnotatedElement)
567+
* @see org.springframework.test.context.TestContextAnnotationUtils#searchEnclosingClass(Class)
564568
*/
565569
public Search withEnclosingClasses(Predicate<Class<?>> searchEnclosingClass) {
566570
Assert.notNull(searchEnclosingClass, "Predicate must not be null");

spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,19 +44,20 @@
4444

4545
/**
4646
* {@code TestContextAnnotationUtils} is a collection of utility methods that
47-
* complements the standard support already available in {@link AnnotationUtils}
48-
* and {@link AnnotatedElementUtils}, while transparently honoring
49-
* {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
47+
* complements the standard support already available in {@link MergedAnnotations},
48+
* {@link AnnotationUtils}, and {@link AnnotatedElementUtils}, while transparently
49+
* honoring {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
5050
*
5151
* <p>Mainly for internal use within the <em>Spring TestContext Framework</em>
5252
* but also supported for third-party integrations with the TestContext framework.
5353
*
54-
* <p>Whereas {@code AnnotationUtils} and {@code AnnotatedElementUtils} provide
55-
* utilities for <em>getting</em> or <em>finding</em> annotations,
56-
* {@code TestContextAnnotationUtils} goes a step further by providing support
57-
* for determining the <em>root class</em> on which an annotation is declared,
58-
* either directly or indirectly via a <em>composed annotation</em>. This
59-
* additional information is encapsulated in an {@link AnnotationDescriptor}.
54+
* <p>Whereas {@code MergedAnnotations}, {@code AnnotationUtils} and
55+
* {@code AnnotatedElementUtils} provide utilities for <em>getting</em> or
56+
* <em>finding</em> annotations, {@code TestContextAnnotationUtils} goes a step
57+
* further by providing support for determining the <em>root class</em> on which
58+
* an annotation is declared, either directly or indirectly via a
59+
* <em>composed annotation</em>. This additional information is encapsulated in
60+
* an {@link AnnotationDescriptor}.
6061
*
6162
* <p>The additional information provided by an {@code AnnotationDescriptor} is
6263
* required by the <em>Spring TestContext Framework</em> in order to be able to
@@ -68,7 +69,11 @@
6869
* example, {@link ContextConfiguration#inheritLocations}.
6970
*
7071
* @author Sam Brannen
71-
* @since 5.3, though originally since 4.0 as {@code org.springframework.test.util.MetaAnnotationUtils}
72+
* @since 5.3
73+
* @see MergedAnnotations
74+
* @see MergedAnnotations.Search
75+
* @see MergedAnnotations.Search#withEnclosingClasses(Predicate)
76+
* @see #searchEnclosingClass(Class)
7277
* @see AnnotationUtils
7378
* @see AnnotatedElementUtils
7479
* @see AnnotationDescriptor

0 commit comments

Comments
 (0)