Revisit nullability annotations
This commit introduces the following changes. 1) It adds a new Spring @NonNull annotation which allows to apply @NonNullApi semantic on a specific element, like @Nullable does. Combined with @Nullable, it allows partial null-safety support when package granularity is too broad. 2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order to be used on generic type arguments (SPR-15942). 3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore since it is not supported yet (applicability for such use case is controversial and need to be discussed). 4) @NonNullApi does not apply to ElementType.FIELD anymore since in a lot of use cases (private, protected) it is not part for the public API + its usage should remain opt-in. A dedicated @NonNullFields annotation has been added in order to set fields default to non-nullable. 5) Updated Javadoc and reference documentation. Issue: SPR-15756
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
* Support package for beans-style handling of Java 5 annotations.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Support package for annotation-driven bean configuration.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPI interfaces and configuration-related convenience classes for bean factories.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* by Rod Johnson (Wrox, 2002).
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Support infrastructure for bean definition parsing.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Support package for the Java 6 ServiceLoader facility.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.serviceloader;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Contains abstract base classes for {@code BeanFactory} implementations.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Foundation for aspect-driven bean configuration.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* including a standard "spring-beans" XSD.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* by Rod Johnson (Wrox, 2002).
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* specific binding processes, as they are localized or the like.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.propertyeditors;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* such as utility classes for sorting and holding lists of beans.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.beans.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
|
||||
Reference in New Issue
Block a user