diff --git a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java
deleted file mode 100644
index c0b22ad47d..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.annotation;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.springframework.beans.BeanWrapper;
-import org.springframework.beans.PropertyAccessorFactory;
-import org.springframework.lang.Nullable;
-import org.springframework.util.ReflectionUtils;
-import org.springframework.util.StringValueResolver;
-
-/**
- * General utility methods for working with annotations in JavaBeans style.
- *
- * @author Rob Harrop
- * @author Juergen Hoeller
- * @since 2.0
- * @deprecated as of 5.2, in favor of custom annotation attribute processing
- */
-@Deprecated
-public abstract class AnnotationBeanUtils {
-
- /**
- * Copy the properties of the supplied {@link Annotation} to the supplied target bean.
- * Any properties defined in {@code excludedProperties} will not be copied.
- * @param ann the annotation to copy from
- * @param bean the bean instance to copy to
- * @param excludedProperties the names of excluded properties, if any
- * @see org.springframework.beans.BeanWrapper
- */
- public static void copyPropertiesToBean(Annotation ann, Object bean, String... excludedProperties) {
- copyPropertiesToBean(ann, bean, null, excludedProperties);
- }
-
- /**
- * Copy the properties of the supplied {@link Annotation} to the supplied target bean.
- * Any properties defined in {@code excludedProperties} will not be copied.
- *
A specified value resolver may resolve placeholders in property values, for example.
- * @param ann the annotation to copy from
- * @param bean the bean instance to copy to
- * @param valueResolver a resolve to post-process String property values (may be {@code null})
- * @param excludedProperties the names of excluded properties, if any
- * @see org.springframework.beans.BeanWrapper
- */
- public static void copyPropertiesToBean(Annotation ann, Object bean, @Nullable StringValueResolver valueResolver,
- String... excludedProperties) {
-
- Set excluded = (excludedProperties.length == 0 ? Collections.emptySet() :
- new HashSet<>(Arrays.asList(excludedProperties)));
- Method[] annotationProperties = ann.annotationType().getDeclaredMethods();
- BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(bean);
- for (Method annotationProperty : annotationProperties) {
- String propertyName = annotationProperty.getName();
- if (!excluded.contains(propertyName) && bw.isWritableProperty(propertyName)) {
- Object value = ReflectionUtils.invokeMethod(annotationProperty, ann);
- if (valueResolver != null && value instanceof String) {
- value = valueResolver.resolveStringValue((String) value);
- }
- bw.setPropertyValue(propertyName, value);
- }
- }
- }
-
-}
diff --git a/spring-beans/src/main/java/org/springframework/beans/annotation/package-info.java b/spring-beans/src/main/java/org/springframework/beans/annotation/package-info.java
deleted file mode 100644
index d2667da96f..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/annotation/package-info.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * 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;
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
index 026790c361..f11dcce9a3 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
@@ -419,14 +419,6 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
return pvs;
}
- @Deprecated
- @Override
- public PropertyValues postProcessPropertyValues(
- PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
-
- return postProcessProperties(pvs, bean, beanName);
- }
-
/**
* 'Native' processing method for direct calls with an arbitrary target instance,
* resolving all of its fields and methods which are annotated with one of the
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java
deleted file mode 100644
index 4993cf25d4..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.factory.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a method (typically a JavaBean setter method) as being 'required': that is,
- * the setter method must be configured to be dependency-injected with a value.
- *
- *
Please do consult the javadoc for the {@link RequiredAnnotationBeanPostProcessor}
- * class (which, by default, checks for the presence of this annotation).
- *
- * @author Rob Harrop
- * @since 2.0
- * @see RequiredAnnotationBeanPostProcessor
- * @deprecated as of 5.1, in favor of using constructor injection for required settings
- * (or a custom {@link org.springframework.beans.factory.InitializingBean} implementation)
- */
-@Deprecated
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Required {
-
-}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java
deleted file mode 100644
index a4cf5f314c..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.factory.annotation;
-
-import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.springframework.beans.PropertyValues;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.BeanInitializationException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
-import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.core.Conventions;
-import org.springframework.core.Ordered;
-import org.springframework.core.PriorityOrdered;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-
-/**
- * {@link org.springframework.beans.factory.config.BeanPostProcessor} implementation
- * that enforces required JavaBean properties to have been configured.
- * Required bean properties are detected through a Java 5 annotation:
- * by default, Spring's {@link Required} annotation.
- *
- *
The motivation for the existence of this BeanPostProcessor is to allow
- * developers to annotate the setter properties of their own classes with an
- * arbitrary JDK 1.5 annotation to indicate that the container must check
- * for the configuration of a dependency injected value. This neatly pushes
- * responsibility for such checking onto the container (where it arguably belongs),
- * and obviates the need (in part) for a developer to code a method that
- * simply checks that all required properties have actually been set.
- *
- *
Please note that an 'init' method may still need to be implemented (and may
- * still be desirable), because all that this class does is enforcing that a
- * 'required' property has actually been configured with a value. It does
- * not check anything else... In particular, it does not check that a
- * configured value is not {@code null}.
- *
- *
Note: A default RequiredAnnotationBeanPostProcessor will be registered
- * by the "context:annotation-config" and "context:component-scan" XML tags.
- * Remove or turn off the default annotation configuration there if you intend
- * to specify a custom RequiredAnnotationBeanPostProcessor bean definition.
- *
- * @author Rob Harrop
- * @author Juergen Hoeller
- * @since 2.0
- * @see #setRequiredAnnotationType
- * @see Required
- * @deprecated as of 5.1, in favor of using constructor injection for required settings
- * (or a custom {@link org.springframework.beans.factory.InitializingBean} implementation)
- */
-@Deprecated
-public class RequiredAnnotationBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor,
- MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware {
-
- /**
- * Bean definition attribute that may indicate whether a given bean is supposed
- * to be skipped when performing this post-processor's required property check.
- * @see #shouldSkip
- */
- public static final String SKIP_REQUIRED_CHECK_ATTRIBUTE =
- Conventions.getQualifiedAttributeName(RequiredAnnotationBeanPostProcessor.class, "skipRequiredCheck");
-
-
- private Class extends Annotation> requiredAnnotationType = Required.class;
-
- private int order = Ordered.LOWEST_PRECEDENCE - 1;
-
- @Nullable
- private ConfigurableListableBeanFactory beanFactory;
-
- /**
- * Cache for validated bean names, skipping re-validation for the same bean.
- */
- private final Set validatedBeanNames = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
-
-
- /**
- * Set the 'required' annotation type, to be used on bean property
- * setter methods.
- *
The default required annotation type is the Spring-provided
- * {@link Required} annotation.
- *
This setter property exists so that developers can provide their own
- * (non-Spring-specific) annotation type to indicate that a property value
- * is required.
- */
- public void setRequiredAnnotationType(Class extends Annotation> requiredAnnotationType) {
- Assert.notNull(requiredAnnotationType, "'requiredAnnotationType' must not be null");
- this.requiredAnnotationType = requiredAnnotationType;
- }
-
- /**
- * Return the 'required' annotation type.
- */
- protected Class extends Annotation> getRequiredAnnotationType() {
- return this.requiredAnnotationType;
- }
-
- @Override
- public void setBeanFactory(BeanFactory beanFactory) {
- if (beanFactory instanceof ConfigurableListableBeanFactory) {
- this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
- }
- }
-
- public void setOrder(int order) {
- this.order = order;
- }
-
- @Override
- public int getOrder() {
- return this.order;
- }
-
-
- @Override
- public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class> beanType, String beanName) {
- }
-
- @Override
- public PropertyValues postProcessPropertyValues(
- PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
-
- if (!this.validatedBeanNames.contains(beanName)) {
- if (!shouldSkip(this.beanFactory, beanName)) {
- List invalidProperties = new ArrayList<>();
- for (PropertyDescriptor pd : pds) {
- if (isRequiredProperty(pd) && !pvs.contains(pd.getName())) {
- invalidProperties.add(pd.getName());
- }
- }
- if (!invalidProperties.isEmpty()) {
- throw new BeanInitializationException(buildExceptionMessage(invalidProperties, beanName));
- }
- }
- this.validatedBeanNames.add(beanName);
- }
- return pvs;
- }
-
- /**
- * Check whether the given bean definition is not subject to the annotation-based
- * required property check as performed by this post-processor.
- *
The default implementations check for the presence of the
- * {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any.
- * It also suggests skipping in case of a bean definition with a "factory-bean"
- * reference set, assuming that instance-based factories pre-populate the bean.
- * @param beanFactory the BeanFactory to check against
- * @param beanName the name of the bean to check against
- * @return {@code true} to skip the bean; {@code false} to process it
- */
- protected boolean shouldSkip(@Nullable ConfigurableListableBeanFactory beanFactory, String beanName) {
- if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) {
- return false;
- }
- BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
- if (beanDefinition.getFactoryBeanName() != null) {
- return true;
- }
- Object value = beanDefinition.getAttribute(SKIP_REQUIRED_CHECK_ATTRIBUTE);
- return (value != null && (Boolean.TRUE.equals(value) || Boolean.parseBoolean(value.toString())));
- }
-
- /**
- * Is the supplied property required to have a value (that is, to be dependency-injected)?
- *
This implementation looks for the existence of a
- * {@link #setRequiredAnnotationType "required" annotation}
- * on the supplied {@link PropertyDescriptor property}.
- * @param propertyDescriptor the target PropertyDescriptor (never {@code null})
- * @return {@code true} if the supplied property has been marked as being required;
- * {@code false} if not, or if the supplied property does not have a setter method
- */
- protected boolean isRequiredProperty(PropertyDescriptor propertyDescriptor) {
- Method setter = propertyDescriptor.getWriteMethod();
- return (setter != null && AnnotationUtils.getAnnotation(setter, getRequiredAnnotationType()) != null);
- }
-
- /**
- * Build an exception message for the given list of invalid properties.
- * @param invalidProperties the list of names of invalid properties
- * @param beanName the name of the bean
- * @return the exception message
- */
- private String buildExceptionMessage(List invalidProperties, String beanName) {
- int size = invalidProperties.size();
- StringBuilder sb = new StringBuilder();
- sb.append(size == 1 ? "Property" : "Properties");
- for (int i = 0; i < size; i++) {
- String propertyName = invalidProperties.get(i);
- if (i > 0) {
- if (i == (size - 1)) {
- sb.append(" and");
- }
- else {
- sb.append(',');
- }
- }
- sb.append(" '").append(propertyName).append('\'');
- }
- sb.append(size == 1 ? " is" : " are");
- sb.append(" required for bean '").append(beanName).append('\'');
- return sb.toString();
- }
-
-}
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 c16db6ca73..c808a81541 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -220,26 +220,6 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
}
- /**
- * Resolve the specified not-unique scenario: by default,
- * throwing a {@link NoUniqueBeanDefinitionException}.
- *
Subclasses may override this to select one of the instances or
- * to opt out with no result at all through returning {@code null}.
- * @param type the requested bean type
- * @param matchingBeans a map of bean names and corresponding bean
- * instances which have been pre-selected for the given type
- * (qualifiers etc already applied)
- * @return a bean instance to proceed with, or {@code null} for none
- * @throws BeansException in case of the not-unique scenario being fatal
- * @since 4.3
- * @deprecated as of 5.1, in favor of {@link #resolveNotUnique(ResolvableType, Map)}
- */
- @Deprecated
- @Nullable
- public Object resolveNotUnique(Class> type, Map matchingBeans) throws BeansException {
- throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
- }
-
/**
* Resolve a shortcut for this dependency against the given factory, for example
* taking some pre-resolved information into account.
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 c4e21122ed..e842353cb5 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.beans.factory.config;
-import java.beans.PropertyDescriptor;
-
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.lang.Nullable;
@@ -34,9 +32,7 @@ import org.springframework.lang.Nullable;
*
*
NOTE: This interface is a special purpose interface, mainly for
* internal use within the framework. It is recommended to implement the plain
- * {@link BeanPostProcessor} interface as far as possible, or to derive from
- * {@link InstantiationAwareBeanPostProcessorAdapter} in order to be shielded
- * from extensions to this interface.
+ * {@link BeanPostProcessor} interface as far as possible.
*
* @author Juergen Hoeller
* @author Rod Johnson
@@ -96,53 +92,19 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
/**
* Post-process the given property values before the factory applies them
- * to the given bean, without any need for property descriptors.
- *
Implementations should return {@code null} (the default) if they provide a custom
- * {@link #postProcessPropertyValues} implementation, and {@code pvs} otherwise.
- * In a future version of this interface (with {@link #postProcessPropertyValues} removed),
- * the default implementation will return the given {@code pvs} as-is directly.
- * @param pvs the property values that the factory is about to apply (never {@code null})
- * @param bean the bean instance created, but whose properties have not yet been set
- * @param beanName the name of the bean
- * @return the actual property values to apply to the given bean (can be the passed-in
- * PropertyValues instance), or {@code null} which proceeds with the existing properties
- * but specifically continues with a call to {@link #postProcessPropertyValues}
- * (requiring initialized {@code PropertyDescriptor}s for the current bean class)
- * @throws org.springframework.beans.BeansException in case of errors
- * @since 5.1
- * @see #postProcessPropertyValues
- */
- @Nullable
- default PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
- throws BeansException {
-
- return null;
- }
-
- /**
- * Post-process the given property values before the factory applies them
- * to the given bean. Allows for checking whether all dependencies have been
- * satisfied, for example based on a "Required" annotation on bean property setters.
- *
Also allows for replacing the property values to apply, typically through
- * creating a new MutablePropertyValues instance based on the original PropertyValues,
- * adding or removing specific values.
+ * to the given bean.
*
The default implementation returns the given {@code pvs} as-is.
* @param pvs the property values that the factory is about to apply (never {@code null})
- * @param pds the relevant property descriptors for the target bean (with ignored
- * dependency types - which the factory handles specifically - already filtered out)
* @param bean the bean instance created, but whose properties have not yet been set
* @param beanName the name of the bean
* @return the actual property values to apply to the given bean (can be the passed-in
* PropertyValues instance), or {@code null} to skip property population
* @throws org.springframework.beans.BeansException in case of errors
- * @see #postProcessProperties
- * @see org.springframework.beans.MutablePropertyValues
- * @deprecated as of 5.1, in favor of {@link #postProcessProperties(PropertyValues, Object, String)}
+ * @since 5.1
*/
- @Deprecated
@Nullable
- default PropertyValues postProcessPropertyValues(
- PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
+ default PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
+ throws BeansException {
return pvs;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java
deleted file mode 100644
index b3c112c8be..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2002-2020 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.factory.config;
-
-/**
- * Adapter that implements all methods on {@link SmartInstantiationAwareBeanPostProcessor}
- * as no-ops, which will not change normal processing of each bean instantiated
- * by the container. Subclasses may override merely those methods that they are
- * actually interested in.
- *
- *
Note that this base class is only recommendable if you actually require
- * {@link InstantiationAwareBeanPostProcessor} functionality. If all you need
- * is plain {@link BeanPostProcessor} functionality, prefer a straight
- * implementation of that (simpler) interface.
- *
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @since 2.0
- * @deprecated as of 5.3 in favor of implementing {@link InstantiationAwareBeanPostProcessor}
- * or {@link SmartInstantiationAwareBeanPostProcessor} directly.
- */
-@Deprecated
-public abstract class InstantiationAwareBeanPostProcessorAdapter implements SmartInstantiationAwareBeanPostProcessor {
-
-}
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 5ab6fb085a..d7f32a8ac5 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
@@ -936,24 +936,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return finder.getResult();
}
- /**
- * This implementation attempts to query the FactoryBean's generic parameter metadata
- * if present to determine the object type. If not present, i.e. the FactoryBean is
- * declared as a raw type, checks the FactoryBean's {@code getObjectType} method
- * on a plain instance of the FactoryBean, without bean properties applied yet.
- * If this doesn't return a type yet, a full creation of the FactoryBean is
- * used as fallback (through delegation to the superclass's implementation).
- *
The shortcut check for a FactoryBean is only applied in case of a singleton
- * FactoryBean. If the FactoryBean instance itself is not kept as singleton,
- * it will be fully created to check the type of its exposed object.
- */
- @Override
- @Deprecated
- @Nullable
- protected Class> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
- return getTypeForFactoryBean(beanName, mbd, true).resolve();
- }
-
/**
* Obtain a reference for early access to the specified bean,
* typically for the purpose of resolving a circular reference.
@@ -1398,7 +1380,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
boolean hasInstAwareBpps = hasInstantiationAwareBeanPostProcessors();
boolean needsDepCheck = (mbd.getDependencyCheck() != AbstractBeanDefinition.DEPENDENCY_CHECK_NONE);
- PropertyDescriptor[] filteredPds = null;
if (hasInstAwareBpps) {
if (pvs == null) {
pvs = mbd.getPropertyValues();
@@ -1406,21 +1387,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
for (InstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache().instantiationAware) {
PropertyValues pvsToUse = bp.postProcessProperties(pvs, bw.getWrappedInstance(), beanName);
if (pvsToUse == null) {
- if (filteredPds == null) {
- filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
- }
- pvsToUse = bp.postProcessPropertyValues(pvs, filteredPds, bw.getWrappedInstance(), beanName);
- if (pvsToUse == null) {
- return;
- }
+ return;
}
pvs = pvsToUse;
}
}
if (needsDepCheck) {
- if (filteredPds == null) {
- filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
- }
+ PropertyDescriptor[] filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
checkDependencies(beanName, mbd, filteredPds, pvs);
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
index b33651f186..6c2e05068c 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
@@ -1694,28 +1694,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
return ResolvableType.NONE;
}
- /**
- * Determine the bean type for the given FactoryBean definition, as far as possible.
- * Only called if there is no singleton instance registered for the target bean already.
- *
The default implementation creates the FactoryBean via {@code getBean}
- * to call its {@code getObjectType} method. Subclasses are encouraged to optimize
- * this, typically by just instantiating the FactoryBean but not populating it yet,
- * trying whether its {@code getObjectType} method already returns a type.
- * If no type found, a full FactoryBean creation as performed by this implementation
- * should be used as fallback.
- * @param beanName the name of the bean
- * @param mbd the merged bean definition for the bean
- * @return the type for the bean if determinable, or {@code null} otherwise
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- * @see #getBean(String)
- * @deprecated since 5.2 in favor of {@link #getTypeForFactoryBean(String, RootBeanDefinition, boolean)}
- */
- @Nullable
- @Deprecated
- protected Class> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
- return getTypeForFactoryBean(beanName, mbd, true).resolve();
- }
-
/**
* Mark the specified bean as already created (or about to be created).
*
This allows the bean factory to optimize its caching for repeated
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java
deleted file mode 100644
index b762a41810..0000000000
--- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.factory.xml;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.core.io.Resource;
-
-/**
- * Convenience extension of {@link DefaultListableBeanFactory} that reads bean definitions
- * from an XML document. Delegates to {@link XmlBeanDefinitionReader} underneath; effectively
- * equivalent to using an XmlBeanDefinitionReader with a DefaultListableBeanFactory.
- *
- *
The structure, element and attribute names of the required XML document
- * are hard-coded in this class. (Of course a transform could be run if necessary
- * to produce this format). "beans" doesn't need to be the root element of the XML
- * document: This class will parse all bean definition elements in the XML file.
- *
- *
This class registers each bean definition with the {@link DefaultListableBeanFactory}
- * superclass, and relies on the latter's implementation of the {@link BeanFactory} interface.
- * It supports singletons, prototypes, and references to either of these kinds of bean.
- * See {@code "spring-beans-3.x.xsd"} (or historically, {@code "spring-beans-2.0.dtd"}) for
- * details on options and configuration style.
- *
- *
For advanced needs, consider using a {@link DefaultListableBeanFactory} with
- * an {@link XmlBeanDefinitionReader}. The latter allows for reading from multiple XML
- * resources and is highly configurable in its actual XML parsing behavior.
- *
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Chris Beams
- * @since 15 April 2001
- * @see org.springframework.beans.factory.support.DefaultListableBeanFactory
- * @see XmlBeanDefinitionReader
- * @deprecated as of Spring 3.1 in favor of {@link DefaultListableBeanFactory} and
- * {@link XmlBeanDefinitionReader}
- */
-@Deprecated
-@SuppressWarnings({"serial", "all"})
-public class XmlBeanFactory extends DefaultListableBeanFactory {
-
- private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this);
-
-
- /**
- * Create a new XmlBeanFactory with the given resource,
- * which must be parsable using DOM.
- * @param resource the XML resource to load bean definitions from
- * @throws BeansException in case of loading or parsing errors
- */
- public XmlBeanFactory(Resource resource) throws BeansException {
- this(resource, null);
- }
-
- /**
- * Create a new XmlBeanFactory with the given input stream,
- * which must be parsable using DOM.
- * @param resource the XML resource to load bean definitions from
- * @param parentBeanFactory parent bean factory
- * @throws BeansException in case of loading or parsing errors
- */
- public XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory) throws BeansException {
- super(parentBeanFactory);
- this.reader.loadBeanDefinitions(resource);
- }
-
-}
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
index c746f21949..2d95718172 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
@@ -250,27 +250,6 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.subInjected).isTrue();
}
- @Test
- @SuppressWarnings("deprecation")
- public void testExtendedResourceInjectionWithAtRequired() {
- bf.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class);
- bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
- bf.registerBeanDefinition("annotatedBean", bd);
- TestBean tb = new TestBean();
- bf.registerSingleton("testBean", tb);
- NestedTestBean ntb = new NestedTestBean();
- bf.registerSingleton("nestedTestBean", ntb);
-
- TypedExtendedResourceInjectionBean bean = (TypedExtendedResourceInjectionBean) bf.getBean("annotatedBean");
- assertThat(bean.getTestBean()).isSameAs(tb);
- assertThat(bean.getTestBean2()).isSameAs(tb);
- assertThat(bean.getTestBean3()).isSameAs(tb);
- assertThat(bean.getTestBean4()).isSameAs(tb);
- assertThat(bean.getNestedTestBean()).isSameAs(ntb);
- assertThat(bean.getBeanFactory()).isSameAs(bf);
- }
-
@Test
public void testOptionalResourceInjection() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalResourceInjectionBean.class));
@@ -2401,7 +2380,6 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@Override
@Autowired
- @Required
@SuppressWarnings("deprecation")
public void setTestBean2(TestBean testBean2) {
super.setTestBean2(testBean2);
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
index d4b97bdb19..079f395560 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -154,27 +154,6 @@ public class InjectAnnotationBeanPostProcessorTests {
assertThat(bean.getBeanFactory()).isSameAs(bf);
}
- @Test
- @SuppressWarnings("deprecation")
- public void testExtendedResourceInjectionWithAtRequired() {
- bf.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class);
- bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
- bf.registerBeanDefinition("annotatedBean", bd);
- TestBean tb = new TestBean();
- bf.registerSingleton("testBean", tb);
- NestedTestBean ntb = new NestedTestBean();
- bf.registerSingleton("nestedTestBean", ntb);
-
- TypedExtendedResourceInjectionBean bean = (TypedExtendedResourceInjectionBean) bf.getBean("annotatedBean");
- assertThat(bean.getTestBean()).isSameAs(tb);
- assertThat(bean.getTestBean2()).isSameAs(tb);
- assertThat(bean.getTestBean3()).isSameAs(tb);
- assertThat(bean.getTestBean4()).isSameAs(tb);
- assertThat(bean.getNestedTestBean()).isSameAs(ntb);
- assertThat(bean.getBeanFactory()).isSameAs(bf);
- }
-
@Test
public void testConstructorResourceInjection() {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class);
@@ -666,7 +645,6 @@ public class InjectAnnotationBeanPostProcessorTests {
@Override
@Inject
- @Required
@SuppressWarnings("deprecation")
public void setTestBean2(TestBean testBean2) {
super.setTestBean2(testBean2);
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java
deleted file mode 100644
index a88a756029..0000000000
--- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.beans.factory.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.junit.jupiter.api.Test;
-
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-
-/**
- * @author Rob Harrop
- * @author Chris Beams
- * @since 2.0
- */
-@Deprecated
-public class RequiredAnnotationBeanPostProcessorTests {
-
- @Test
- public void testWithRequiredPropertyOmitted() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .addPropertyValue("name", "Rob Harrop")
- .addPropertyValue("favouriteColour", "Blue")
- .addPropertyValue("jobTitle", "Grand Poobah")
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- factory.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
- factory::preInstantiateSingletons)
- .withMessageContaining("Property")
- .withMessageContaining("age")
- .withMessageContaining("testBean");
- }
-
- @Test
- public void testWithThreeRequiredPropertiesOmitted() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .addPropertyValue("name", "Rob Harrop")
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- factory.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
- factory::preInstantiateSingletons)
- .withMessageContaining("Properties")
- .withMessageContaining("age")
- .withMessageContaining("favouriteColour")
- .withMessageContaining("jobTitle")
- .withMessageContaining("testBean");
- }
-
- @Test
- public void testWithAllRequiredPropertiesSpecified() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .addPropertyValue("age", "24")
- .addPropertyValue("favouriteColour", "Blue")
- .addPropertyValue("jobTitle", "Grand Poobah")
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- factory.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- factory.preInstantiateSingletons();
- RequiredTestBean bean = (RequiredTestBean) factory.getBean("testBean");
- assertThat(bean.getAge()).isEqualTo(24);
- assertThat(bean.getFavouriteColour()).isEqualTo("Blue");
- }
-
- @Test
- public void testWithCustomAnnotation() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- RequiredAnnotationBeanPostProcessor rabpp = new RequiredAnnotationBeanPostProcessor();
- rabpp.setRequiredAnnotationType(MyRequired.class);
- factory.addBeanPostProcessor(rabpp);
- assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
- factory::preInstantiateSingletons)
- .withMessageContaining("Property")
- .withMessageContaining("name")
- .withMessageContaining("testBean");
- }
-
- @Test
- public void testWithStaticFactoryMethod() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .setFactoryMethod("create")
- .addPropertyValue("name", "Rob Harrop")
- .addPropertyValue("favouriteColour", "Blue")
- .addPropertyValue("jobTitle", "Grand Poobah")
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- factory.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
- factory::preInstantiateSingletons)
- .withMessageContaining("Property")
- .withMessageContaining("age")
- .withMessageContaining("testBean");
- }
-
- @Test
- public void testWithStaticFactoryMethodAndRequiredPropertiesSpecified() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- BeanDefinition beanDef = BeanDefinitionBuilder
- .genericBeanDefinition(RequiredTestBean.class)
- .setFactoryMethod("create")
- .addPropertyValue("age", "24")
- .addPropertyValue("favouriteColour", "Blue")
- .addPropertyValue("jobTitle", "Grand Poobah")
- .getBeanDefinition();
- factory.registerBeanDefinition("testBean", beanDef);
- factory.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor());
- factory.preInstantiateSingletons();
- RequiredTestBean bean = (RequiredTestBean) factory.getBean("testBean");
- assertThat(bean.getAge()).isEqualTo(24);
- assertThat(bean.getFavouriteColour()).isEqualTo("Blue");
- }
-
- @Test
- public void testWithFactoryBean() {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- RootBeanDefinition beanDef = new RootBeanDefinition(RequiredTestBean.class);
- beanDef.setFactoryBeanName("testBeanFactory");
- beanDef.setFactoryMethodName("create");
- factory.registerBeanDefinition("testBean", beanDef);
- factory.registerBeanDefinition("testBeanFactory", new RootBeanDefinition(RequiredTestBeanFactory.class));
- RequiredAnnotationBeanPostProcessor bpp = new RequiredAnnotationBeanPostProcessor();
- bpp.setBeanFactory(factory);
- factory.addBeanPostProcessor(bpp);
- factory.preInstantiateSingletons();
- }
-
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- public @interface MyRequired {
- }
-
-
- public static class RequiredTestBean implements BeanNameAware, BeanFactoryAware {
-
- private String name;
-
- private int age;
-
- private String favouriteColour;
-
- private String jobTitle;
-
-
- public int getAge() {
- return age;
- }
-
- @Required
- public void setAge(int age) {
- this.age = age;
- }
-
- public String getName() {
- return name;
- }
-
- @MyRequired
- public void setName(String name) {
- this.name = name;
- }
-
- public String getFavouriteColour() {
- return favouriteColour;
- }
-
- @Required
- public void setFavouriteColour(String favouriteColour) {
- this.favouriteColour = favouriteColour;
- }
-
- public String getJobTitle() {
- return jobTitle;
- }
-
- @Required
- public void setJobTitle(String jobTitle) {
- this.jobTitle = jobTitle;
- }
-
- @Override
- @Required
- public void setBeanName(String name) {
- }
-
- @Override
- @Required
- public void setBeanFactory(BeanFactory beanFactory) {
- }
-
- public static RequiredTestBean create() {
- return new RequiredTestBean();
- }
- }
-
-
- public static class RequiredTestBeanFactory {
-
- public RequiredTestBean create() {
- return new RequiredTestBean();
- }
- }
-
-}
diff --git a/spring-context/src/jmh/java/org/springframework/context/annotation/AnnotationProcessorBenchmark.java b/spring-context/src/jmh/java/org/springframework/context/annotation/AnnotationProcessorBenchmark.java
index 3e19ca7e97..f78c671817 100644
--- a/spring-context/src/jmh/java/org/springframework/context/annotation/AnnotationProcessorBenchmark.java
+++ b/spring-context/src/jmh/java/org/springframework/context/annotation/AnnotationProcessorBenchmark.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,7 +84,6 @@ public class AnnotationProcessorBenchmark {
@Override
@Resource
@SuppressWarnings("deprecation")
- @org.springframework.beans.factory.annotation.Required
public void setSpouse(ITestBean spouse) {
super.setSpouse(spouse);
}
@@ -95,7 +94,6 @@ public class AnnotationProcessorBenchmark {
@Override
@Autowired
@SuppressWarnings("deprecation")
- @org.springframework.beans.factory.annotation.Required
public void setSpouse(ITestBean spouse) {
super.setSpouse(spouse);
}
diff --git a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java
index 50516d0727..c7f7ef5da0 100644
--- a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java
+++ b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -132,21 +132,6 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
return this.cacheMap.get(name);
}
- /**
- * Dynamically register an additional Cache with this manager.
- * @param cache the Cache to register
- * @deprecated as of Spring 4.3, in favor of {@link #getMissingCache(String)}
- */
- @Deprecated
- protected final void addCache(Cache cache) {
- String name = cache.getName();
- synchronized (this.cacheMap) {
- if (this.cacheMap.put(name, decorateCache(cache)) == null) {
- updateCacheNames(name);
- }
- }
- }
-
/**
* Update the exposed {@link #cacheNames} set with the given name.
*
This will always be called within a full {@link #cacheMap} lock
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
index 20ed51eff6..9a1a146290 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
@@ -83,14 +83,6 @@ public abstract class AnnotationConfigUtils {
public static final String AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME =
"org.springframework.context.annotation.internalAutowiredAnnotationProcessor";
- /**
- * The bean name of the internally managed Required annotation processor.
- * @deprecated as of 5.1, since no Required processor is registered by default anymore
- */
- @Deprecated
- public static final String REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME =
- "org.springframework.context.annotation.internalRequiredAnnotationProcessor";
-
/**
* The bean name of the internally managed common annotation processor.
*/
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java
index 2f254d5a71..14732b1783 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.core.annotation.AliasFor;
@@ -239,21 +238,6 @@ public @interface Bean {
@AliasFor("value")
String[] name() default {};
- /**
- * Are dependencies to be injected via convention-based autowiring by name or type?
- *
Note that this autowire mode is just about externally driven autowiring based
- * on bean property setter methods by convention, analogous to XML bean definitions.
- *
The default mode does allow for annotation-driven autowiring. "no" refers to
- * externally driven autowiring only, not affecting any autowiring demands that the
- * bean class itself expresses through annotations.
- * @see Autowire#BY_NAME
- * @see Autowire#BY_TYPE
- * @deprecated as of 5.1, since {@code @Bean} factory method argument resolution and
- * {@code @Autowired} processing supersede name/type-based bean property injection
- */
- @Deprecated
- Autowire autowire() default Autowire.NO;
-
/**
* Is this bean a candidate for getting autowired into some other bean?
*
Default is {@code true}; set this to {@code false} for internal delegates
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
index db8c8e2c28..18a6245b64 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
@@ -306,14 +306,6 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
return pvs;
}
- @Deprecated
- @Override
- public PropertyValues postProcessPropertyValues(
- PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
-
- return postProcessProperties(pvs, bean, beanName);
- }
-
private InjectionMetadata findResourceMetadata(String beanName, Class> clazz, @Nullable PropertyValues pvs) {
// Fall back to class name as cache key, for backwards compatibility with custom callers.
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
index 85b45e1574..86bcbb5e5b 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
@@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
-import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader;
@@ -244,16 +243,8 @@ class ConfigurationClassBeanDefinitionReader {
}
beanDef.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
- beanDef.setAttribute(org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor.
- SKIP_REQUIRED_CHECK_ATTRIBUTE, Boolean.TRUE);
-
AnnotationConfigUtils.processCommonDefinitionAnnotations(beanDef, metadata);
- Autowire autowire = bean.getEnum("autowire");
- if (autowire.isAutowire()) {
- beanDef.setAutowireMode(autowire.value());
- }
-
boolean autowireCandidate = bean.getBoolean("autowireCandidate");
if (!autowireCandidate) {
beanDef.setAutowireCandidate(false);
diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
index dae989caa6..27b050838c 100644
--- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
+++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
@@ -935,11 +935,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Publish the final event.
publishEvent(new ContextRefreshedEvent(this));
-
- // Participate in LiveBeansView MBean, if active.
- if (!NativeDetector.inNativeImage()) {
- LiveBeansView.registerApplicationContext(this);
- }
}
/**
@@ -995,18 +990,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
}
- /**
- * Callback for destruction of this instance, originally attached
- * to a {@code DisposableBean} implementation (not anymore in 5.0).
- *
The {@link #close()} method is the native way to shut down
- * an ApplicationContext, which this method simply delegates to.
- * @deprecated as of Spring Framework 5.0, in favor of {@link #close()}
- */
- @Deprecated
- public void destroy() {
- close();
- }
-
/**
* Close this application context, destroying all beans in its bean factory.
*
Delegates to {@code doClose()} for the actual closing procedure.
@@ -1048,10 +1031,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
logger.debug("Closing " + this);
}
- if (!NativeDetector.inNativeImage()) {
- LiveBeansView.unregisterApplicationContext(this);
- }
-
try {
// Publish shutdown event.
publishEvent(new ContextClosedEvent(this));
diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java
deleted file mode 100644
index 96a9b212e3..0000000000
--- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.context.support;
-
-import java.lang.management.ManagementFactory;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationContextException;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-
-/**
- * Adapter for live beans view exposure, building a snapshot of current beans
- * and their dependencies from either a local {@code ApplicationContext} (with a
- * local {@code LiveBeansView} bean definition) or all registered ApplicationContexts
- * (driven by the {@value #MBEAN_DOMAIN_PROPERTY_NAME} environment property).
- *
- * @author Juergen Hoeller
- * @author Stephane Nicoll
- * @since 3.2
- * @see #getSnapshotAsJson()
- * @see org.springframework.web.context.support.LiveBeansViewServlet
- * @deprecated as of 5.3, in favor of using Spring Boot actuators for such needs
- */
-@Deprecated
-public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAware {
-
- /**
- * The "MBean Domain" property name.
- */
- public static final String MBEAN_DOMAIN_PROPERTY_NAME = "spring.liveBeansView.mbeanDomain";
-
- /**
- * The MBean application key.
- */
- public static final String MBEAN_APPLICATION_KEY = "application";
-
- private static final Set applicationContexts = new LinkedHashSet<>();
-
- @Nullable
- private static String applicationName;
-
-
- static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
- String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
- if (mbeanDomain != null) {
- synchronized (applicationContexts) {
- if (applicationContexts.isEmpty()) {
- try {
- MBeanServer server = ManagementFactory.getPlatformMBeanServer();
- applicationName = applicationContext.getApplicationName();
- server.registerMBean(new LiveBeansView(),
- new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
- }
- catch (Throwable ex) {
- throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex);
- }
- }
- applicationContexts.add(applicationContext);
- }
- }
- }
-
- static void unregisterApplicationContext(ConfigurableApplicationContext applicationContext) {
- synchronized (applicationContexts) {
- if (applicationContexts.remove(applicationContext) && applicationContexts.isEmpty()) {
- try {
- MBeanServer server = ManagementFactory.getPlatformMBeanServer();
- String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
- if (mbeanDomain != null) {
- server.unregisterMBean(new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
- }
- }
- catch (Throwable ex) {
- throw new ApplicationContextException("Failed to unregister LiveBeansView MBean", ex);
- }
- finally {
- applicationName = null;
- }
- }
- }
- }
-
-
- @Nullable
- private ConfigurableApplicationContext applicationContext;
-
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) {
- Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext,
- "ApplicationContext does not implement ConfigurableApplicationContext");
- this.applicationContext = (ConfigurableApplicationContext) applicationContext;
- }
-
-
- /**
- * Generate a JSON snapshot of current beans and their dependencies,
- * finding all active ApplicationContexts through {@link #findApplicationContexts()},
- * then delegating to {@link #generateJson(java.util.Set)}.
- */
- @Override
- public String getSnapshotAsJson() {
- Set contexts;
- if (this.applicationContext != null) {
- contexts = Collections.singleton(this.applicationContext);
- }
- else {
- contexts = findApplicationContexts();
- }
- return generateJson(contexts);
- }
-
- /**
- * Find all applicable ApplicationContexts for the current application.
- *
Called if no specific ApplicationContext has been set for this LiveBeansView.
- * @return the set of ApplicationContexts
- */
- protected Set findApplicationContexts() {
- synchronized (applicationContexts) {
- return new LinkedHashSet<>(applicationContexts);
- }
- }
-
- /**
- * Actually generate a JSON snapshot of the beans in the given ApplicationContexts.
- *
This implementation doesn't use any JSON parsing libraries in order to avoid
- * third-party library dependencies. It produces an array of context description
- * objects, each containing a context and parent attribute as well as a beans
- * attribute with nested bean description objects. Each bean object contains a
- * bean, scope, type and resource attribute, as well as a dependencies attribute
- * with a nested array of bean names that the present bean depends on.
- * @param contexts the set of ApplicationContexts
- * @return the JSON document
- */
- protected String generateJson(Set contexts) {
- StringBuilder result = new StringBuilder("[\n");
- for (Iterator it = contexts.iterator(); it.hasNext();) {
- ConfigurableApplicationContext context = it.next();
- result.append("{\n\"context\": \"").append(context.getId()).append("\",\n");
- if (context.getParent() != null) {
- result.append("\"parent\": \"").append(context.getParent().getId()).append("\",\n");
- }
- else {
- result.append("\"parent\": null,\n");
- }
- result.append("\"beans\": [\n");
- ConfigurableListableBeanFactory bf = context.getBeanFactory();
- String[] beanNames = bf.getBeanDefinitionNames();
- boolean elementAppended = false;
- for (String beanName : beanNames) {
- BeanDefinition bd = bf.getBeanDefinition(beanName);
- if (isBeanEligible(beanName, bd, bf)) {
- if (elementAppended) {
- result.append(",\n");
- }
- result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
- result.append("\"aliases\": ");
- appendArray(result, bf.getAliases(beanName));
- result.append(",\n");
- String scope = bd.getScope();
- if (!StringUtils.hasText(scope)) {
- scope = BeanDefinition.SCOPE_SINGLETON;
- }
- result.append("\"scope\": \"").append(scope).append("\",\n");
- Class> beanType = bf.getType(beanName);
- if (beanType != null) {
- result.append("\"type\": \"").append(beanType.getName()).append("\",\n");
- }
- else {
- result.append("\"type\": null,\n");
- }
- result.append("\"resource\": \"").append(getEscapedResourceDescription(bd)).append("\",\n");
- result.append("\"dependencies\": ");
- appendArray(result, bf.getDependenciesForBean(beanName));
- result.append("\n}");
- elementAppended = true;
- }
- }
- result.append("]\n");
- result.append('}');
- if (it.hasNext()) {
- result.append(",\n");
- }
- }
- result.append(']');
- return result.toString();
- }
-
- /**
- * Determine whether the specified bean is eligible for inclusion in the
- * LiveBeansView JSON snapshot.
- * @param beanName the name of the bean
- * @param bd the corresponding bean definition
- * @param bf the containing bean factory
- * @return {@code true} if the bean is to be included; {@code false} otherwise
- */
- protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
- return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
- (!bd.isLazyInit() || bf.containsSingleton(beanName)));
- }
-
- /**
- * Determine a resource description for the given bean definition and
- * apply basic JSON escaping (backslashes, double quotes) to it.
- * @param bd the bean definition to build the resource description for
- * @return the JSON-escaped resource description
- */
- @Nullable
- protected String getEscapedResourceDescription(BeanDefinition bd) {
- String resourceDescription = bd.getResourceDescription();
- if (resourceDescription == null) {
- return null;
- }
- StringBuilder result = new StringBuilder(resourceDescription.length() + 16);
- for (int i = 0; i < resourceDescription.length(); i++) {
- char character = resourceDescription.charAt(i);
- if (character == '\\') {
- result.append('/');
- }
- else if (character == '"') {
- result.append("\\").append('"');
- }
- else {
- result.append(character);
- }
- }
- return result.toString();
- }
-
- private void appendArray(StringBuilder result, String[] arr) {
- result.append('[');
- if (arr.length > 0) {
- result.append('\"');
- }
- result.append(StringUtils.arrayToDelimitedString(arr, "\", \""));
- if (arr.length > 0) {
- result.append('\"');
- }
- result.append(']');
- }
-
-}
diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java
deleted file mode 100644
index b8e0ba01bd..0000000000
--- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2002-2020 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.context.support;
-
-/**
- * MBean operation interface for the {@link LiveBeansView} feature.
- *
- * @author Juergen Hoeller
- * @since 3.2
- * @deprecated as of 5.3, in favor of using Spring Boot actuators for such needs
- */
-@Deprecated
-public interface LiveBeansViewMBean {
-
- /**
- * Generate a JSON snapshot of current beans and their dependencies.
- */
- String getSnapshotAsJson();
-
-}
diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java
index 0ba5a87265..e334bddff5 100644
--- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java
+++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.context.annotation.configuration;
import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -46,15 +45,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class BeanAnnotationAttributePropagationTests {
- @Test
- public void autowireMetadataIsPropagated() {
- @Configuration class Config {
- @Bean(autowire=Autowire.BY_TYPE) Object foo() { return null; }
- }
-
- assertThat(beanDef(Config.class).getAutowireMode()).as("autowire mode was not propagated").isEqualTo(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
- }
-
@Test
public void autowireCandidateMetadataIsPropagated() {
@Configuration class Config {
diff --git a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java b/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java
deleted file mode 100644
index 983fa9bc88..0000000000
--- a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.context.support;
-
-import java.lang.management.ManagementFactory;
-import java.util.Set;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
-
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.mock.env.MockEnvironment;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
-/**
- * Tests for {@link LiveBeansView}
- *
- * @author Stephane Nicoll
- * @author Sam Brannen
- */
-@SuppressWarnings("deprecation")
-class LiveBeansViewTests {
-
- private final MockEnvironment environment = new MockEnvironment();
-
-
- @Test
- void registerIgnoredIfPropertyIsNotSet(TestInfo testInfo) throws MalformedObjectNameException {
- ConfigurableApplicationContext context = createApplicationContext("app");
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- LiveBeansView.registerApplicationContext(context);
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- LiveBeansView.unregisterApplicationContext(context);
- }
-
- @Test
- void registerUnregisterSingleContext(TestInfo testInfo) throws MalformedObjectNameException {
- this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME,
- testInfo.getTestMethod().get().getName());
- ConfigurableApplicationContext context = createApplicationContext("app");
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- LiveBeansView.registerApplicationContext(context);
- assertSingleLiveBeansViewMbean(testInfo, "app");
- LiveBeansView.unregisterApplicationContext(context);
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- }
-
- @Test
- void registerUnregisterSeveralContexts(TestInfo testInfo) throws MalformedObjectNameException {
- this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME,
- testInfo.getTestMethod().get().getName());
- ConfigurableApplicationContext context = createApplicationContext("app");
- ConfigurableApplicationContext childContext = createApplicationContext("child");
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- LiveBeansView.registerApplicationContext(context);
- assertSingleLiveBeansViewMbean(testInfo, "app");
- LiveBeansView.registerApplicationContext(childContext);
- // Only one MBean
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(1);
- LiveBeansView.unregisterApplicationContext(childContext);
- assertSingleLiveBeansViewMbean(testInfo, "app"); // Root context removes it
- LiveBeansView.unregisterApplicationContext(context);
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- }
-
- @Test
- void registerUnregisterSeveralContextsDifferentOrder(TestInfo testInfo) throws MalformedObjectNameException {
- this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME,
- testInfo.getTestMethod().get().getName());
- ConfigurableApplicationContext context = createApplicationContext("app");
- ConfigurableApplicationContext childContext = createApplicationContext("child");
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- LiveBeansView.registerApplicationContext(context);
- assertSingleLiveBeansViewMbean(testInfo, "app");
- LiveBeansView.registerApplicationContext(childContext);
- assertSingleLiveBeansViewMbean(testInfo, "app"); // Only one MBean
- LiveBeansView.unregisterApplicationContext(context);
- LiveBeansView.unregisterApplicationContext(childContext);
- assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0);
- }
-
- private ConfigurableApplicationContext createApplicationContext(String applicationName) {
- ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
- given(context.getEnvironment()).willReturn(this.environment);
- given(context.getApplicationName()).willReturn(applicationName);
- return context;
- }
-
- private void assertSingleLiveBeansViewMbean(TestInfo testInfo, String applicationName) throws MalformedObjectNameException {
- Set objectNames = searchLiveBeansViewMeans(testInfo);
- assertThat(objectNames.size()).isEqualTo(1);
- assertThat(objectNames.iterator().next().getCanonicalName()).as("Wrong MBean name").isEqualTo(
- String.format("%s:application=%s", testInfo.getTestMethod().get().getName(), applicationName));
- }
-
- private Set searchLiveBeansViewMeans(TestInfo testInfo) throws MalformedObjectNameException {
- String objectName = String.format("%s:*,%s=*", testInfo.getTestMethod().get().getName(),
- LiveBeansView.MBEAN_APPLICATION_KEY);
- return ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName(objectName), null);
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java
index e805414c13..5749d859eb 100644
--- a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java
+++ b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -207,17 +207,6 @@ public final class StringDecoder extends AbstractDataBufferDecoder {
}
}
- /**
- * Create a {@code StringDecoder} for {@code "text/plain"}.
- * @param stripDelimiter this flag is ignored
- * @deprecated as of Spring 5.0.4, in favor of {@link #textPlainOnly()} or
- * {@link #textPlainOnly(List, boolean)}
- */
- @Deprecated
- public static StringDecoder textPlainOnly(boolean stripDelimiter) {
- return textPlainOnly();
- }
-
/**
* Create a {@code StringDecoder} for {@code "text/plain"}.
*/
@@ -235,17 +224,6 @@ public final class StringDecoder extends AbstractDataBufferDecoder {
return new StringDecoder(delimiters, stripDelimiter, new MimeType("text", "plain", DEFAULT_CHARSET));
}
- /**
- * Create a {@code StringDecoder} that supports all MIME types.
- * @param stripDelimiter this flag is ignored
- * @deprecated as of Spring 5.0.4, in favor of {@link #allMimeTypes()} or
- * {@link #allMimeTypes(List, boolean)}
- */
- @Deprecated
- public static StringDecoder allMimeTypes(boolean stripDelimiter) {
- return allMimeTypes();
- }
-
/**
* Create a {@code StringDecoder} that supports all MIME types.
*/
diff --git a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
index cbaad7001b..2ba871bbc1 100644
--- a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
@@ -99,22 +99,6 @@ public class ClassPathResource extends AbstractFileResolvingResource {
this.clazz = clazz;
}
- /**
- * Create a new {@code ClassPathResource} with optional {@code ClassLoader}
- * and {@code Class}. Only for internal usage.
- * @param path relative or absolute path within the classpath
- * @param classLoader the class loader to load the resource with, if any
- * @param clazz the class to load resources with, if any
- * @deprecated as of 4.3.13, in favor of selective use of
- * {@link #ClassPathResource(String, ClassLoader)} vs {@link #ClassPathResource(String, Class)}
- */
- @Deprecated
- protected ClassPathResource(String path, @Nullable ClassLoader classLoader, @Nullable Class> clazz) {
- this.path = StringUtils.cleanPath(path);
- this.classLoader = classLoader;
- this.clazz = clazz;
- }
-
/**
* Return the path for this resource (as resource path within the class path).
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java
deleted file mode 100644
index 356ab5b461..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.lang.reflect.Field;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.SpringAsmInfo;
-import org.springframework.asm.Type;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.lang.Nullable;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.ReflectionUtils;
-
-/**
- * {@link AnnotationVisitor} to recursively visit annotations.
- *
- * @author Chris Beams
- * @author Juergen Hoeller
- * @author Phillip Webb
- * @author Sam Brannen
- * @since 3.1.1
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
-
- protected final Log logger = LogFactory.getLog(getClass());
-
- protected final AnnotationAttributes attributes;
-
- @Nullable
- protected final ClassLoader classLoader;
-
-
- public AbstractRecursiveAnnotationVisitor(@Nullable ClassLoader classLoader, AnnotationAttributes attributes) {
- super(SpringAsmInfo.ASM_VERSION);
- this.classLoader = classLoader;
- this.attributes = attributes;
- }
-
-
- @Override
- public void visit(String attributeName, Object attributeValue) {
- this.attributes.put(attributeName, attributeValue);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String attributeName, String asmTypeDescriptor) {
- String annotationType = Type.getType(asmTypeDescriptor).getClassName();
- AnnotationAttributes nestedAttributes = new AnnotationAttributes(annotationType, this.classLoader);
- this.attributes.put(attributeName, nestedAttributes);
- return new RecursiveAnnotationAttributesVisitor(annotationType, nestedAttributes, this.classLoader);
- }
-
- @Override
- public AnnotationVisitor visitArray(String attributeName) {
- return new RecursiveAnnotationArrayVisitor(attributeName, this.attributes, this.classLoader);
- }
-
- @Override
- public void visitEnum(String attributeName, String asmTypeDescriptor, String attributeValue) {
- Object newValue = getEnumValue(asmTypeDescriptor, attributeValue);
- visit(attributeName, newValue);
- }
-
- protected Object getEnumValue(String asmTypeDescriptor, String attributeValue) {
- Object valueToUse = attributeValue;
- try {
- Class> enumType = ClassUtils.forName(Type.getType(asmTypeDescriptor).getClassName(), this.classLoader);
- Field enumConstant = ReflectionUtils.findField(enumType, attributeValue);
- if (enumConstant != null) {
- ReflectionUtils.makeAccessible(enumConstant);
- valueToUse = enumConstant.get(null);
- }
- }
- catch (ClassNotFoundException | NoClassDefFoundError ex) {
- logger.debug("Failed to classload enum type while reading annotation metadata", ex);
- }
- catch (IllegalAccessException ex) {
- logger.debug("Could not access enum value while reading annotation metadata", ex);
- }
- return valueToUse;
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
deleted file mode 100644
index ba1bfe06cf..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Modifier;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.lang.Nullable;
-import org.springframework.util.MultiValueMap;
-import org.springframework.util.ObjectUtils;
-
-/**
- * ASM visitor which looks for annotations defined on a class or method,
- * including meta-annotations.
- *
- *
This visitor is fully recursive, taking into account any nested
- * annotations or nested annotation arrays.
- *
- * @author Juergen Hoeller
- * @author Chris Beams
- * @author Phillip Webb
- * @author Sam Brannen
- * @since 3.0
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttributesVisitor {
-
- private final MultiValueMap attributesMap;
-
- private final Map> metaAnnotationMap;
-
-
- public AnnotationAttributesReadingVisitor(String annotationType,
- MultiValueMap attributesMap, Map> metaAnnotationMap,
- @Nullable ClassLoader classLoader) {
-
- super(annotationType, new AnnotationAttributes(annotationType, classLoader), classLoader);
- this.attributesMap = attributesMap;
- this.metaAnnotationMap = metaAnnotationMap;
- }
-
-
- @Override
- public void visitEnd() {
- super.visitEnd();
-
- Class extends Annotation> annotationClass = this.attributes.annotationType();
- if (annotationClass != null) {
- List attributeList = this.attributesMap.get(this.annotationType);
- if (attributeList == null) {
- this.attributesMap.add(this.annotationType, this.attributes);
- }
- else {
- attributeList.add(0, this.attributes);
- }
- if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotationClass.getName())) {
- try {
- Annotation[] metaAnnotations = annotationClass.getAnnotations();
- if (!ObjectUtils.isEmpty(metaAnnotations)) {
- Set visited = new LinkedHashSet<>();
- for (Annotation metaAnnotation : metaAnnotations) {
- recursivelyCollectMetaAnnotations(visited, metaAnnotation);
- }
- if (!visited.isEmpty()) {
- Set metaAnnotationTypeNames = new LinkedHashSet<>(visited.size());
- for (Annotation ann : visited) {
- metaAnnotationTypeNames.add(ann.annotationType().getName());
- }
- this.metaAnnotationMap.put(annotationClass.getName(), metaAnnotationTypeNames);
- }
- }
- }
- catch (Throwable ex) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed to introspect meta-annotations on " + annotationClass + ": " + ex);
- }
- }
- }
- }
- }
-
- private void recursivelyCollectMetaAnnotations(Set visited, Annotation annotation) {
- Class extends Annotation> annotationType = annotation.annotationType();
- String annotationName = annotationType.getName();
- if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotationName) && visited.add(annotation)) {
- try {
- // Only do attribute scanning for public annotations.
- if (Modifier.isPublic(annotationType.getModifiers())) {
- this.attributesMap.add(annotationName,
- AnnotationUtils.getAnnotationAttributes(annotation, false, true));
- }
- for (Annotation metaMetaAnnotation : annotationType.getAnnotations()) {
- recursivelyCollectMetaAnnotations(visited, metaMetaAnnotation);
- }
- }
- catch (Throwable ex) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed to introspect meta-annotations on " + annotation + ": " + ex);
- }
- }
- }
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java
deleted file mode 100644
index 9435af78ed..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2002-2020 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.MethodVisitor;
-import org.springframework.asm.Opcodes;
-import org.springframework.asm.Type;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.MergedAnnotations;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.core.type.MethodMetadata;
-import org.springframework.lang.Nullable;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-
-/**
- * ASM class visitor which looks for the class name and implemented types as
- * well as for the annotations defined on the class, exposing them through
- * the {@link org.springframework.core.type.AnnotationMetadata} interface.
- *
- * @author Juergen Hoeller
- * @author Mark Fisher
- * @author Costin Leau
- * @author Phillip Webb
- * @author Sam Brannen
- * @since 2.5
- * @deprecated As of Spring Framework 5.2, this class has been replaced by
- * {@link SimpleAnnotationMetadataReadingVisitor} for internal use within the
- * framework, but there is no public replacement for
- * {@code AnnotationMetadataReadingVisitor}.
- */
-@Deprecated
-public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor implements AnnotationMetadata {
-
- @Nullable
- protected final ClassLoader classLoader;
-
- protected final Set annotationSet = new LinkedHashSet<>(4);
-
- protected final Map> metaAnnotationMap = new LinkedHashMap<>(4);
-
- /**
- * Declared as a {@link LinkedMultiValueMap} instead of a {@link MultiValueMap}
- * to ensure that the hierarchical ordering of the entries is preserved.
- * @see AnnotationReadingVisitorUtils#getMergedAnnotationAttributes
- */
- protected final LinkedMultiValueMap attributesMap = new LinkedMultiValueMap<>(3);
-
- protected final Set methodMetadataSet = new LinkedHashSet<>(4);
-
-
- public AnnotationMetadataReadingVisitor(@Nullable ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
-
- @Override
- public MergedAnnotations getAnnotations() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- // Skip bridge methods - we're only interested in original annotation-defining user methods.
- // On JDK 8, we'd otherwise run into double detection of the same annotated method...
- if ((access & Opcodes.ACC_BRIDGE) != 0) {
- return super.visitMethod(access, name, desc, signature, exceptions);
- }
- return new MethodMetadataReadingVisitor(name, access, getClassName(),
- Type.getReturnType(desc).getClassName(), this.classLoader, this.methodMetadataSet);
- }
-
- @Override
- @Nullable
- public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
- if (!visible) {
- return null;
- }
- String className = Type.getType(desc).getClassName();
- if (AnnotationUtils.isInJavaLangAnnotationPackage(className)) {
- return null;
- }
- this.annotationSet.add(className);
- return new AnnotationAttributesReadingVisitor(
- className, this.attributesMap, this.metaAnnotationMap, this.classLoader);
- }
-
-
- @Override
- public Set getAnnotationTypes() {
- return this.annotationSet;
- }
-
- @Override
- public Set getMetaAnnotationTypes(String annotationName) {
- Set metaAnnotationTypes = this.metaAnnotationMap.get(annotationName);
- return (metaAnnotationTypes != null ? metaAnnotationTypes : Collections.emptySet());
- }
-
- @Override
- public boolean hasMetaAnnotation(String metaAnnotationType) {
- if (AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotationType)) {
- return false;
- }
- Collection> allMetaTypes = this.metaAnnotationMap.values();
- for (Set metaTypes : allMetaTypes) {
- if (metaTypes.contains(metaAnnotationType)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean isAnnotated(String annotationName) {
- return (!AnnotationUtils.isInJavaLangAnnotationPackage(annotationName) &&
- this.attributesMap.containsKey(annotationName));
- }
-
- @Override
- public boolean hasAnnotation(String annotationName) {
- return getAnnotationTypes().contains(annotationName);
- }
-
- @Override
- @Nullable
- public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) {
- AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(
- this.attributesMap, this.metaAnnotationMap, annotationName);
- if (raw == null) {
- return null;
- }
- return AnnotationReadingVisitorUtils.convertClassValues(
- "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString);
- }
-
- @Override
- @Nullable
- public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
- MultiValueMap allAttributes = new LinkedMultiValueMap<>();
- List attributes = this.attributesMap.get(annotationName);
- if (attributes == null) {
- return null;
- }
- String annotatedElement = "class '" + getClassName() + "'";
- for (AnnotationAttributes raw : attributes) {
- for (Map.Entry entry : AnnotationReadingVisitorUtils.convertClassValues(
- annotatedElement, this.classLoader, raw, classValuesAsString).entrySet()) {
- allAttributes.add(entry.getKey(), entry.getValue());
- }
- }
- return allAttributes;
- }
-
- @Override
- public boolean hasAnnotatedMethods(String annotationName) {
- for (MethodMetadata methodMetadata : this.methodMetadataSet) {
- if (methodMetadata.isAnnotated(annotationName)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public Set getAnnotatedMethods(String annotationName) {
- Set annotatedMethods = new LinkedHashSet<>(4);
- for (MethodMetadata methodMetadata : this.methodMetadataSet) {
- if (methodMetadata.isAnnotated(annotationName)) {
- annotatedMethods.add(methodMetadata);
- }
- }
- return annotatedMethods;
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java
deleted file mode 100644
index 98bb301ba4..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.springframework.asm.Type;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.lang.Nullable;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.ObjectUtils;
-
-/**
- * Internal utility class used when reading annotations via ASM.
- *
- * @author Juergen Hoeller
- * @author Mark Fisher
- * @author Costin Leau
- * @author Phillip Webb
- * @author Sam Brannen
- * @since 4.0
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-abstract class AnnotationReadingVisitorUtils {
-
- public static AnnotationAttributes convertClassValues(Object annotatedElement,
- @Nullable ClassLoader classLoader, AnnotationAttributes original, boolean classValuesAsString) {
-
- AnnotationAttributes result = new AnnotationAttributes(original);
- AnnotationUtils.postProcessAnnotationAttributes(annotatedElement, result, classValuesAsString);
-
- for (Map.Entry entry : result.entrySet()) {
- try {
- Object value = entry.getValue();
- if (value instanceof AnnotationAttributes) {
- value = convertClassValues(
- annotatedElement, classLoader, (AnnotationAttributes) value, classValuesAsString);
- }
- else if (value instanceof AnnotationAttributes[] values) {
- for (int i = 0; i < values.length; i++) {
- values[i] = convertClassValues(annotatedElement, classLoader, values[i], classValuesAsString);
- }
- value = values;
- }
- else if (value instanceof Type) {
- value = (classValuesAsString ? ((Type) value).getClassName() :
- ClassUtils.forName(((Type) value).getClassName(), classLoader));
- }
- else if (value instanceof Type[] array) {
- Object[] convArray =
- (classValuesAsString ? new String[array.length] : new Class>[array.length]);
- for (int i = 0; i < array.length; i++) {
- convArray[i] = (classValuesAsString ? array[i].getClassName() :
- ClassUtils.forName(array[i].getClassName(), classLoader));
- }
- value = convArray;
- }
- else if (classValuesAsString) {
- if (value instanceof Class) {
- value = ((Class>) value).getName();
- }
- else if (value instanceof Class[]) {
- Class>[] clazzArray = (Class>[]) value;
- String[] newValue = new String[clazzArray.length];
- for (int i = 0; i < clazzArray.length; i++) {
- newValue[i] = clazzArray[i].getName();
- }
- value = newValue;
- }
- }
- entry.setValue(value);
- }
- catch (Throwable ex) {
- // Class not found - can't resolve class reference in annotation attribute.
- result.put(entry.getKey(), ex);
- }
- }
-
- return result;
- }
-
- /**
- * Retrieve the merged attributes of the annotation of the given type,
- * if any, from the supplied {@code attributesMap}.
- *
Annotation attribute values appearing lower in the annotation
- * hierarchy (i.e., closer to the declaring class) will override those
- * defined higher in the annotation hierarchy.
- * @param attributesMap the map of annotation attribute lists, keyed by
- * annotation type name
- * @param metaAnnotationMap the map of meta annotation relationships,
- * keyed by annotation type name
- * @param annotationName the fully qualified class name of the annotation
- * type to look for
- * @return the merged annotation attributes, or {@code null} if no
- * matching annotation is present in the {@code attributesMap}
- * @since 4.0.3
- */
- @Nullable
- public static AnnotationAttributes getMergedAnnotationAttributes(
- LinkedMultiValueMap attributesMap,
- Map> metaAnnotationMap, String annotationName) {
-
- // Get the unmerged list of attributes for the target annotation.
- List attributesList = attributesMap.get(annotationName);
- if (CollectionUtils.isEmpty(attributesList)) {
- return null;
- }
-
- // To start with, we populate the result with a copy of all attribute values
- // from the target annotation. A copy is necessary so that we do not
- // inadvertently mutate the state of the metadata passed to this method.
- AnnotationAttributes result = new AnnotationAttributes(attributesList.get(0));
-
- Set overridableAttributeNames = new HashSet<>(result.keySet());
- overridableAttributeNames.remove(AnnotationUtils.VALUE);
-
- // Since the map is a LinkedMultiValueMap, we depend on the ordering of
- // elements in the map and reverse the order of the keys in order to traverse
- // "down" the annotation hierarchy.
- List annotationTypes = new ArrayList<>(attributesMap.keySet());
- Collections.reverse(annotationTypes);
-
- // No need to revisit the target annotation type:
- annotationTypes.remove(annotationName);
-
- for (String currentAnnotationType : annotationTypes) {
- List currentAttributesList = attributesMap.get(currentAnnotationType);
- if (!ObjectUtils.isEmpty(currentAttributesList)) {
- Set metaAnns = metaAnnotationMap.get(currentAnnotationType);
- if (metaAnns != null && metaAnns.contains(annotationName)) {
- AnnotationAttributes currentAttributes = currentAttributesList.get(0);
- for (String overridableAttributeName : overridableAttributeNames) {
- Object value = currentAttributes.get(overridableAttributeName);
- if (value != null) {
- // Store the value, potentially overriding a value from an attribute
- // of the same name found higher in the annotation hierarchy.
- result.put(overridableAttributeName, value);
- }
- }
- }
- }
- }
-
- return result;
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
deleted file mode 100644
index c80520cb5e..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.Attribute;
-import org.springframework.asm.ClassVisitor;
-import org.springframework.asm.FieldVisitor;
-import org.springframework.asm.MethodVisitor;
-import org.springframework.asm.Opcodes;
-import org.springframework.asm.SpringAsmInfo;
-import org.springframework.core.type.ClassMetadata;
-import org.springframework.lang.Nullable;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.StringUtils;
-
-/**
- * ASM class visitor which looks only for the class name and implemented types,
- * exposing them through the {@link org.springframework.core.type.ClassMetadata}
- * interface.
- *
- * @author Rod Johnson
- * @author Costin Leau
- * @author Mark Fisher
- * @author Ramnivas Laddad
- * @author Chris Beams
- * @since 2.5
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata {
-
- private String className = "";
-
- private boolean isInterface;
-
- private boolean isAnnotation;
-
- private boolean isAbstract;
-
- private boolean isFinal;
-
- @Nullable
- private String enclosingClassName;
-
- private boolean independentInnerClass;
-
- @Nullable
- private String superClassName;
-
- private String[] interfaces = new String[0];
-
- private final Set memberClassNames = new LinkedHashSet<>(4);
-
-
- public ClassMetadataReadingVisitor() {
- super(SpringAsmInfo.ASM_VERSION);
- }
-
-
- @Override
- public void visit(
- int version, int access, String name, String signature, @Nullable String supername, String[] interfaces) {
-
- this.className = ClassUtils.convertResourcePathToClassName(name);
- this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
- this.isAnnotation = ((access & Opcodes.ACC_ANNOTATION) != 0);
- this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0);
- this.isFinal = ((access & Opcodes.ACC_FINAL) != 0);
- if (supername != null && !this.isInterface) {
- this.superClassName = ClassUtils.convertResourcePathToClassName(supername);
- }
- this.interfaces = new String[interfaces.length];
- for (int i = 0; i < interfaces.length; i++) {
- this.interfaces[i] = ClassUtils.convertResourcePathToClassName(interfaces[i]);
- }
- }
-
- @Override
- public void visitOuterClass(String owner, String name, String desc) {
- this.enclosingClassName = ClassUtils.convertResourcePathToClassName(owner);
- }
-
- @Override
- public void visitInnerClass(String name, @Nullable String outerName, String innerName, int access) {
- if (outerName != null) {
- String fqName = ClassUtils.convertResourcePathToClassName(name);
- String fqOuterName = ClassUtils.convertResourcePathToClassName(outerName);
- if (this.className.equals(fqName)) {
- this.enclosingClassName = fqOuterName;
- this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0);
- }
- else if (this.className.equals(fqOuterName)) {
- this.memberClassNames.add(fqName);
- }
- }
- }
-
- @Override
- public void visitSource(String source, String debug) {
- // no-op
- }
-
- @Override
- @Nullable
- public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
- // no-op
- return new EmptyAnnotationVisitor();
- }
-
- @Override
- public void visitAttribute(Attribute attr) {
- // no-op
- }
-
- @Override
- public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
- // no-op
- return new EmptyFieldVisitor();
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- // no-op
- return new EmptyMethodVisitor();
- }
-
- @Override
- public void visitEnd() {
- // no-op
- }
-
-
- @Override
- public String getClassName() {
- return this.className;
- }
-
- @Override
- public boolean isInterface() {
- return this.isInterface;
- }
-
- @Override
- public boolean isAnnotation() {
- return this.isAnnotation;
- }
-
- @Override
- public boolean isAbstract() {
- return this.isAbstract;
- }
-
- @Override
- public boolean isFinal() {
- return this.isFinal;
- }
-
- @Override
- public boolean isIndependent() {
- return (this.enclosingClassName == null || this.independentInnerClass);
- }
-
- @Override
- public boolean hasEnclosingClass() {
- return (this.enclosingClassName != null);
- }
-
- @Override
- @Nullable
- public String getEnclosingClassName() {
- return this.enclosingClassName;
- }
-
- @Override
- @Nullable
- public String getSuperClassName() {
- return this.superClassName;
- }
-
- @Override
- public String[] getInterfaceNames() {
- return this.interfaces;
- }
-
- @Override
- public String[] getMemberClassNames() {
- return StringUtils.toStringArray(this.memberClassNames);
- }
-
-
- private static class EmptyAnnotationVisitor extends AnnotationVisitor {
-
- public EmptyAnnotationVisitor() {
- super(SpringAsmInfo.ASM_VERSION);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String name, String desc) {
- return this;
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return this;
- }
- }
-
-
- private static class EmptyMethodVisitor extends MethodVisitor {
-
- public EmptyMethodVisitor() {
- super(SpringAsmInfo.ASM_VERSION);
- }
- }
-
-
- private static class EmptyFieldVisitor extends FieldVisitor {
-
- public EmptyFieldVisitor() {
- super(SpringAsmInfo.ASM_VERSION);
- }
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
deleted file mode 100644
index f352428b33..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2002-2020 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.MethodVisitor;
-import org.springframework.asm.Opcodes;
-import org.springframework.asm.SpringAsmInfo;
-import org.springframework.asm.Type;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.annotation.MergedAnnotations;
-import org.springframework.core.type.MethodMetadata;
-import org.springframework.lang.Nullable;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-
-/**
- * ASM method visitor which looks for the annotations defined on a method,
- * exposing them through the {@link org.springframework.core.type.MethodMetadata}
- * interface.
- *
- * @author Juergen Hoeller
- * @author Mark Pollack
- * @author Costin Leau
- * @author Chris Beams
- * @author Phillip Webb
- * @since 3.0
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-public class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
-
- protected final String methodName;
-
- protected final int access;
-
- protected final String declaringClassName;
-
- protected final String returnTypeName;
-
- @Nullable
- protected final ClassLoader classLoader;
-
- protected final Set methodMetadataSet;
-
- protected final Map> metaAnnotationMap = new LinkedHashMap<>(4);
-
- protected final LinkedMultiValueMap attributesMap = new LinkedMultiValueMap<>(3);
-
-
- public MethodMetadataReadingVisitor(String methodName, int access, String declaringClassName,
- String returnTypeName, @Nullable ClassLoader classLoader, Set methodMetadataSet) {
-
- super(SpringAsmInfo.ASM_VERSION);
- this.methodName = methodName;
- this.access = access;
- this.declaringClassName = declaringClassName;
- this.returnTypeName = returnTypeName;
- this.classLoader = classLoader;
- this.methodMetadataSet = methodMetadataSet;
- }
-
-
- @Override
- public MergedAnnotations getAnnotations() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Nullable
- public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
- if (!visible) {
- return null;
- }
- this.methodMetadataSet.add(this);
- String className = Type.getType(desc).getClassName();
- return new AnnotationAttributesReadingVisitor(
- className, this.attributesMap, this.metaAnnotationMap, this.classLoader);
- }
-
-
- @Override
- public String getMethodName() {
- return this.methodName;
- }
-
- @Override
- public boolean isAbstract() {
- return ((this.access & Opcodes.ACC_ABSTRACT) != 0);
- }
-
- @Override
- public boolean isStatic() {
- return ((this.access & Opcodes.ACC_STATIC) != 0);
- }
-
- @Override
- public boolean isFinal() {
- return ((this.access & Opcodes.ACC_FINAL) != 0);
- }
-
- @Override
- public boolean isOverridable() {
- return (!isStatic() && !isFinal() && ((this.access & Opcodes.ACC_PRIVATE) == 0));
- }
-
- @Override
- public boolean isAnnotated(String annotationName) {
- return this.attributesMap.containsKey(annotationName);
- }
-
- @Override
- @Nullable
- public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) {
- AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(
- this.attributesMap, this.metaAnnotationMap, annotationName);
- if (raw == null) {
- return null;
- }
- return AnnotationReadingVisitorUtils.convertClassValues(
- "method '" + getMethodName() + "'", this.classLoader, raw, classValuesAsString);
- }
-
- @Override
- @Nullable
- public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
- if (!this.attributesMap.containsKey(annotationName)) {
- return null;
- }
- MultiValueMap allAttributes = new LinkedMultiValueMap<>();
- List attributesList = this.attributesMap.get(annotationName);
- if (attributesList != null) {
- String annotatedElement = "method '" + getMethodName() + '\'';
- for (AnnotationAttributes annotationAttributes : attributesList) {
- AnnotationAttributes convertedAttributes = AnnotationReadingVisitorUtils.convertClassValues(
- annotatedElement, this.classLoader, annotationAttributes, classValuesAsString);
- convertedAttributes.forEach(allAttributes::add);
- }
- }
- return allAttributes;
- }
-
- @Override
- public String getDeclaringClassName() {
- return this.declaringClassName;
- }
-
- @Override
- public String getReturnTypeName() {
- return this.returnTypeName;
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java
deleted file mode 100644
index 68bc0258aa..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.Type;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.lang.Nullable;
-import org.springframework.util.ObjectUtils;
-
-/**
- * {@link AnnotationVisitor} to recursively visit annotation arrays.
- *
- * @author Chris Beams
- * @author Juergen Hoeller
- * @since 3.1.1
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-class RecursiveAnnotationArrayVisitor extends AbstractRecursiveAnnotationVisitor {
-
- private final String attributeName;
-
- private final List allNestedAttributes = new ArrayList<>();
-
-
- public RecursiveAnnotationArrayVisitor(
- String attributeName, AnnotationAttributes attributes, @Nullable ClassLoader classLoader) {
-
- super(classLoader, attributes);
- this.attributeName = attributeName;
- }
-
-
- @Override
- public void visit(String attributeName, Object attributeValue) {
- Object newValue = attributeValue;
- Object existingValue = this.attributes.get(this.attributeName);
- if (existingValue != null) {
- newValue = ObjectUtils.addObjectToArray((Object[]) existingValue, newValue);
- }
- else {
- Class> arrayClass = newValue.getClass();
- if (Enum.class.isAssignableFrom(arrayClass)) {
- while (arrayClass.getSuperclass() != null && !arrayClass.isEnum()) {
- arrayClass = arrayClass.getSuperclass();
- }
- }
- Object[] newArray = (Object[]) Array.newInstance(arrayClass, 1);
- newArray[0] = newValue;
- newValue = newArray;
- }
- this.attributes.put(this.attributeName, newValue);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String attributeName, String asmTypeDescriptor) {
- String annotationType = Type.getType(asmTypeDescriptor).getClassName();
- AnnotationAttributes nestedAttributes = new AnnotationAttributes(annotationType, this.classLoader);
- this.allNestedAttributes.add(nestedAttributes);
- return new RecursiveAnnotationAttributesVisitor(annotationType, nestedAttributes, this.classLoader);
- }
-
- @Override
- public void visitEnd() {
- if (!this.allNestedAttributes.isEmpty()) {
- this.attributes.put(this.attributeName, this.allNestedAttributes.toArray(new AnnotationAttributes[0]));
- }
- else if (!this.attributes.containsKey(this.attributeName)) {
- Class extends Annotation> annotationType = this.attributes.annotationType();
- if (annotationType != null) {
- try {
- Class> attributeType = annotationType.getMethod(this.attributeName).getReturnType();
- if (attributeType.isArray()) {
- Class> elementType = attributeType.getComponentType();
- if (elementType.isAnnotation()) {
- elementType = AnnotationAttributes.class;
- }
- this.attributes.put(this.attributeName, Array.newInstance(elementType, 0));
- }
- }
- catch (NoSuchMethodException ex) {
- // Corresponding attribute method not found: cannot expose empty array.
- }
- }
- }
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationAttributesVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationAttributesVisitor.java
deleted file mode 100644
index b5953c8dad..0000000000
--- a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationAttributesVisitor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import org.springframework.asm.AnnotationVisitor;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.lang.Nullable;
-
-/**
- * {@link AnnotationVisitor} to recursively visit annotation attributes.
- *
- * @author Chris Beams
- * @author Juergen Hoeller
- * @since 3.1.1
- * @deprecated As of Spring Framework 5.2, this class and related classes in this
- * package have been replaced by {@link SimpleAnnotationMetadataReadingVisitor}
- * and related classes for internal use within the framework.
- */
-@Deprecated
-class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVisitor {
-
- protected final String annotationType;
-
-
- public RecursiveAnnotationAttributesVisitor(
- String annotationType, AnnotationAttributes attributes, @Nullable ClassLoader classLoader) {
-
- super(classLoader, attributes);
- this.annotationType = annotationType;
- }
-
-
- @Override
- public void visitEnd() {
- AnnotationUtils.registerDefaultValues(this.attributes);
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/lang/UsesJava7.java b/spring-core/src/main/java/org/springframework/lang/UsesJava7.java
deleted file mode 100644
index c59159c472..0000000000
--- a/spring-core/src/main/java/org/springframework/lang/UsesJava7.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.lang;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated element uses Java 7 specific API constructs,
- * without implying that it strictly requires Java 7.
- *
- * @author Stephane Nicoll
- * @since 4.1
- * @deprecated as of 5.0 since the framework is based on Java 8+ now
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
-@Documented
-@Deprecated
-public @interface UsesJava7 {
-}
diff --git a/spring-core/src/main/java/org/springframework/lang/UsesJava8.java b/spring-core/src/main/java/org/springframework/lang/UsesJava8.java
deleted file mode 100644
index 1c2416b576..0000000000
--- a/spring-core/src/main/java/org/springframework/lang/UsesJava8.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.lang;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated element uses Java 8 specific API constructs,
- * without implying that it strictly requires Java 8.
- *
- * @author Stephane Nicoll
- * @since 4.1
- * @deprecated as of 5.0 since the framework is based on Java 8+ now
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
-@Documented
-@Deprecated
-public @interface UsesJava8 {
-}
diff --git a/spring-core/src/main/java/org/springframework/lang/UsesSunHttpServer.java b/spring-core/src/main/java/org/springframework/lang/UsesSunHttpServer.java
deleted file mode 100644
index 2147079f0a..0000000000
--- a/spring-core/src/main/java/org/springframework/lang/UsesSunHttpServer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.lang;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated element uses the Http Server available in
- * {@code com.sun.*} classes, which is only available on a Sun/Oracle JVM.
- *
- * @author Stephane Nicoll
- * @since 4.1
- * @deprecated as of 5.1, along with Spring's Sun HTTP Server support classes
- */
-@Deprecated
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
-@Documented
-public @interface UsesSunHttpServer {
-}
diff --git a/spring-core/src/main/java/org/springframework/lang/UsesSunMisc.java b/spring-core/src/main/java/org/springframework/lang/UsesSunMisc.java
deleted file mode 100644
index f86ccd9636..0000000000
--- a/spring-core/src/main/java/org/springframework/lang/UsesSunMisc.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2002-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.lang;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated element uses an API from the {@code sun.misc}
- * package.
- *
- * @author Stephane Nicoll
- * @since 4.3
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
-@Documented
-public @interface UsesSunMisc {
-}
diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java
index f5a703c301..297789e381 100644
--- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java
+++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java
@@ -558,42 +558,6 @@ public abstract class ObjectUtils {
return hash;
}
- /**
- * Return the same value as {@link Boolean#hashCode(boolean)}}.
- * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant
- */
- @Deprecated
- public static int hashCode(boolean bool) {
- return Boolean.hashCode(bool);
- }
-
- /**
- * Return the same value as {@link Double#hashCode(double)}}.
- * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant
- */
- @Deprecated
- public static int hashCode(double dbl) {
- return Double.hashCode(dbl);
- }
-
- /**
- * Return the same value as {@link Float#hashCode(float)}}.
- * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant
- */
- @Deprecated
- public static int hashCode(float flt) {
- return Float.hashCode(flt);
- }
-
- /**
- * Return the same value as {@link Long#hashCode(long)}}.
- * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant
- */
- @Deprecated
- public static int hashCode(long lng) {
- return Long.hashCode(lng);
- }
-
//---------------------------------------------------------------------
// Convenience methods for toString output
diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java
index 5b5c762408..313979e87e 100644
--- a/spring-core/src/main/java/org/springframework/util/StringUtils.java
+++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java
@@ -886,18 +886,6 @@ public abstract class StringUtils {
}
}
- /**
- * Determine the RFC 3066 compliant language tag,
- * as used for the HTTP "Accept-Language" header.
- * @param locale the Locale to transform to a language tag
- * @return the RFC 3066 compliant language tag as {@code String}
- * @deprecated as of 5.0.4, in favor of {@link Locale#toLanguageTag()}
- */
- @Deprecated
- public static String toLanguageTag(Locale locale) {
- return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : "");
- }
-
/**
* Parse the given {@code timeZoneString} value into a {@link TimeZone}.
* @param timeZoneString the time zone {@code String}, following {@link TimeZone#getTimeZone(String)}
@@ -983,37 +971,6 @@ public abstract class StringUtils {
return newArr;
}
- /**
- * Merge the given {@code String} arrays into one, with overlapping
- * array elements only included once.
- *
The order of elements in the original arrays is preserved
- * (with the exception of overlapping elements, which are only
- * included on their first occurrence).
- * @param array1 the first array (can be {@code null})
- * @param array2 the second array (can be {@code null})
- * @return the new array ({@code null} if both given arrays were {@code null})
- * @deprecated as of 4.3.15, in favor of manual merging via {@link LinkedHashSet}
- * (with every entry included at most once, even entries within the first array)
- */
- @Deprecated
- @Nullable
- public static String[] mergeStringArrays(@Nullable String[] array1, @Nullable String[] array2) {
- if (ObjectUtils.isEmpty(array1)) {
- return array2;
- }
- if (ObjectUtils.isEmpty(array2)) {
- return array1;
- }
-
- List result = new ArrayList<>(Arrays.asList(array1));
- for (String str : array2) {
- if (!result.contains(str)) {
- result.add(str);
- }
- }
- return toStringArray(result);
- }
-
/**
* Sort the given {@code String} array if necessary.
* @param array the original array (potentially empty)
diff --git a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java
deleted file mode 100644
index a7e3565c44..0000000000
--- a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.util.comparator;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-
-/**
- * A comparator that chains a sequence of one or more Comparators.
- *
- *
A compound comparator calls each Comparator in sequence until a single
- * Comparator returns a non-zero result, or the comparators are exhausted and
- * zero is returned.
- *
- *
This facilitates in-memory sorting similar to multi-column sorting in SQL.
- * The order of any single Comparator in the list can also be reversed.
- *
- * @author Keith Donald
- * @author Juergen Hoeller
- * @since 1.2.2
- * @param the type of objects that may be compared by this comparator
- * @deprecated as of Spring Framework 5.0, in favor of the standard JDK 8
- * {@link Comparator#thenComparing(Comparator)}
- */
-@Deprecated
-@SuppressWarnings({"serial", "rawtypes"})
-public class CompoundComparator implements Comparator, Serializable {
-
- private final List comparators;
-
-
- /**
- * Construct a CompoundComparator with initially no Comparators. Clients
- * must add at least one Comparator before calling the compare method or an
- * IllegalStateException is thrown.
- */
- public CompoundComparator() {
- this.comparators = new ArrayList<>();
- }
-
- /**
- * Construct a CompoundComparator from the Comparators in the provided array.
- *
All Comparators will default to ascending sort order,
- * unless they are InvertibleComparators.
- * @param comparators the comparators to build into a compound comparator
- * @see InvertibleComparator
- */
- @SuppressWarnings("unchecked")
- public CompoundComparator(Comparator... comparators) {
- Assert.notNull(comparators, "Comparators must not be null");
- this.comparators = new ArrayList<>(comparators.length);
- for (Comparator comparator : comparators) {
- addComparator(comparator);
- }
- }
-
-
- /**
- * Add a Comparator to the end of the chain.
- *
The Comparator will default to ascending sort order,
- * unless it is a InvertibleComparator.
- * @param comparator the Comparator to add to the end of the chain
- * @see InvertibleComparator
- */
- @SuppressWarnings("unchecked")
- public void addComparator(Comparator extends T> comparator) {
- if (comparator instanceof InvertibleComparator) {
- this.comparators.add((InvertibleComparator) comparator);
- }
- else {
- this.comparators.add(new InvertibleComparator(comparator));
- }
- }
-
- /**
- * Add a Comparator to the end of the chain using the provided sort order.
- * @param comparator the Comparator to add to the end of the chain
- * @param ascending the sort order: ascending (true) or descending (false)
- */
- @SuppressWarnings("unchecked")
- public void addComparator(Comparator extends T> comparator, boolean ascending) {
- this.comparators.add(new InvertibleComparator(comparator, ascending));
- }
-
- /**
- * Replace the Comparator at the given index.
- *
The Comparator will default to ascending sort order,
- * unless it is a InvertibleComparator.
- * @param index the index of the Comparator to replace
- * @param comparator the Comparator to place at the given index
- * @see InvertibleComparator
- */
- @SuppressWarnings("unchecked")
- public void setComparator(int index, Comparator extends T> comparator) {
- if (comparator instanceof InvertibleComparator) {
- this.comparators.set(index, (InvertibleComparator) comparator);
- }
- else {
- this.comparators.set(index, new InvertibleComparator(comparator));
- }
- }
-
- /**
- * Replace the Comparator at the given index using the given sort order.
- * @param index the index of the Comparator to replace
- * @param comparator the Comparator to place at the given index
- * @param ascending the sort order: ascending (true) or descending (false)
- */
- public void setComparator(int index, Comparator comparator, boolean ascending) {
- this.comparators.set(index, new InvertibleComparator<>(comparator, ascending));
- }
-
- /**
- * Invert the sort order of each sort definition contained by this compound
- * comparator.
- */
- public void invertOrder() {
- for (InvertibleComparator comparator : this.comparators) {
- comparator.invertOrder();
- }
- }
-
- /**
- * Invert the sort order of the sort definition at the specified index.
- * @param index the index of the comparator to invert
- */
- public void invertOrder(int index) {
- this.comparators.get(index).invertOrder();
- }
-
- /**
- * Change the sort order at the given index to ascending.
- * @param index the index of the comparator to change
- */
- public void setAscendingOrder(int index) {
- this.comparators.get(index).setAscending(true);
- }
-
- /**
- * Change the sort order at the given index to descending sort.
- * @param index the index of the comparator to change
- */
- public void setDescendingOrder(int index) {
- this.comparators.get(index).setAscending(false);
- }
-
- /**
- * Returns the number of aggregated comparators.
- */
- public int getComparatorCount() {
- return this.comparators.size();
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public int compare(T o1, T o2) {
- Assert.state(!this.comparators.isEmpty(),
- "No sort definitions have been added to this CompoundComparator to compare");
- for (InvertibleComparator comparator : this.comparators) {
- int result = comparator.compare(o1, o2);
- if (result != 0) {
- return result;
- }
- }
- return 0;
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public boolean equals(@Nullable Object other) {
- return (this == other || (other instanceof CompoundComparator &&
- this.comparators.equals(((CompoundComparator) other).comparators)));
- }
-
- @Override
- public int hashCode() {
- return this.comparators.hashCode();
- }
-
- @Override
- public String toString() {
- return "CompoundComparator: " + this.comparators;
- }
-
-}
diff --git a/spring-core/src/main/java/org/springframework/util/comparator/InvertibleComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/InvertibleComparator.java
deleted file mode 100644
index 7da876615b..0000000000
--- a/spring-core/src/main/java/org/springframework/util/comparator/InvertibleComparator.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2002-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.util.comparator;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-
-/**
- * A decorator for a comparator, with an "ascending" flag denoting
- * whether comparison results should be treated in forward (standard
- * ascending) order or flipped for reverse (descending) order.
- *
- * @author Keith Donald
- * @author Juergen Hoeller
- * @since 1.2.2
- * @param the type of objects that may be compared by this comparator
- * @deprecated as of Spring Framework 5.0, in favor of the standard JDK 8
- * {@link Comparator#reversed()}
- */
-@Deprecated
-@SuppressWarnings("serial")
-public class InvertibleComparator implements Comparator, Serializable {
-
- private final Comparator comparator;
-
- private boolean ascending = true;
-
-
- /**
- * Create an InvertibleComparator that sorts ascending by default.
- * For the actual comparison, the specified Comparator will be used.
- * @param comparator the comparator to decorate
- */
- public InvertibleComparator(Comparator comparator) {
- Assert.notNull(comparator, "Comparator must not be null");
- this.comparator = comparator;
- }
-
- /**
- * Create an InvertibleComparator that sorts based on the provided order.
- * For the actual comparison, the specified Comparator will be used.
- * @param comparator the comparator to decorate
- * @param ascending the sort order: ascending (true) or descending (false)
- */
- public InvertibleComparator(Comparator comparator, boolean ascending) {
- Assert.notNull(comparator, "Comparator must not be null");
- this.comparator = comparator;
- setAscending(ascending);
- }
-
-
- /**
- * Specify the sort order: ascending (true) or descending (false).
- */
- public void setAscending(boolean ascending) {
- this.ascending = ascending;
- }
-
- /**
- * Return the sort order: ascending (true) or descending (false).
- */
- public boolean isAscending() {
- return this.ascending;
- }
-
- /**
- * Invert the sort order: ascending → descending or
- * descending → ascending.
- */
- public void invertOrder() {
- this.ascending = !this.ascending;
- }
-
-
- @Override
- public int compare(T o1, T o2) {
- int result = this.comparator.compare(o1, o2);
- if (result != 0) {
- // Invert the order if it is a reverse sort.
- if (!this.ascending) {
- if (Integer.MIN_VALUE == result) {
- result = Integer.MAX_VALUE;
- }
- else {
- result *= -1;
- }
- }
- return result;
- }
- return 0;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public boolean equals(@Nullable Object other) {
- if (this == other) {
- return true;
- }
- if (!(other instanceof InvertibleComparator)) {
- return false;
- }
- InvertibleComparator otherComp = (InvertibleComparator) other;
- return (this.comparator.equals(otherComp.comparator) && this.ascending == otherComp.ascending);
- }
-
- @Override
- public int hashCode() {
- return this.comparator.hashCode();
- }
-
- @Override
- public String toString() {
- return "InvertibleComparator: [" + this.comparator + "]; ascending=" + this.ascending;
- }
-
-}
diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java
index a6baf3a8e7..ce383eec49 100644
--- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java
+++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2020 the original author or authors.
+ * Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ package org.springframework.core.annotation;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -36,7 +35,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets;
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet;
-import org.springframework.lang.UsesSunMisc;
import org.springframework.util.ReflectionUtils;
import static java.util.stream.Collectors.toList;
@@ -60,12 +58,6 @@ class AnnotationTypeMappingsTests {
AnnotationTypeMapping::getAnnotationType).containsExactly(SimpleAnnotation.class);
}
- @Test
- void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() {
- AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithSpringLangAnnotation.class);
- assertThat(mappings.size()).isEqualTo(1);
- }
-
@Test
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
@@ -526,12 +518,6 @@ class AnnotationTypeMappingsTests {
@interface SimpleAnnotation {
}
- @Retention(RetentionPolicy.RUNTIME)
- @Inherited
- @UsesSunMisc
- @interface WithSpringLangAnnotation {
- }
-
@Retention(RetentionPolicy.RUNTIME)
@interface AA {
}
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
deleted file mode 100644
index 844f56b86d..0000000000
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import org.springframework.asm.ClassReader;
-import org.springframework.core.io.DefaultResourceLoader;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.type.AbstractAnnotationMetadataTests;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.util.ClassUtils;
-
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-
-/**
- * Tests for {@link AnnotationMetadataReadingVisitor}.
- *
- * @author Phillip Webb
- * @author Sam Brannen
- */
-@SuppressWarnings("deprecation")
-class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTests {
-
- @Override
- protected AnnotationMetadata get(Class> source) {
- try {
- ClassLoader classLoader = source.getClassLoader();
- String className = source.getName();
- String resourcePath = ResourceLoader.CLASSPATH_URL_PREFIX
- + ClassUtils.convertClassNameToResourcePath(className)
- + ClassUtils.CLASS_FILE_SUFFIX;
- Resource resource = new DefaultResourceLoader().getResource(resourcePath);
- try (InputStream inputStream = new BufferedInputStream(
- resource.getInputStream())) {
- ClassReader classReader = new ClassReader(inputStream);
- AnnotationMetadataReadingVisitor metadata = new AnnotationMetadataReadingVisitor(
- classLoader);
- classReader.accept(metadata, ClassReader.SKIP_DEBUG);
- return metadata;
- }
- }
- catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- @Test
- @Disabled("equals() not implemented in deprecated AnnotationMetadataReadingVisitor")
- @Override
- public void verifyEquals() throws Exception {
- }
-
- @Test
- @Disabled("hashCode() not implemented in deprecated AnnotationMetadataReadingVisitor")
- @Override
- public void verifyHashCode() throws Exception {
- }
-
- @Test
- @Disabled("toString() not implemented in deprecated AnnotationMetadataReadingVisitor")
- @Override
- public void verifyToString() {
- }
-
- @Override
- @Test
- public void getAnnotationsReturnsDirectAnnotations() {
- assertThatExceptionOfType(UnsupportedOperationException.class)
- .isThrownBy(super::getAnnotationsReturnsDirectAnnotations);
- }
-
-}
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java
deleted file mode 100644
index d303b031bf..0000000000
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.core.type.classreading;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import org.springframework.asm.ClassReader;
-import org.springframework.core.io.DefaultResourceLoader;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.type.AbstractMethodMetadataTests;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.util.ClassUtils;
-
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-
-/**
- * Tests for {@link MethodMetadataReadingVisitor}.
- *
- * @author Phillip Webb
- * @author Sam Brannen
- */
-@SuppressWarnings("deprecation")
-class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests {
-
- @Override
- protected AnnotationMetadata get(Class> source) {
- try {
- ClassLoader classLoader = source.getClassLoader();
- String className = source.getName();
- String resourcePath = ResourceLoader.CLASSPATH_URL_PREFIX
- + ClassUtils.convertClassNameToResourcePath(className)
- + ClassUtils.CLASS_FILE_SUFFIX;
- Resource resource = new DefaultResourceLoader().getResource(resourcePath);
- try (InputStream inputStream = new BufferedInputStream(
- resource.getInputStream())) {
- ClassReader classReader = new ClassReader(inputStream);
- AnnotationMetadataReadingVisitor metadata = new AnnotationMetadataReadingVisitor(
- classLoader);
- classReader.accept(metadata, ClassReader.SKIP_DEBUG);
- return metadata;
- }
- }
- catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- @Test
- @Disabled("equals() not implemented in deprecated MethodMetadataReadingVisitor")
- @Override
- public void verifyEquals() throws Exception {
- }
-
- @Test
- @Disabled("hashCode() not implemented in deprecated MethodMetadataReadingVisitor")
- @Override
- public void verifyHashCode() throws Exception {
- }
-
- @Test
- @Disabled("toString() not implemented in deprecated MethodMetadataReadingVisitor")
- @Override
- public void verifyToString() {
- }
-
- @Test
- @Override
- public void getAnnotationsReturnsDirectAnnotations() {
- assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
- super::getAnnotationsReturnsDirectAnnotations);
- }
-
-}
diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
index c89286af88..5390d01782 100644
--- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
@@ -233,44 +233,6 @@ class ObjectUtilsTests {
assertThat(ObjectUtils.nullSafeEquals(new int[] {1, 2, 3}, new int[] {1, 2, 3})).isTrue();
}
- @Test
- @Deprecated
- void hashCodeWithBooleanFalse() {
- int expected = Boolean.FALSE.hashCode();
- assertThat(ObjectUtils.hashCode(false)).isEqualTo(expected);
- }
-
- @Test
- @Deprecated
- void hashCodeWithBooleanTrue() {
- int expected = Boolean.TRUE.hashCode();
- assertThat(ObjectUtils.hashCode(true)).isEqualTo(expected);
- }
-
- @Test
- @Deprecated
- void hashCodeWithDouble() {
- double dbl = 9830.43;
- int expected = Double.valueOf(dbl).hashCode();
- assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(expected);
- }
-
- @Test
- @Deprecated
- void hashCodeWithFloat() {
- float flt = 34.8f;
- int expected = (Float.valueOf(flt)).hashCode();
- assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
- }
-
- @Test
- @Deprecated
- void hashCodeWithLong() {
- long lng = 883L;
- int expected = (Long.valueOf(lng)).hashCode();
- assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
- }
-
@Test
void identityToString() {
Object obj = new Object();
diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java
index 2b46f73a56..24525c9f2d 100644
--- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java
@@ -440,21 +440,6 @@ class StringUtilsTests {
assertThat(StringUtils.concatenateStringArrays(null, null)).isNull();
}
- @Test
- @Deprecated
- void mergeStringArrays() {
- String[] input1 = new String[] {"myString2"};
- String[] input2 = new String[] {"myString1", "myString2"};
- String[] result = StringUtils.mergeStringArrays(input1, input2);
- assertThat(result.length).isEqualTo(2);
- assertThat(result[0]).isEqualTo("myString2");
- assertThat(result[1]).isEqualTo("myString1");
-
- assertThat(StringUtils.mergeStringArrays(input1, null)).isEqualTo(input1);
- assertThat(StringUtils.mergeStringArrays(null, input2)).isEqualTo(input2);
- assertThat(StringUtils.mergeStringArrays(null, null)).isNull();
- }
-
@Test
void sortStringArray() {
String[] input = new String[] {"myString2"};
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java
deleted file mode 100644
index bf60e2d81f..0000000000
--- a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.util.comparator;
-
-import java.util.Comparator;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-
-/**
- * Test for {@link CompoundComparator}.
- *
- * @author Keith Donald
- * @author Chris Beams
- * @author Phillip Webb
- */
-@Deprecated
-class CompoundComparatorTests {
-
- @Test
- void shouldNeedAtLeastOneComparator() {
- Comparator c = new CompoundComparator<>();
- assertThatIllegalStateException().isThrownBy(() ->
- c.compare("foo", "bar"));
- }
-
-}
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java
deleted file mode 100644
index df3f1a25e6..0000000000
--- a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2002-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.util.comparator;
-
-import java.util.Comparator;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-
-
-/**
- * Tests for {@link InvertibleComparator}.
- *
- * @author Keith Donald
- * @author Chris Beams
- * @author Phillip Webb
- */
-@Deprecated
-class InvertibleComparatorTests {
-
- private final Comparator comparator = new ComparableComparator<>();
-
-
- @Test
- void shouldNeedComparator() throws Exception {
- assertThatIllegalArgumentException().isThrownBy(() ->
- new InvertibleComparator<>(null));
- }
-
- @Test
- void shouldNeedComparatorWithAscending() throws Exception {
- assertThatIllegalArgumentException().isThrownBy(() ->
- new InvertibleComparator<>(null, true));
- }
-
- @Test
- void shouldDefaultToAscending() throws Exception {
- InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator);
- assertThat(invertibleComparator.isAscending()).isTrue();
- assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
- }
-
- @Test
- void shouldInvert() throws Exception {
- InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator);
- assertThat(invertibleComparator.isAscending()).isTrue();
- assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
- invertibleComparator.invertOrder();
- assertThat(invertibleComparator.isAscending()).isFalse();
- assertThat(invertibleComparator.compare(1, 2)).isEqualTo(1);
- }
-
- @Test
- void shouldCompareAscending() throws Exception {
- InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator, true);
- assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
- }
-
- @Test
- void shouldCompareDescending() throws Exception {
- InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator, false);
- assertThat(invertibleComparator.compare(1, 2)).isEqualTo(1);
- }
-
-}
diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
index fae62e1d37..f9fbd7b638 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
@@ -332,17 +332,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
throw new AccessException("Neither setter method nor field found for property '" + name + "'");
}
- /**
- * Get the last read invoker pair.
- * @deprecated as of 4.3.15 since it is not used within the framework anymore
- */
- @Deprecated
- @Nullable
- public Member getLastReadInvokerPair() {
- InvokerPair lastReadInvoker = this.lastReadInvokerPair;
- return (lastReadInvoker != null ? lastReadInvoker.member : null);
- }
-
@Nullable
private TypeDescriptor getTypeDescriptor(EvaluationContext context, Object target, String name) {
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BatchUpdateUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BatchUpdateUtils.java
deleted file mode 100644
index dcab3b2ca9..0000000000
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BatchUpdateUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2002-2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.jdbc.core;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.springframework.lang.Nullable;
-
-/**
- * Generic utility methods for working with JDBC batch statements.
- * Mainly for internal use within the framework.
- *
- * @author Thomas Risberg
- * @author Juergen Hoeller
- * @since 3.0
- * @deprecated as of 5.1.3, not used by {@link JdbcTemplate} anymore
- */
-@Deprecated
-public abstract class BatchUpdateUtils {
-
- public static int[] executeBatchUpdate(
- String sql, final List