diff --git a/documentation/src/docs/asciidoc/user-guide/extensions.adoc b/documentation/src/docs/asciidoc/user-guide/extensions.adoc index 7ccbf96c4df2..11185fe05019 100644 --- a/documentation/src/docs/asciidoc/user-guide/extensions.adoc +++ b/documentation/src/docs/asciidoc/user-guide/extensions.adoc @@ -871,6 +871,9 @@ 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. +NOTE: The `isAnnotated()` methods do not find repeatable annotations. To check for repeatable annotations, +use one of the `findRepeatableAnnotations()` methods and verify that the returned list is not empty. + NOTE: See also: <> [[extensions-supported-utilities-classes]] diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AnnotatedElementContext.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AnnotatedElementContext.java index 0c12f33c1765..19ad328fb7a4 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AnnotatedElementContext.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AnnotatedElementContext.java @@ -55,6 +55,10 @@ public interface AnnotatedElementContext { * present or meta-present on the {@link AnnotatedElement} for * this context. * + *

Note: 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. + * *

WARNING

*

Favor the use of this method over directly invoking * {@link AnnotatedElement#isAnnotationPresent(Class)} due to a bug in {@code javac} diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java index 2ef21ac9d0c3..3066916f3503 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java @@ -54,6 +54,10 @@ private AnnotationSupport() { * present or meta-present on the supplied optional * {@code element}. * + *

Note: 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 empty * @param annotationType the annotation type to search for; never {@code null} @@ -61,6 +65,7 @@ private AnnotationSupport() { * @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 element, @@ -74,12 +79,17 @@ public static boolean isAnnotated(Optional element, * present or meta-present on the supplied * {@code element}. * + *

Note: This method does not find repeatable annotations. + * To check for repeatable annotations, use {@link #findRepeatableAnnotations(AnnotatedElement, 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(AnnotatedElement, Class) */ public static boolean isAnnotated(AnnotatedElement element, Class annotationType) { return AnnotationUtils.isAnnotated(element, annotationType);