Switch to JSpecify annotations

This commit updates the whole Spring Framework codebase to use JSpecify
annotations instead of Spring null-safety annotations with JSR 305
semantics.

JSpecify provides signficant enhancements such as properly defined
specifications, a canonical dependency with no split-package issue,
better tooling, better Kotlin integration and the capability to specify
generic type, array and varargs element null-safety. Generic type
null-safety is not defined by this commit yet and will be specified
later.

A key difference is that Spring null-safety annotations, following
JSR 305 semantics, apply to fields, parameters and return values,
while JSpecify annotations apply to type usages. That's why this
commit moves nullability annotations closer to the type for fields
and return values.

See gh-28797
This commit is contained in:
Sébastien Deleuze
2024-12-03 15:22:37 +01:00
parent fcb8aed03f
commit bc5d771a06
3459 changed files with 14118 additions and 22059 deletions

View File

@@ -1,9 +1,7 @@
/**
* AspectJ-based dependency injection support.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.beans.factory.aspectj;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* AspectJ-based caching support.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.cache.aspectj;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -3,9 +3,7 @@
* {@link org.springframework.beans.factory.annotation.Configurable @Configurable}
* annotation.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.context.annotation.aspectj;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* AspectJ-based scheduling support.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.scheduling.aspectj;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;

View File

@@ -1,9 +1,7 @@
/**
* AspectJ-based transaction management support.
*/
@NonNullApi
@NonNullFields
@NullMarked
package org.springframework.transaction.aspectj;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.jspecify.annotations.NullMarked;