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 27974078fa34..879db7b3a7fa 100644 --- a/spring-core/src/main/java/org/springframework/lang/NonNull.java +++ b/spring-core/src/main/java/org/springframework/lang/NonNull.java @@ -30,15 +30,13 @@ * 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 generic type argument, parameter, return value, and field level. + *

Should be used at parameter, return value, and field level. * Methods 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 - * your whole codebase with {@code @NonNull}. No default retricted to generic type argument - * is possible ({@code ElementType.TYPE_USE} scope is too wide) so each generic type argument - * needs to be annotated with @code @NonNull}. + * your whole codebase with {@code @NonNull}. * * @author Sebastien Deleuze * @author Juergen Hoeller @@ -47,7 +45,7 @@ * @see NonNullFields * @see Nullable */ -@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE, ElementType.FIELD}) +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull diff --git a/spring-core/src/main/java/org/springframework/lang/NonNullApi.java b/spring-core/src/main/java/org/springframework/lang/NonNullApi.java index 050abe0c1567..c216e8b8f604 100644 --- a/spring-core/src/main/java/org/springframework/lang/NonNullApi.java +++ b/spring-core/src/main/java/org/springframework/lang/NonNullApi.java @@ -30,15 +30,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 package level in association with {@link Nullable} * annotations at parameter and return value level. * - *

This annotation does not define nullability of generic type arguments, because - * {@code @TypeQualifierDefault(ElementType.TYPE_USE)} scope would be too broad. - * As a consequence, each API generic type argument should be annotated - * with {@link Nullable} or {@link NonNull} to specify their nullability. - * * @author Sebastien Deleuze * @author Juergen Hoeller * @since 5.0 diff --git a/spring-core/src/main/java/org/springframework/lang/NonNullFields.java b/spring-core/src/main/java/org/springframework/lang/NonNullFields.java index 213ec2878162..fb1b3f3940dc 100644 --- a/spring-core/src/main/java/org/springframework/lang/NonNullFields.java +++ b/spring-core/src/main/java/org/springframework/lang/NonNullFields.java @@ -34,11 +34,6 @@ *

Should be used at package level in association with {@link Nullable} * annotations at field level. * - *

This annotation does not define nullability of generic type arguments, because - * {@code @TypeQualifierDefault(ElementType.TYPE_USE)} scope would be too broad. - * As a consequence, each field generic type argument should be annotated - * with {@link Nullable} or {@link NonNull} to specify their nullability. - * * @author Sebastien Deleuze * @since 5.0 * @see NonNullFields diff --git a/spring-core/src/main/java/org/springframework/lang/Nullable.java b/spring-core/src/main/java/org/springframework/lang/Nullable.java index 7db3b9cbfed4..3d176e760b00 100644 --- a/spring-core/src/main/java/org/springframework/lang/Nullable.java +++ b/spring-core/src/main/java/org/springframework/lang/Nullable.java @@ -30,7 +30,7 @@ * some circumstance. 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 generic type argument, parameter, return value, and field level. + *

Should be used at parameter, return value, and field level. * Methods overrides should repeat parent {@code @Nullable} annotations unless they behave * differently. * @@ -44,7 +44,7 @@ * @see NonNullFields * @see NonNull */ -@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE, ElementType.FIELD}) +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull(when = When.MAYBE) diff --git a/src/docs/asciidoc/kotlin.adoc b/src/docs/asciidoc/kotlin.adoc index 13749efba9b0..ef74094cee9f 100644 --- a/src/docs/asciidoc/kotlin.adoc +++ b/src/docs/asciidoc/kotlin.adoc @@ -111,12 +111,8 @@ the default behavior in an upcoming release of Kotlin. [NOTE] ==== -Make sure to https://github.com/sdeleuze/spring-kotlin-functional/blob/2d6ac07adfc2b8f25e91681dbb2b58a1c6cdf9a7/build.gradle.kts#L57[include JSR-305 JAR] -until Kotlin 1.1.5 is released (it will fix https://youtrack.jetbrains.com/issue/KT-19419[KT-19419]). - -Support for generic type arguments, varargs and array elements is still work in progress, -see https://youtrack.jetbrains.com/issue/KT-19592[KT-19592] and -https://youtrack.jetbrains.com/issue/IDEA-153093[IDEA-153093] for up-to-date +Generic type arguments, varargs and array elements nullability are not yet supported, +see https://github.com/Kotlin/KEEP/issues/79[this dicussion] for up-to-date informations. ====