Moved @Uses annotations to org.springframework.lang; fixed Base64Utils to declare Java 8, and fixed PathResource's declaration to refer to Java 7.
Issue: SPR-11604
This commit is contained in:
parent
77cbc53d1e
commit
f7b465390c
|
|
@ -135,9 +135,9 @@ configure(allprojects) { project ->
|
|||
signature: "$buildDir/javaApiSignature/javaApi.signature",
|
||||
classpath: sourceSets.main.compileClasspath.asPath) {
|
||||
path(path: sourceSets.main.output.classesDir)
|
||||
annotation(className: "org.springframework.core.UsesJava7")
|
||||
annotation(className: "org.springframework.core.UsesJava8")
|
||||
annotation(className: "org.springframework.core.UsesSunHttpServer")
|
||||
annotation(className: "org.springframework.lang.UsesJava7")
|
||||
annotation(className: "org.springframework.lang.UsesJava8")
|
||||
annotation(className: "org.springframework.lang.UsesSunHttpServer")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.beans.propertyeditors;
|
|||
import java.beans.PropertyEditorSupport;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* Editor for {@code java.time.ZoneId}, translating zone ID Strings into {@code ZoneId}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.TimeZone;
|
|||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* A context that holds user-specific <code>java.time</code> (JSR-310) settings
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ package org.springframework.format.datetime.standard;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* A holder for a thread-local user {@link DateTimeContext}.
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import java.time.chrono.ChronoZonedDateTime;
|
|||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterRegistry;
|
||||
import org.springframework.format.datetime.DateFormatterRegistrar;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* Installs lower-level type converters required to integrate
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.time.format.FormatStyle;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ import java.time.format.FormatStyle;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.format.FormatterRegistrar;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* Configures the JSR-310 <code>java.time</code> formatting system for use with Spring.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import java.text.ParseException;
|
|||
import java.time.Instant;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* {@link Formatter} implementation for a JSR-310 {@link java.time.Instant},
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.format.Parser;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* {@link Parser} implementation for a JSR-310 {@link java.time.temporal.TemporalAccessor},
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.format.Printer;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* {@link Printer} implementation for a JSR-310 {@link java.time.temporal.TemporalAccessor},
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.UsesSunHttpServer;
|
||||
import org.springframework.lang.UsesSunHttpServer;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.beans.factory.FactoryBean} that creates a simple
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
|
||||
/**
|
||||
* A Spring {@link FactoryBean} that builds and exposes a preconfigured {@link ForkJoinPool}.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import java.lang.reflect.Constructor;
|
|||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* {@link ParameterNameDiscoverer} implementation which uses JDK 8's reflection facilities
|
||||
* for introspecting parameter names (based on the "-parameters" compiler flag).
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ package org.springframework.core.convert.support;
|
|||
import java.time.ZoneId;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* Simple converter from Java 8's {@link java.time.ZoneId} to {@link java.util.TimeZone}.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import java.time.ZonedDateTime;
|
|||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* Simple converter from Java 8's {@link java.time.ZonedDateTime} to {@link java.util.Calendar}.
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.nio.file.OpenOption;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +40,7 @@ import org.springframework.util.Assert;
|
|||
* @since 4.0
|
||||
* @see java.nio.file.Path
|
||||
*/
|
||||
@UsesJava8
|
||||
@UsesJava7
|
||||
public class PathResource extends AbstractResource implements WritableResource {
|
||||
|
||||
private final Path path;
|
||||
|
|
@ -49,8 +49,8 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
/**
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i> the
|
||||
* given root:
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @param path a Path handle
|
||||
*/
|
||||
|
|
@ -62,8 +62,8 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
/**
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i> the
|
||||
* given root:
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @param path a path
|
||||
* @see java.nio.file.Paths#get(String, String...)
|
||||
|
|
@ -76,8 +76,8 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
/**
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i> the
|
||||
* given root:
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @see java.nio.file.Paths#get(URI)
|
||||
* @param uri a path URI
|
||||
|
|
@ -121,11 +121,11 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
*/
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
if(!exists()) {
|
||||
throw new FileNotFoundException(getPath() + " (No such file or directory)");
|
||||
if (!exists()) {
|
||||
throw new FileNotFoundException(getPath() + " (no such file or directory)");
|
||||
}
|
||||
if(Files.isDirectory(this.path)) {
|
||||
throw new FileNotFoundException(getPath() + " (Is a directory)");
|
||||
if (Files.isDirectory(this.path)) {
|
||||
throw new FileNotFoundException(getPath() + " (is a directory)");
|
||||
}
|
||||
return Files.newInputStream(this.path);
|
||||
}
|
||||
|
|
@ -160,8 +160,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
catch (UnsupportedOperationException ex) {
|
||||
// only Paths on the default file system can be converted to a File
|
||||
// do exception translation for cases where conversion is not possible
|
||||
throw new FileNotFoundException(this.path + " cannot be resolved to "
|
||||
+ "absolute file path");
|
||||
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +227,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
if(Files.isDirectory(this.path)) {
|
||||
throw new FileNotFoundException(getPath() + " (Is a directory)");
|
||||
throw new FileNotFoundException(getPath() + " (is a directory)");
|
||||
}
|
||||
return Files.newOutputStream(this.path);
|
||||
}
|
||||
|
|
@ -239,7 +238,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
return (this == obj ||
|
||||
(obj instanceof PathResource && this.path.equals(((PathResource) obj).path)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core;
|
||||
package org.springframework.lang;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core;
|
||||
package org.springframework.lang;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core;
|
||||
package org.springframework.lang;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* Annotations indicating the use of core Java/JDK API beyond the API level of JDK 6 update 18.
|
||||
* Used descriptively within the framework codebase; validated by Animal Sniffer at build time.
|
||||
*
|
||||
*/
|
||||
package org.springframework.lang;
|
||||
|
||||
|
|
@ -19,6 +19,8 @@ package org.springframework.util;
|
|||
import java.nio.charset.Charset;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.springframework.lang.UsesJava8;
|
||||
|
||||
/**
|
||||
* A simple utility class for Base64 encoding and decoding.
|
||||
*
|
||||
|
|
@ -131,6 +133,7 @@ public abstract class Base64Utils {
|
|||
}
|
||||
|
||||
|
||||
@UsesJava8
|
||||
private static class JdkBase64Delegate implements Base64Delegate {
|
||||
|
||||
public byte[] encode(byte[] src) {
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import javax.sql.rowset.CachedRowSet;
|
|||
import javax.sql.rowset.RowSetFactory;
|
||||
import javax.sql.rowset.RowSetProvider;
|
||||
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.core.JdkVersion;
|
||||
import org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet;
|
||||
import org.springframework.jdbc.support.rowset.SqlRowSet;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ import javax.sql.DataSource;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -135,7 +135,7 @@ public abstract class JdbcUtils {
|
|||
* @return the value object
|
||||
* @throws SQLException if thrown by the JDBC API
|
||||
*/
|
||||
@UsesJava7 // guard use of JDBC 4.1 (safe with 1.6)
|
||||
@UsesJava7 // guard optional use of JDBC 4.1 (safe with 1.6 due to getObjectWithTypeAvailable check)
|
||||
public static Object getResultSetValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
|
||||
if (requiredType == null) {
|
||||
return getResultSetValue(rs, index);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
||||
import org.springframework.core.UsesSunHttpServer;
|
||||
import org.springframework.lang.UsesSunHttpServer;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
||||
import org.springframework.core.UsesSunHttpServer;
|
||||
import org.springframework.lang.UsesSunHttpServer;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.io.OutputStream;
|
|||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
||||
import org.springframework.core.UsesSunHttpServer;
|
||||
import org.springframework.lang.UsesSunHttpServer;
|
||||
import org.springframework.remoting.rmi.RemoteInvocationSerializingExporter;
|
||||
import org.springframework.remoting.support.RemoteInvocation;
|
||||
import org.springframework.remoting.support.RemoteInvocationResult;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.DisposableBean;
|
|||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
|
|||
* @see Endpoint#create(Object)
|
||||
* @see Endpoint#create(String, Object)
|
||||
*/
|
||||
@UsesJava7 // Endpoint#create with WebServiceFeature[]
|
||||
@UsesJava7 // optional use of Endpoint#create with WebServiceFeature[]
|
||||
protected Endpoint createEndpoint(Object bean) {
|
||||
if (this.endpointFeatures != null || this.webServiceFeatures != null) {
|
||||
WebServiceFeature[] endpointFeaturesToUse = this.endpointFeatures;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import javax.xml.ws.Service;
|
|||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.HandlerResolver;
|
||||
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
|
@ -147,7 +147,7 @@ public class LocalJaxWsServiceFactory {
|
|||
* @see #setServiceName
|
||||
* @see #setWsdlDocumentUrl
|
||||
*/
|
||||
@UsesJava7 // Service#create with WebServiceFeature[]
|
||||
@UsesJava7 // optional use of Service#create with WebServiceFeature[]
|
||||
public Service createJaxWsService() {
|
||||
Assert.notNull(this.serviceName, "No service name specified");
|
||||
Service service;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import com.sun.net.httpserver.HttpContext;
|
|||
import com.sun.net.httpserver.HttpServer;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.UsesSunHttpServer;
|
||||
|
||||
import org.springframework.lang.UsesSunHttpServer;
|
||||
|
||||
/**
|
||||
* Simple exporter for JAX-WS services, autodetecting annotated service beans
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.core.UsesJava8;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.UsesJava8;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ import javax.websocket.Extension;
|
|||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.springframework.core.UsesJava7;
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.UsesJava7;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
|
|
@ -146,7 +146,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
|
|||
return result;
|
||||
}
|
||||
|
||||
@UsesJava7
|
||||
@UsesJava7 // fallback to InetAddress.getLoopbackAddress()
|
||||
private InetAddress getLocalHost() {
|
||||
try {
|
||||
return InetAddress.getLocalHost();
|
||||
|
|
|
|||
Loading…
Reference in New Issue