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 27974078fa3..879db7b3a7f 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 @@ import javax.annotation.meta.TypeQualifierNickname; * 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 @@ import javax.annotation.meta.TypeQualifierNickname; * @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 050abe0c156..c216e8b8f60 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 @@ import javax.annotation.meta.TypeQualifierDefault; * 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 213ec287816..fb1b3f3940d 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 @@ import javax.annotation.meta.TypeQualifierDefault; *

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 7db3b9cbfed..3d176e760b0 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 @@ import javax.annotation.meta.When; * 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 @@ import javax.annotation.meta.When; * @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 13749efba9b..ef74094cee9 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. ====