autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java
index c9e0db6ad8..8cd218573f 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.config;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.core.AttributeAccessor;
+import org.springframework.lang.Nullable;
/**
* A BeanDefinition describes a bean instance, which has property values,
@@ -84,11 +85,12 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
/**
* Set the name of the parent definition of this bean definition, if any.
*/
- void setParentName(String parentName);
+ void setParentName(@Nullable String parentName);
/**
* Return the name of the parent definition of this bean definition, if any.
*/
+ @Nullable
String getParentName();
/**
@@ -126,6 +128,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
* Return the name of the current target scope for this bean,
* or {@code null} if not known yet.
*/
+ @Nullable
String getScope();
/**
@@ -188,6 +191,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
/**
* Return the factory bean name, if any.
*/
+ @Nullable
String getFactoryBeanName();
/**
@@ -203,6 +207,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
/**
* Return a factory method, if any.
*/
+ @Nullable
String getFactoryMethodName();
/**
@@ -260,6 +265,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
* Return a description of the resource that this bean definition
* came from (for the purpose of showing context in case of errors).
*/
+ @Nullable
String getResourceDescription();
/**
@@ -268,6 +274,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
* Note that this method returns the immediate originator. Iterate through the
* originator chain to find the original BeanDefinition as defined by the user.
*/
+ @Nullable
BeanDefinition getOriginatingBeanDefinition();
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java
index 6e10d7573a..9379a831af 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.config;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -60,7 +61,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
* @param beanName the name of the bean, as specified for the bean definition
* @param aliases alias names for the bean, or {@code null} if none
*/
- public BeanDefinitionHolder(BeanDefinition beanDefinition, String beanName, String[] aliases) {
+ public BeanDefinitionHolder(BeanDefinition beanDefinition, String beanName, @Nullable String[] aliases) {
Assert.notNull(beanDefinition, "BeanDefinition must not be null");
Assert.notNull(beanName, "Bean name must not be null");
this.beanDefinition = beanDefinition;
@@ -101,6 +102,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
* Return the alias names for the bean, as specified directly for the bean definition.
* @return the array of alias names, or {@code null} if none
*/
+ @Nullable
public String[] getAliases() {
return this.aliases;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java
index 1da52f0e20..2f0a5bead2 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.config;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -51,6 +52,7 @@ public class BeanExpressionContext {
(this.scope != null && this.scope.resolveContextualObject(key) != null));
}
+ @Nullable
public Object getObject(String key) {
if (this.beanFactory.containsBean(key)) {
return this.beanFactory.getBean(key);
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java
index ce61b2de93..7121908cf0 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import org.springframework.beans.BeansException;
+import org.springframework.lang.Nullable;
/**
* Factory hook that allows for custom modification of new bean instances,
@@ -54,6 +55,7 @@ public interface BeanPostProcessor {
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
*/
+ @Nullable
default Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@@ -79,6 +81,7 @@ public interface BeanPostProcessor {
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
* @see org.springframework.beans.factory.FactoryBean
*/
+ @Nullable
default Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java
index 302deec58f..35f5b860b4 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.core.convert.ConversionService;
+import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver;
/**
@@ -85,7 +86,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* @param beanClassLoader the class loader to use,
* or {@code null} to suggest the default class loader
*/
- void setBeanClassLoader(ClassLoader beanClassLoader);
+ void setBeanClassLoader(@Nullable ClassLoader beanClassLoader);
/**
* Return this factory's class loader for loading bean classes.
@@ -108,6 +109,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* if any.
* @since 2.5
*/
+ @Nullable
ClassLoader getTempClassLoader();
/**
@@ -151,6 +153,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* Return the associated ConversionService, if any.
* @since 3.0
*/
+ @Nullable
ConversionService getConversionService();
/**
@@ -222,6 +225,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* @return the resolved value (may be the original value as-is)
* @since 3.0
*/
+ @Nullable
String resolveEmbeddedValue(String value);
/**
@@ -265,6 +269,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* @return the registered Scope implementation, or {@code null} if none
* @see #registerScope
*/
+ @Nullable
Scope getRegisteredScope(String scopeName);
/**
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
index dfffe28e36..87efa185e5 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
@@ -26,6 +26,7 @@ import java.util.Set;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -146,7 +147,8 @@ public class ConstructorArgumentValues {
* untyped values only)
* @return the ValueHolder for the argument, or {@code null} if none set
*/
- public ValueHolder getIndexedArgumentValue(int index, Class> requiredType) {
+ @Nullable
+ public ValueHolder getIndexedArgumentValue(int index, @Nullable Class> requiredType) {
return getIndexedArgumentValue(index, requiredType, null);
}
@@ -159,7 +161,8 @@ public class ConstructorArgumentValues {
* unnamed values only, or empty String to match any name)
* @return the ValueHolder for the argument, or {@code null} if none set
*/
- public ValueHolder getIndexedArgumentValue(int index, Class> requiredType, String requiredName) {
+ @Nullable
+ public ValueHolder getIndexedArgumentValue(int index, @Nullable Class> requiredType, @Nullable String requiredName) {
Assert.isTrue(index >= 0, "Index must not be negative");
ValueHolder valueHolder = this.indexedArgumentValues.get(index);
if (valueHolder != null &&
@@ -247,6 +250,7 @@ public class ConstructorArgumentValues {
* @param requiredType the type to match
* @return the ValueHolder for the argument, or {@code null} if none set
*/
+ @Nullable
public ValueHolder getGenericArgumentValue(Class> requiredType) {
return getGenericArgumentValue(requiredType, null, null);
}
@@ -257,6 +261,7 @@ public class ConstructorArgumentValues {
* @param requiredName the name to match
* @return the ValueHolder for the argument, or {@code null} if none set
*/
+ @Nullable
public ValueHolder getGenericArgumentValue(Class> requiredType, String requiredName) {
return getGenericArgumentValue(requiredType, requiredName, null);
}
@@ -273,7 +278,8 @@ public class ConstructorArgumentValues {
* in the current resolution process and should therefore not be returned again
* @return the ValueHolder for the argument, or {@code null} if none found
*/
- public ValueHolder getGenericArgumentValue(Class> requiredType, String requiredName, Set usedValueHolders) {
+ @Nullable
+ public ValueHolder getGenericArgumentValue(@Nullable Class> requiredType, @Nullable String requiredName, Set usedValueHolders) {
for (ValueHolder valueHolder : this.genericArgumentValues) {
if (usedValueHolders != null && usedValueHolders.contains(valueHolder)) {
continue;
@@ -312,6 +318,7 @@ public class ConstructorArgumentValues {
* @param requiredType the parameter type to match
* @return the ValueHolder for the argument, or {@code null} if none set
*/
+ @Nullable
public ValueHolder getArgumentValue(int index, Class> requiredType) {
return getArgumentValue(index, requiredType, null, null);
}
@@ -324,6 +331,7 @@ public class ConstructorArgumentValues {
* @param requiredName the parameter name to match
* @return the ValueHolder for the argument, or {@code null} if none set
*/
+ @Nullable
public ValueHolder getArgumentValue(int index, Class> requiredType, String requiredName) {
return getArgumentValue(index, requiredType, requiredName, null);
}
@@ -342,7 +350,8 @@ public class ConstructorArgumentValues {
* in case of multiple generic argument values of the same type)
* @return the ValueHolder for the argument, or {@code null} if none set
*/
- public ValueHolder getArgumentValue(int index, Class> requiredType, String requiredName, Set usedValueHolders) {
+ @Nullable
+ public ValueHolder getArgumentValue(int index, @Nullable Class> requiredType, @Nullable String requiredName, Set usedValueHolders) {
Assert.isTrue(index >= 0, "Index must not be negative");
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
if (valueHolder == null) {
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java
index 7d19ad3481..3b6288fc3b 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java
@@ -38,6 +38,7 @@ import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.ResolvableType;
+import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
/**
@@ -211,6 +212,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
* @throws BeansException in case of the not-unique scenario being fatal
* @since 4.3
*/
+ @Nullable
public Object resolveNotUnique(Class> type, Map matchingBeans) throws BeansException {
throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
}
@@ -227,6 +229,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
* @throws BeansException if the shortcut could not be obtained
* @since 4.3.1
*/
+ @Nullable
public Object resolveShortcut(BeanFactory beanFactory) throws BeansException {
return null;
}
@@ -321,7 +324,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
* this point; it just allows discovery to happen when the application calls
* {@link #getDependencyName()} (if ever).
*/
- public void initParameterNameDiscovery(ParameterNameDiscoverer parameterNameDiscoverer) {
+ public void initParameterNameDiscovery(@Nullable ParameterNameDiscoverer parameterNameDiscoverer) {
if (this.methodParameter != null) {
this.methodParameter.initParameterNameDiscovery(parameterNameDiscoverer);
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java
index 595707fe76..ca664f40ad 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java
@@ -20,6 +20,7 @@ import java.beans.PropertyDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
+import org.springframework.lang.Nullable;
/**
* Subinterface of {@link BeanPostProcessor} that adds a before-instantiation callback,
@@ -67,6 +68,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#hasBeanClass
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName
*/
+ @Nullable
default Object postProcessBeforeInstantiation(Class> beanClass, String beanName) throws BeansException {
return null;
}
@@ -109,6 +111,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.MutablePropertyValues
*/
+ @Nullable
default PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/NamedBeanHolder.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/NamedBeanHolder.java
index 04e5e39a37..0c43b97c31 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/NamedBeanHolder.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/NamedBeanHolder.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import org.springframework.beans.factory.NamedBean;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -56,6 +57,7 @@ public class NamedBeanHolder implements NamedBean {
/**
* Return the corresponding bean instance (can be {@code null}).
*/
+ @Nullable
public T getBeanInstance() {
return this.beanInstance;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java
index f7223a9a1c..91ec753eee 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver;
/**
@@ -140,7 +141,7 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
* special character should be processed as a value separator.
* The default is {@value #DEFAULT_VALUE_SEPARATOR}.
*/
- public void setValueSeparator(String valueSeparator) {
+ public void setValueSeparator(@Nullable String valueSeparator) {
this.valueSeparator = valueSeparator;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PreferencesPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PreferencesPlaceholderConfigurer.java
index c8de04029b..89f41a126d 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PreferencesPlaceholderConfigurer.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PreferencesPlaceholderConfigurer.java
@@ -22,6 +22,7 @@ import java.util.prefs.Preferences;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.lang.Nullable;
/**
* Subclass of PropertyPlaceholderConfigurer that supports JDK 1.4's
@@ -113,6 +114,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu
* @param preferences the Preferences to resolve against
* @return the value for the placeholder, or {@code null} if none found
*/
+ @Nullable
protected String resolvePlaceholder(String path, String key, Preferences preferences) {
if (path != null) {
// Do not create the node if it does not exist...
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
index 39129c60a7..6a21805217 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
import org.springframework.core.Constants;
import org.springframework.core.SpringProperties;
import org.springframework.core.env.AbstractEnvironment;
+import org.springframework.lang.Nullable;
import org.springframework.util.PropertyPlaceholderHelper;
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
import org.springframework.util.StringValueResolver;
@@ -179,6 +180,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
* @return the resolved value, of {@code null} if none
* @see #setSystemPropertiesMode
*/
+ @Nullable
protected String resolvePlaceholder(String placeholder, Properties props) {
return props.getProperty(placeholder);
}
@@ -192,6 +194,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
* @see System#getProperty(String)
* @see System#getenv(String)
*/
+ @Nullable
protected String resolveSystemProperty(String key) {
try {
String value = System.getProperty(key);
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java
index 4e313c7919..aebaf3135f 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.lang.Nullable;
/**
* Strategy interface used by a {@link ConfigurableBeanFactory},
@@ -88,6 +89,7 @@ public interface Scope {
* @throws IllegalStateException if the underlying scope is not currently active
* @see #registerDestructionCallback
*/
+ @Nullable
Object remove(String name);
/**
@@ -128,6 +130,7 @@ public interface Scope {
* @return the corresponding object, or {@code null} if none found
* @throws IllegalStateException if the underlying scope is not currently active
*/
+ @Nullable
Object resolveContextualObject(String key);
/**
@@ -145,6 +148,7 @@ public interface Scope {
* conversation ID for the current scope
* @throws IllegalStateException if the underlying scope is not currently active
*/
+ @Nullable
String getConversationId();
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java
index e2188050f1..f610c8d815 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java
@@ -16,6 +16,8 @@
package org.springframework.beans.factory.config;
+import org.springframework.lang.Nullable;
+
/**
* Interface that defines a registry for shared bean instances.
* Can be implemented by {@link org.springframework.beans.factory.BeanFactory}
@@ -68,6 +70,7 @@ public interface SingletonBeanRegistry {
* @return the registered singleton object, or {@code null} if none found
* @see ConfigurableListableBeanFactory#getBeanDefinition
*/
+ @Nullable
Object getSingleton(String beanName);
/**
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java
index 61a0a8f666..5d52fae329 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.config;
import java.lang.reflect.Constructor;
import org.springframework.beans.BeansException;
+import org.springframework.lang.Nullable;
/**
* Extension of the {@link InstantiationAwareBeanPostProcessor} interface,
@@ -45,6 +46,7 @@ public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationA
* @return the type of the bean, or {@code null} if not predictable
* @throws org.springframework.beans.BeansException in case of errors
*/
+ @Nullable
default Class> predictBeanType(Class> beanClass, String beanName) throws BeansException {
return null;
}
@@ -57,6 +59,7 @@ public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationA
* @return the candidate constructors, or {@code null} if none specified
* @throws org.springframework.beans.BeansException in case of errors
*/
+ @Nullable
default Constructor>[] determineCandidateConstructors(Class> beanClass, String beanName)
throws BeansException {
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java
index 0a6f73e350..1454ae8d59 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import org.springframework.beans.BeanMetadataElement;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -153,6 +154,7 @@ public class TypedStringValue implements BeanMetadataElement {
* @return the resolved type to convert to
* @throws ClassNotFoundException if the type cannot be resolved
*/
+ @Nullable
public Class> resolveTargetType(ClassLoader classLoader) throws ClassNotFoundException {
if (this.targetType == null) {
return null;
@@ -179,13 +181,14 @@ public class TypedStringValue implements BeanMetadataElement {
/**
* Set the type name as actually specified for this particular value, if any.
*/
- public void setSpecifiedTypeName(String specifiedTypeName) {
+ public void setSpecifiedTypeName(@Nullable String specifiedTypeName) {
this.specifiedTypeName = specifiedTypeName;
}
/**
* Return the type name as actually specified for this particular value, if any.
*/
+ @Nullable
public String getSpecifiedTypeName() {
return this.specifiedTypeName;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/package-info.java
index 81e5ad6668..1bfd372f34 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/package-info.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/package-info.java
@@ -1,4 +1,7 @@
/**
* SPI interfaces and configuration-related convenience classes for bean factories.
*/
+@NonNullApi
package org.springframework.beans.factory.config;
+
+import org.springframework.lang.NonNullApi;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java
index 0834baa9e5..10b3a3a3cf 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java
@@ -9,4 +9,7 @@
* Expert One-On-One J2EE Design and Development
* by Rod Johnson (Wrox, 2002).
*/
+@NonNullApi
package org.springframework.beans.factory;
+
+import org.springframework.lang.NonNullApi;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java
index 06d037c5d7..e87d3c5ca9 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing;
import org.springframework.beans.BeanMetadataElement;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -50,7 +51,7 @@ public class AliasDefinition implements BeanMetadataElement {
* @param alias the alias registered for the bean
* @param source the source object (may be {@code null})
*/
- public AliasDefinition(String beanName, String alias, Object source) {
+ public AliasDefinition(String beanName, String alias, @Nullable Object source) {
Assert.notNull(beanName, "Bean name must not be null");
Assert.notNull(alias, "Alias must not be null");
this.beanName = beanName;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java
index fe309eeb3c..c5b1c54a39 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java
@@ -24,6 +24,7 @@ import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.lang.Nullable;
/**
* ComponentDefinition based on a standard BeanDefinition, exposing the given bean
@@ -56,7 +57,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
* @param beanName the name of the bean
* @param aliases alias names for the bean, or {@code null} if none
*/
- public BeanComponentDefinition(BeanDefinition beanDefinition, String beanName, String[] aliases) {
+ public BeanComponentDefinition(BeanDefinition beanDefinition, String beanName, @Nullable String[] aliases) {
super(beanDefinition, beanName, aliases);
findInnerBeanDefinitionsAndBeanReferences(beanDefinition);
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java
index 859d611f14..dbafd3fddc 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java
@@ -19,6 +19,8 @@ package org.springframework.beans.factory.parsing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.lang.Nullable;
+
/**
* Simple {@link ProblemReporter} implementation that exhibits fail-fast
* behavior when errors are encountered.
@@ -45,7 +47,7 @@ public class FailFastProblemReporter implements ProblemReporter {
* the name of the instance class will be used.
* @param logger the {@link Log logger} that is to be used to report warnings
*/
- public void setLogger(Log logger) {
+ public void setLogger(@Nullable Log logger) {
this.logger = (logger != null ? logger : LogFactory.getLog(getClass()));
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java
index 85eea69610..fdab1473e0 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.parsing;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.core.io.Resource;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -49,7 +50,7 @@ public class ImportDefinition implements BeanMetadataElement {
* @param importedResource the location of the imported resource
* @param source the source object (may be {@code null})
*/
- public ImportDefinition(String importedResource, Object source) {
+ public ImportDefinition(String importedResource, @Nullable Object source) {
this(importedResource, null, source);
}
@@ -58,7 +59,7 @@ public class ImportDefinition implements BeanMetadataElement {
* @param importedResource the location of the imported resource
* @param source the source object (may be {@code null})
*/
- public ImportDefinition(String importedResource, Resource[] actualResources, Object source) {
+ public ImportDefinition(String importedResource, Resource[] actualResources, @Nullable Object source) {
Assert.notNull(importedResource, "Imported resource must not be null");
this.importedResource = importedResource;
this.actualResources = actualResources;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java
index 9ff54665c7..23747a032e 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing;
import org.springframework.core.io.Resource;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -53,7 +54,7 @@ public class Location {
* @param source the actual location within the associated resource
* (may be {@code null})
*/
- public Location(Resource resource, Object source) {
+ public Location(Resource resource, @Nullable Object source) {
Assert.notNull(resource, "Resource must not be null");
this.resource = resource;
this.source = source;
@@ -73,6 +74,7 @@ public class Location {
* See the {@link Location class level javadoc for this class} for examples
* of what the actual type of the returned object may be.
*/
+ @Nullable
public Object getSource() {
return this.source;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java
index 2edb93890d..7e3ff72e52 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java
@@ -18,6 +18,8 @@ package org.springframework.beans.factory.parsing;
import java.util.Stack;
+import org.springframework.lang.Nullable;
+
/**
* Simple {@link Stack}-based structure for tracking the logical position during
* a parsing process. {@link Entry entries} are added to the stack at
@@ -78,6 +80,7 @@ public final class ParseState {
* Return the {@link Entry} currently at the top of the {@link Stack} or
* {@code null} if the {@link Stack} is empty.
*/
+ @Nullable
public Entry peek() {
return this.state.empty() ? null : this.state.peek();
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java
index c317d5f935..a8150dc2f0 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.parsing;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -66,7 +67,7 @@ public class Problem {
* @param parseState the {@link ParseState} at the time of the error
* @param location the location within a bean configuration source that triggered the error
*/
- public Problem(String message, Location location, ParseState parseState, Throwable rootCause) {
+ public Problem(String message, Location location, ParseState parseState, @Nullable Throwable rootCause) {
Assert.notNull(message, "Message must not be null");
Assert.notNull(location, "Location must not be null");
this.message = message;
@@ -102,6 +103,7 @@ public class Problem {
/**
* Get the {@link ParseState} at the time of the error (may be {@code null}).
*/
+ @Nullable
public ParseState getParseState() {
return this.parseState;
}
@@ -109,6 +111,7 @@ public class Problem {
/**
* Get the underlying exception that caused the error (may be {@code null}).
*/
+ @Nullable
public Throwable getRootCause() {
return this.rootCause;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java
index ed9248fdf2..a403c5c229 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing;
import org.springframework.core.io.Resource;
+import org.springframework.lang.Nullable;
/**
* Simple strategy allowing tools to control how source metadata is attached
@@ -44,6 +45,7 @@ public interface SourceExtractor {
* (may be {@code null})
* @return the source metadata object to store (may be {@code null})
*/
- Object extractSource(Object sourceCandidate, Resource definingResource);
+ @Nullable
+ Object extractSource(Object sourceCandidate, @Nullable Resource definingResource);
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/package-info.java
index eae9057e60..ab87c9bc5d 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/package-info.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/package-info.java
@@ -1,4 +1,7 @@
/**
* Support infrastructure for bean definition parsing.
*/
+@NonNullApi
package org.springframework.beans.factory.parsing;
+
+import org.springframework.lang.NonNullApi;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/package-info.java
index 793df3de8b..71ae523912 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/package-info.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/package-info.java
@@ -1,4 +1,7 @@
/**
* Support package for the Java 6 ServiceLoader facility.
*/
+@NonNullApi
package org.springframework.beans.factory.serviceloader;
+
+import org.springframework.lang.NonNullApi;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
index b306901faa..811b914044 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
@@ -77,6 +77,7 @@ import org.springframework.core.NamedThreadLocal;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.ResolvableType;
+import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@@ -175,7 +176,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* Create a new AbstractAutowireCapableBeanFactory with the given parent.
* @param parentBeanFactory parent bean factory, or {@code null} if none
*/
- public AbstractAutowireCapableBeanFactory(BeanFactory parentBeanFactory) {
+ public AbstractAutowireCapableBeanFactory(@Nullable BeanFactory parentBeanFactory) {
this();
setParentBeanFactory(parentBeanFactory);
}
@@ -654,6 +655,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* (also signals that the returned {@code Class} will never be exposed to application code)
* @return the type for the bean if determinable, or {@code null} otherwise
*/
+ @Nullable
protected Class> determineTargetType(String beanName, RootBeanDefinition mbd, Class>... typesToMatch) {
Class> targetType = mbd.getTargetType();
if (targetType == null) {
@@ -681,6 +683,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the type for the bean if determinable, or {@code null} otherwise
* @see #createBean
*/
+ @Nullable
protected Class> getTypeForFactoryMethod(String beanName, RootBeanDefinition mbd, Class>... typesToMatch) {
ResolvableType cachedReturnType = mbd.factoryMethodReturnType;
if (cachedReturnType != null) {
@@ -858,6 +861,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param factoryMethodName the name of the factory method
* @return the common {@code FactoryBean} object type, or {@code null} if none
*/
+ @Nullable
private Class> getTypeForFactoryBeanFromMethod(Class> beanClass, final String factoryMethodName) {
class Holder { Class> value = null; }
final Holder objectType = new Holder();
@@ -893,6 +897,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param bean the raw bean instance
* @return the object to expose as bean reference
*/
+ @Nullable
protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd, Object bean) {
Object exposedObject = bean;
if (bean != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
@@ -922,6 +927,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
+ @Nullable
private FactoryBean> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
synchronized (getSingletonMutex()) {
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
@@ -965,6 +971,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
+ @Nullable
private FactoryBean> getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
if (isPrototypeCurrentlyInCreation(beanName)) {
return null;
@@ -1021,6 +1028,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param mbd the bean definition for the bean
* @return the shortcut-determined bean instance, or {@code null} if none
*/
+ @Nullable
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
Object bean = null;
if (!Boolean.FALSE.equals(mbd.beforeInstantiationResolved)) {
@@ -1050,6 +1058,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the bean object to use instead of a default instance of the target bean, or {@code null}
* @see InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation
*/
+ @Nullable
protected Object applyBeanPostProcessorsBeforeInstantiation(Class> beanClass, String beanName) {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof InstantiationAwareBeanPostProcessor) {
@@ -1181,6 +1190,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors
*/
+ @Nullable
protected Constructor>[] determineConstructorsFromBeanPostProcessors(Class> beanClass, String beanName)
throws BeansException {
@@ -1241,7 +1251,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #getBean(String, Object[])
*/
protected BeanWrapper instantiateUsingFactoryMethod(
- String beanName, RootBeanDefinition mbd, Object[] explicitArgs) {
+ String beanName, RootBeanDefinition mbd, @Nullable Object[] explicitArgs) {
return new ConstructorResolver(this).instantiateUsingFactoryMethod(beanName, mbd, explicitArgs);
}
@@ -1261,7 +1271,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return a BeanWrapper for the new instance
*/
protected BeanWrapper autowireConstructor(
- String beanName, RootBeanDefinition mbd, Constructor>[] ctors, Object[] explicitArgs) {
+ String beanName, RootBeanDefinition mbd, Constructor>[] ctors, @Nullable Object[] explicitArgs) {
return new ConstructorResolver(this).autowireConstructor(beanName, mbd, ctors, explicitArgs);
}
@@ -1674,7 +1684,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #invokeInitMethods
* @see #applyBeanPostProcessorsAfterInitialization
*/
- protected Object initializeBean(final String beanName, final Object bean, RootBeanDefinition mbd) {
+ protected Object initializeBean(final String beanName, final Object bean, @Nullable RootBeanDefinition mbd) {
if (System.getSecurityManager() != null) {
AccessController.doPrivileged(new PrivilegedAction