Skip to content

Commit

Permalink
Update document
Browse files Browse the repository at this point in the history
Issue: #4058
  • Loading branch information
YongGoose committed Jan 12, 2025
1 parent 28a261e commit c40c41a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions documentation/src/docs/asciidoc/user-guide/extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,12 @@ order to align with the behavior of the JUnit Platform and JUnit Jupiter.
These include methods to check whether an element is annotated or meta-annotated with a
particular annotation, to search for specific annotations, and to find annotated methods
and fields in a class or interface. Some of these methods search on implemented
interfaces and within class hierarchies to find annotations. Consult the Javadoc for
`{AnnotationSupport}` for further details.
interfaces and within class hierarchies to find annotations.

**Note:** `isAnnotated` method does not find repeatable annotations. To check for repeatable annotations,
use the `findRepeatableAnnotations` method and verify that the returned list is not empty.

Consult the Javadoc for `{AnnotationSupport}` for further details.

NOTE: See also: <<extensions-supported-utilities-search-semantics>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public interface AnnotatedElementContext {
* <em>present</em> or <em>meta-present</em> on the {@link AnnotatedElement} for
* this context.
*
* <p><strong>Note:</strong> This method does not find repeatable annotations.
* To check for repeatable annotations, use {@link #findRepeatableAnnotations(Class)}
* and verify that the returned list is not empty.
*
* <h4>WARNING</h4>
* <p>Favor the use of this method over directly invoking
* {@link AnnotatedElement#isAnnotationPresent(Class)} due to a bug in {@code javac}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ private AnnotationSupport() {
* <em>present</em> or <em>meta-present</em> on the supplied optional
* {@code element}.
*
* <p><strong>Note:</strong> This method does not find repeatable annotations.
* To check for repeatable annotations, use {@link #findRepeatableAnnotations(Optional, Class)}
* and verify that the returned list is not empty.
*
* @param element an {@link Optional} containing the element on which to
* search for the annotation; may be {@code null} or <em>empty</em>
* @param annotationType the annotation type to search for; never {@code null}
* @return {@code true} if the annotation is present or meta-present
* @since 1.3
* @see #isAnnotated(AnnotatedElement, Class)
* @see #findAnnotation(Optional, Class)
* @see #findRepeatableAnnotations(Optional, Class)
*/
@API(status = MAINTAINED, since = "1.3")
public static boolean isAnnotated(Optional<? extends AnnotatedElement> element,
Expand All @@ -74,12 +79,17 @@ public static boolean isAnnotated(Optional<? extends AnnotatedElement> element,
* <em>present</em> or <em>meta-present</em> on the supplied
* {@code element}.
*
* <p><strong>Note:</strong> This method does not find repeatable annotations.
* To check for repeatable annotations, use {@link #findRepeatableAnnotations(Optional, Class)}
* and verify that the returned list is not empty.
*
* @param element the element on which to search for the annotation; may be
* {@code null}
* @param annotationType the annotation type to search for; never {@code null}
* @return {@code true} if the annotation is present or meta-present
* @see #isAnnotated(Optional, Class)
* @see #findAnnotation(AnnotatedElement, Class)
* @see #findRepeatableAnnotations(Optional, Class)
*/
public static boolean isAnnotated(AnnotatedElement element, Class<? extends Annotation> annotationType) {
return AnnotationUtils.isAnnotated(element, annotationType);
Expand Down

0 comments on commit c40c41a

Please sign in to comment.