diff --git a/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java b/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java index 8919b8c8c..f54b7b369 100644 --- a/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java +++ b/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java @@ -29,8 +29,8 @@ import org.springframework.data.util.NullnessMethodInvocationValidator; * @author Christoph Strobl * @since 2.0 * @see org.jspecify.annotations.NonNull + * @see org.springframework.core.Nullness * @see org.springframework.data.util.ReflectionUtils#isNullable(org.springframework.core.MethodParameter) - * @see org.springframework.data.util.NullableUtils */ public class MethodInvocationValidator extends NullnessMethodInvocationValidator { diff --git a/src/main/java/org/springframework/data/util/NullableUtils.java b/src/main/java/org/springframework/data/util/NullableUtils.java index e1df0a16f..27adf2c27 100644 --- a/src/main/java/org/springframework/data/util/NullableUtils.java +++ b/src/main/java/org/springframework/data/util/NullableUtils.java @@ -42,18 +42,18 @@ import org.springframework.util.MultiValueMap; /** * Utility methods to introspect nullability rules declared in packages, classes and methods. *

- * Nullability rules are declared using {@link NonNullApi}, {@link Nullable}, and JSR-305 + * Nullability rules are declared using {@code Nullable}, {@code NonNullApi}, and JSR-305 * {@code javax.annotation.Nonnull} annotations. By default (no annotation use), a package and its types are considered * allowing {@literal null} values in return values and method parameters. Nullability rules are expressed by annotating - * a package with a JSR-305 meta annotation such as Spring's {@link NonNullApi}. All types of the package inherit the - * package rule. Subpackages do not inherit nullability rules and must be annotated themself. + * a package with a JSR-305 meta annotation such as Spring's {@code NonNullApi}. All types of the package inherit the + * package rule. Subpackages do not inherit nullability rules and must be annotated themselves. * *

  * @org.jspecify.annotations.NullMarked
  * package com.example;
  * 
* - * {@link Nullable} selectively permits {@literal null} values for method return values or method parameters by + * {@code Nullable} selectively permits {@literal null} values for method return values or method parameters by * annotating the method respectively the parameters: * *
@@ -77,7 +77,10 @@ import org.springframework.util.MultiValueMap;
  * @since 2.0
  * @see NonNullApi
  * @see Nullable
+ * @deprecated since 4.0 in favor of {@link org.springframework.core.Nullness} fully using JSpecify annotations instead
+ *             of Spring Framework's own {@literal @Nullable} and {@literal @NonNullApi} annotations.
  */
+@Deprecated(since = "4.0")
 public abstract class NullableUtils {
 
 	private static final String NON_NULL_CLASS_NAME = "javax.annotation.Nonnull";
diff --git a/src/main/java/org/springframework/data/util/NullnessMethodInvocationValidator.java b/src/main/java/org/springframework/data/util/NullnessMethodInvocationValidator.java
index 0f7d082a6..3a6e65ee5 100644
--- a/src/main/java/org/springframework/data/util/NullnessMethodInvocationValidator.java
+++ b/src/main/java/org/springframework/data/util/NullnessMethodInvocationValidator.java
@@ -46,8 +46,8 @@ import org.springframework.util.ObjectUtils;
  * @author Christoph Strobl
  * @since 3.5
  * @see org.jspecify.annotations.NonNull
+ * @see org.springframework.core.Nullness
  * @see ReflectionUtils#isNullable(MethodParameter)
- * @see NullableUtils
  * @link Nullness
  */
 public class NullnessMethodInvocationValidator implements MethodInterceptor {
@@ -63,14 +63,12 @@ public class NullnessMethodInvocationValidator implements MethodInterceptor {
 	 */
 	public static boolean supports(Class type) {
 
-		if (type.getPackage() != null
-				&& type.getPackage().isAnnotationPresent(NullMarked.class)) {
+		if (type.getPackage() != null && type.getPackage().isAnnotationPresent(NullMarked.class)) {
 			return true;
 		}
 
 		return KotlinDetector.isKotlinPresent() && KotlinReflectionUtils.isSupportedKotlinClass(type)
-				|| NullableUtils.isNonNull(type, ElementType.METHOD)
-				|| NullableUtils.isNonNull(type, ElementType.PARAMETER);
+				|| NullableUtils.isNonNull(type, ElementType.METHOD) || NullableUtils.isNonNull(type, ElementType.PARAMETER);
 	}
 
 	@Override
@@ -195,17 +193,19 @@ public class NullnessMethodInvocationValidator implements MethodInterceptor {
 
 		/**
 		 * Check method return nullability
+		 *
 		 * @param method
 		 * @return
 		 */
 		private static boolean allowNullableReturn(@Nullable Method method) {
 
-			if(method == null) {
+			if (method == null) {
 				return false;
 			}
 
-			KFunction function = KotlinDetector.isKotlinType(method.getDeclaringClass()) ?
-				KotlinReflectionUtils.findKotlinFunction(method) : null;
+			KFunction function = KotlinDetector.isKotlinType(method.getDeclaringClass())
+					? KotlinReflectionUtils.findKotlinFunction(method)
+					: null;
 			return function != null && function.getReturnType().isMarkedNullable();
 		}
 
diff --git a/src/main/kotlin/org/springframework/data/repository/kotlin/package-info.java b/src/main/kotlin/org/springframework/data/repository/kotlin/package-info.java
index a8b71d97a..8b553eb66 100644
--- a/src/main/kotlin/org/springframework/data/repository/kotlin/package-info.java
+++ b/src/main/kotlin/org/springframework/data/repository/kotlin/package-info.java
@@ -1,5 +1,5 @@
 /**
  * Support for Kotlin Coroutines repositories.
  */
-@org.springframework.lang.NonNullApi
+@org.jspecify.annotations.NullMarked
 package org.springframework.data.repository.kotlin;