From af853ead0784f9a1de60fc078a21143932625caf Mon Sep 17 00:00:00 2001 From: yongjunhong Date: Sun, 12 Jan 2025 20:06:10 +0900 Subject: [PATCH 1/6] Update document Issue: #4058 --- .../src/docs/asciidoc/user-guide/extensions.adoc | 8 ++++++-- .../jupiter/api/extension/AnnotatedElementContext.java | 4 ++++ .../platform/commons/support/AnnotationSupport.java | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/documentation/src/docs/asciidoc/user-guide/extensions.adoc b/documentation/src/docs/asciidoc/user-guide/extensions.adoc index 7ccbf96c4df2..52a257141ea8 100644 --- a/documentation/src/docs/asciidoc/user-guide/extensions.adoc +++ b/documentation/src/docs/asciidoc/user-guide/extensions.adoc @@ -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: <> 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..3cf768a009fc 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(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 annotationType) { return AnnotationUtils.isAnnotated(element, annotationType); From 0f81bc0c32dc31652fb3eb12c7e942e49e46d2dd Mon Sep 17 00:00:00 2001 From: Yongjun Hong Date: Mon, 13 Jan 2025 18:33:31 +0900 Subject: [PATCH 2/6] Update documentation/src/docs/asciidoc/user-guide/extensions.adoc Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com> --- documentation/src/docs/asciidoc/user-guide/extensions.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/docs/asciidoc/user-guide/extensions.adoc b/documentation/src/docs/asciidoc/user-guide/extensions.adoc index 52a257141ea8..d630190a1b12 100644 --- a/documentation/src/docs/asciidoc/user-guide/extensions.adoc +++ b/documentation/src/docs/asciidoc/user-guide/extensions.adoc @@ -871,7 +871,7 @@ and fields in a class or interface. Some of these methods search on implemented 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. +use one of the `findRepeatableAnnotations()` methods and verify that the returned list is not empty. Consult the Javadoc for `{AnnotationSupport}` for further details. From fc89410ec4d194725aaa08f89d7cb3ddb0f10e2e Mon Sep 17 00:00:00 2001 From: Yongjun Hong Date: Mon, 13 Jan 2025 18:33:38 +0900 Subject: [PATCH 3/6] Update junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com> --- .../org/junit/platform/commons/support/AnnotationSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3cf768a009fc..53cc6d410da7 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 @@ -89,7 +89,7 @@ public static boolean isAnnotated(Optional element, * @return {@code true} if the annotation is present or meta-present * @see #isAnnotated(Optional, Class) * @see #findAnnotation(AnnotatedElement, Class) - * @see #findRepeatableAnnotations(Optional, Class) + * @see #findRepeatableAnnotations(AnnotatedElement, Class) */ public static boolean isAnnotated(AnnotatedElement element, Class annotationType) { return AnnotationUtils.isAnnotated(element, annotationType); From 000e0dd3cd1f48885d49fcf5ef4e847122f6178a Mon Sep 17 00:00:00 2001 From: Yongjun Hong Date: Mon, 13 Jan 2025 18:33:56 +0900 Subject: [PATCH 4/6] Update junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com> --- .../org/junit/platform/commons/support/AnnotationSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 53cc6d410da7..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 @@ -80,7 +80,7 @@ public static boolean isAnnotated(Optional element, * {@code element}. * *

Note: This method does not find repeatable annotations. - * To check for repeatable annotations, use {@link #findRepeatableAnnotations(Optional, Class)} + * 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 From 1595ccb62366c7ad2b10ce3fdc539fce625010a8 Mon Sep 17 00:00:00 2001 From: yongjunhong Date: Mon, 13 Jan 2025 18:38:08 +0900 Subject: [PATCH 5/6] Apply comment Issue: #4058 --- documentation/src/docs/asciidoc/user-guide/extensions.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/docs/asciidoc/user-guide/extensions.adoc b/documentation/src/docs/asciidoc/user-guide/extensions.adoc index d630190a1b12..58cb1097a0f9 100644 --- a/documentation/src/docs/asciidoc/user-guide/extensions.adoc +++ b/documentation/src/docs/asciidoc/user-guide/extensions.adoc @@ -870,7 +870,7 @@ particular annotation, to search for specific annotations, and to find annotated and fields in a class or interface. Some of these methods search on implemented interfaces and within class hierarchies to find annotations. -**Note:** `isAnnotated` method does not find repeatable annotations. To check for repeatable annotations, +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. Consult the Javadoc for `{AnnotationSupport}` for further details. From bda5b1ac90a3eaaa359d041853eff77d26555760 Mon Sep 17 00:00:00 2001 From: yongjunhong Date: Wed, 15 Jan 2025 17:55:02 +0900 Subject: [PATCH 6/6] Apply comment Issue: #4058 --- documentation/src/docs/asciidoc/user-guide/extensions.adoc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/documentation/src/docs/asciidoc/user-guide/extensions.adoc b/documentation/src/docs/asciidoc/user-guide/extensions.adoc index 58cb1097a0f9..11185fe05019 100644 --- a/documentation/src/docs/asciidoc/user-guide/extensions.adoc +++ b/documentation/src/docs/asciidoc/user-guide/extensions.adoc @@ -868,13 +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. +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. -Consult the Javadoc for `{AnnotationSupport}` for further details. - NOTE: See also: <> [[extensions-supported-utilities-classes]]