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:
Juergen Hoeller
2014-06-04 21:34:23 +02:00
parent 77cbc53d1e
commit f7b465390c
31 changed files with 63 additions and 49 deletions

View File

@@ -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).

View File

@@ -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}.

View File

@@ -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}.

View File

@@ -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)));
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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) {