Broadly remove deprecated core classes and methods

Issue: SPR-14430
This commit is contained in:
Juergen Hoeller
2016-07-05 15:52:48 +02:00
parent 0fc0ce78ae
commit b5db5d3aac
119 changed files with 145 additions and 6086 deletions

View File

@@ -1,118 +0,0 @@
/*
* Copyright 2002-2015 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
*
* http://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;
/**
* Internal helper class used to find the Java/JVM version that Spring is
* operating on, to allow for automatically adapting to the present platform's
* capabilities.
*
* <p>Note that Spring requires JVM 1.6 or higher, as of Spring 4.0.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Rick Evans
* @author Sam Brannen
* @deprecated as of Spring 4.2.1, in favor of direct checks for the desired
* JDK API variants via reflection
*/
@Deprecated
public abstract class JdkVersion {
/**
* Constant identifying the 1.3.x JVM (JDK 1.3).
*/
public static final int JAVA_13 = 0;
/**
* Constant identifying the 1.4.x JVM (J2SE 1.4).
*/
public static final int JAVA_14 = 1;
/**
* Constant identifying the 1.5 JVM (Java 5).
*/
public static final int JAVA_15 = 2;
/**
* Constant identifying the 1.6 JVM (Java 6).
*/
public static final int JAVA_16 = 3;
/**
* Constant identifying the 1.7 JVM (Java 7).
*/
public static final int JAVA_17 = 4;
/**
* Constant identifying the 1.8 JVM (Java 8).
*/
public static final int JAVA_18 = 5;
/**
* Constant identifying the 1.9 JVM (Java 9).
*/
public static final int JAVA_19 = 6;
private static final String javaVersion;
private static final int majorJavaVersion;
static {
javaVersion = System.getProperty("java.version");
// version String should look like "1.4.2_10"
if (javaVersion.contains("1.9.")) {
majorJavaVersion = JAVA_19;
}
else if (javaVersion.contains("1.8.")) {
majorJavaVersion = JAVA_18;
}
else if (javaVersion.contains("1.7.")) {
majorJavaVersion = JAVA_17;
}
else {
// else leave 1.6 as default (it's either 1.6 or unknown)
majorJavaVersion = JAVA_16;
}
}
/**
* Return the full Java version string, as returned by
* {@code System.getProperty("java.version")}.
* @return the full Java version string
* @see System#getProperty(String)
*/
public static String getJavaVersion() {
return javaVersion;
}
/**
* Get the major version code. This means we can do things like
* {@code if (getMajorJavaVersion() >= JAVA_17)}.
* @return a code comparable to the {@code JAVA_XX} codes in this class
* @see #JAVA_16
* @see #JAVA_17
* @see #JAVA_18
* @see #JAVA_19
*/
public static int getMajorJavaVersion() {
return majorJavaVersion;
}
}

View File

@@ -295,24 +295,6 @@ public class AnnotatedElementUtils {
return Boolean.TRUE.equals(searchWithGetSemantics(element, null, annotationName, alwaysTrueAnnotationProcessor));
}
/**
* @deprecated As of Spring Framework 4.2, use {@link #getMergedAnnotationAttributes(AnnotatedElement, String)} instead.
*/
@Deprecated
public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement element, String annotationName) {
return getMergedAnnotationAttributes(element, annotationName);
}
/**
* @deprecated As of Spring Framework 4.2, use {@link #getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)} instead.
*/
@Deprecated
public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement element, String annotationName,
boolean classValuesAsString, boolean nestedAnnotationsAsMap) {
return getMergedAnnotationAttributes(element, annotationName, classValuesAsString, nestedAnnotationsAsMap);
}
/**
* Get the first annotation of the specified {@code annotationType} within
* the annotation hierarchy <em>above</em> the supplied {@code element} and
@@ -731,35 +713,6 @@ public class AnnotatedElementUtils {
return AnnotationUtils.synthesizeAnnotation(attributes, annotationType, element);
}
/**
* Find the first annotation of the specified {@code annotationName} within
* the annotation hierarchy <em>above</em> the supplied {@code element},
* merge that annotation's attributes with <em>matching</em> attributes from
* annotations in lower levels of the annotation hierarchy, and synthesize
* the result back into an annotation of the specified {@code annotationName}.
* <p>{@link AliasFor @AliasFor} semantics are fully supported, both
* within a single annotation and within the annotation hierarchy.
* <p>This method delegates to {@link #findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)}
* (supplying {@code false} for {@code classValuesAsString} and {@code nestedAnnotationsAsMap})
* and {@link AnnotationUtils#synthesizeAnnotation(Map, Class, AnnotatedElement)}.
* <p>This method follows <em>find semantics</em> as described in the
* {@linkplain AnnotatedElementUtils class-level javadoc}.
* @param element the annotated element
* @param annotationName the fully qualified class name of the annotation type to find
* @return the merged, synthesized {@code Annotation}, or {@code null} if not found
* @since 4.2
* @see #findMergedAnnotation(AnnotatedElement, Class)
* @see #findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
* @see AnnotationUtils#synthesizeAnnotation(Map, Class, AnnotatedElement)
* @deprecated As of Spring Framework 4.2.3, use {@link #findMergedAnnotation(AnnotatedElement, Class)} instead.
*/
@Deprecated
@SuppressWarnings("unchecked")
public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement element, String annotationName) {
AnnotationAttributes attributes = findMergedAnnotationAttributes(element, annotationName, false, false);
return AnnotationUtils.synthesizeAnnotation(attributes, (Class<A>) attributes.annotationType(), element);
}
/**
* Find <strong>all</strong> annotations of the specified {@code annotationType}
* within the annotation hierarchy <em>above</em> the supplied {@code element};

View File

@@ -257,36 +257,6 @@ public abstract class AnnotationUtils {
return null;
}
/**
* Delegates to {@link #getRepeatableAnnotations(AnnotatedElement, Class, Class)}.
* @since 4.0
* @see #getRepeatableAnnotations(AnnotatedElement, Class, Class)
* @see #getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class)
* @deprecated As of Spring Framework 4.2, use {@code getRepeatableAnnotations()}
* or {@code getDeclaredRepeatableAnnotations()} instead.
*/
@Deprecated
public static <A extends Annotation> Set<A> getRepeatableAnnotation(Method method,
Class<? extends Annotation> containerAnnotationType, Class<A> annotationType) {
return getRepeatableAnnotations(method, annotationType, containerAnnotationType);
}
/**
* Delegates to {@link #getRepeatableAnnotations(AnnotatedElement, Class, Class)}.
* @since 4.0
* @see #getRepeatableAnnotations(AnnotatedElement, Class, Class)
* @see #getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class)
* @deprecated As of Spring Framework 4.2, use {@code getRepeatableAnnotations()}
* or {@code getDeclaredRepeatableAnnotations()} instead.
*/
@Deprecated
public static <A extends Annotation> Set<A> getRepeatableAnnotation(AnnotatedElement annotatedElement,
Class<? extends Annotation> containerAnnotationType, Class<A> annotationType) {
return getRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType);
}
/**
* Get the <em>repeatable</em> {@linkplain Annotation annotations} of
* {@code annotationType} from the supplied {@link AnnotatedElement}, where

View File

@@ -546,12 +546,6 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
return this.propertyResolver.getProperty(key, targetType, defaultValue);
}
@Override
@Deprecated
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetType) {
return this.propertyResolver.getPropertyAsClass(key, targetType);
}
@Override
public String getRequiredProperty(String key) throws IllegalStateException {
return this.propertyResolver.getRequiredProperty(key);

View File

@@ -153,12 +153,6 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
return (value != null ? value : defaultValue);
}
@Override
@Deprecated
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetValueType) {
throw new UnsupportedOperationException();
}
@Override
public String getRequiredProperty(String key) throws IllegalStateException {
String value = getProperty(key);

View File

@@ -72,19 +72,6 @@ public interface PropertyResolver {
*/
<T> T getProperty(String key, Class<T> targetType, T defaultValue);
/**
* Convert the property value associated with the given key to a {@code Class}
* of type {@code T} or {@code null} if the key cannot be resolved.
* @throws org.springframework.core.convert.ConversionException if class specified
* by property value cannot be found or loaded or if targetType is not assignable
* from class specified by property value
* @see #getProperty(String, Class)
* @deprecated as of 4.3, in favor of {@link #getProperty} with manual conversion
* to {@code Class} via the application's {@code ClassLoader}
*/
@Deprecated
<T> Class<T> getPropertyAsClass(String key, Class<T> targetType);
/**
* Return the property value associated with the given key (never {@code null}).
* @throws IllegalStateException if the key cannot be resolved

View File

@@ -93,47 +93,6 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
return null;
}
@Override
@Deprecated
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetValueType) {
if (this.propertySources != null) {
for (PropertySource<?> propertySource : this.propertySources) {
if (logger.isTraceEnabled()) {
logger.trace(String.format("Searching for key '%s' in [%s]", key, propertySource.getName()));
}
Object value = propertySource.getProperty(key);
if (value != null) {
logKeyFound(key, propertySource, value);
Class<?> clazz;
if (value instanceof String) {
try {
clazz = ClassUtils.forName((String) value, null);
}
catch (Exception ex) {
throw new ClassConversionException((String) value, targetValueType, ex);
}
}
else if (value instanceof Class) {
clazz = (Class<?>) value;
}
else {
clazz = value.getClass();
}
if (!targetValueType.isAssignableFrom(clazz)) {
throw new ClassConversionException(clazz, targetValueType);
}
@SuppressWarnings("unchecked")
Class<T> targetClass = (Class<T>) clazz;
return targetClass;
}
}
}
if (logger.isDebugEnabled()) {
logger.debug(String.format("Could not find key '%s' in any property source", key));
}
return null;
}
/**
* Log the given key as found in the given {@link PropertySource}, resulting in
* the given value.
@@ -151,20 +110,4 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
}
}
@SuppressWarnings("serial")
@Deprecated
private static class ClassConversionException extends ConversionException {
public ClassConversionException(Class<?> actual, Class<?> expected) {
super(String.format("Actual type %s is not assignable to expected type %s",
actual.getName(), expected.getName()));
}
public ClassConversionException(String actual, Class<?> expected, Exception ex) {
super(String.format("Could not find/load class %s during attempt to convert to %s",
actual, expected.getName()), ex);
}
}
}

View File

@@ -551,16 +551,9 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
* @see java.net.JarURLConnection
* @see org.springframework.util.PathMatcher
*/
@SuppressWarnings("deprecation")
protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource, URL rootDirURL, String subPattern)
throws IOException {
// Check deprecated variant for potential overriding first...
Set<Resource> result = doFindPathMatchingJarResources(rootDirResource, subPattern);
if (result != null) {
return result;
}
URLConnection con = rootDirURL.openConnection();
JarFile jarFile;
String jarFileUrl;
@@ -614,7 +607,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
// The Sun JRE does not return a slash here, but BEA JRockit does.
rootEntryPath = rootEntryPath + "/";
}
result = new LinkedHashSet<Resource>(8);
Set<Resource> result = new LinkedHashSet<Resource>(8);
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
JarEntry entry = entries.nextElement();
String entryPath = entry.getName();
@@ -634,23 +627,6 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
}
}
/**
* Find all resources in jar files that match the given location pattern
* via the Ant-style PathMatcher.
* @param rootDirResource the root directory as Resource
* @param subPattern the sub pattern to match (below the root directory)
* @return a mutable Set of matching Resource instances
* @throws IOException in case of I/O errors
* @deprecated as of Spring 4.3, in favor of
* {@link #doFindPathMatchingJarResources(Resource, URL, String)}
*/
@Deprecated
protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource, String subPattern)
throws IOException {
return null;
}
/**
* Resolve the given jar file URL into a JarFile object.
*/

View File

@@ -281,17 +281,6 @@ public class MimeType implements Comparable<MimeType>, Serializable {
return (charSet != null ? Charset.forName(unquote(charSet)) : null);
}
/**
* Return the character set, as indicated by a {@code charset} parameter, if any.
* @return the character set, or {@code null} if not available
* @deprecated as of Spring 4.3, in favor of {@link #getCharset()} with its name
* aligned with the Java return type name
*/
@Deprecated
public Charset getCharSet() {
return getCharset();
}
/**
* Return a generic parameter value, given a parameter name.
* @param name the parameter name