diff --git a/spring-core/src/main/java/org/springframework/lang/NonNull.java b/spring-core/src/main/java/org/springframework/lang/NonNull.java index c98400968144..6a0d6568329e 100644 --- a/spring-core/src/main/java/org/springframework/lang/NonNull.java +++ b/spring-core/src/main/java/org/springframework/lang/NonNull.java @@ -31,9 +31,9 @@ *

Leverages JSR-305 meta-annotations to indicate nullability in Java to common * tools with JSR-305 support and used by Kotlin to infer nullability of Spring API. * - *

Should be used at the parameter, return value, and field level. Method - * overrides should repeat parent {@code @NonNull} annotations unless they behave - * differently. + *

Should be used at the parameter, return value, field, and type-use level, including + * generics and other type usages. Method overrides should repeat parent {@code @NonNull} + * annotations unless they behave differently. * *

Use {@code @NonNullApi} (scope = parameters + return values) and/or {@code @NonNullFields} * (scope = fields) to set the default behavior to non-nullable in order to avoid annotating @@ -47,7 +47,7 @@ * @see NonNullFields * @see Nullable */ -@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) +@Target({ElementType.TYPE_USE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull