Integrate animal sniffer

Animal sniffer provides tools to assist verifying that classes
compiled with a newer JDK are compatible with an older JDK.

This integratesthe latest version of the tool (1.11) that
permits the use of custom annotations. Added @UsesJava7,
@UsesJava8 and @UsesSunHttpServer and annotated the few places
where we rely on a specific environment.

The verification process can be invoked by running the 'sniff'
task.

Issue: SPR-11604

polishing
This commit is contained in:
Stephane Nicoll
2014-01-16 16:11:13 +01:00
parent e84f61bb9d
commit bd85c916eb
30 changed files with 247 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -28,6 +28,7 @@ import java.lang.reflect.Parameter;
* @since 4.0
* @see java.lang.reflect.Parameter#getName()
*/
@UsesJava8
public class StandardReflectionParameterNameDiscoverer implements ParameterNameDiscoverer {
@Override

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2002-2014 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;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Indicate that the annotated element uses Java7 specific constructs
* and therefore requires a Java7 environment.
*
* @author Stephane Nicoll
*/
@Retention(java.lang.annotation.RetentionPolicy.CLASS)
@Documented
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
public @interface UsesJava7 {
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2002-2014 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;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Indicate that the annotated element uses Java8 specific constructs
* and therefore requires a Java8 environment.
*
* @author Stephane Nicoll
* @since 4.1
*/
@Retention(java.lang.annotation.RetentionPolicy.CLASS)
@Documented
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
public @interface UsesJava8 {
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2002-2014 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;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Indicate 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
*/
@Retention(java.lang.annotation.RetentionPolicy.CLASS)
@Documented
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
public @interface UsesSunHttpServer {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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,6 +19,7 @@ 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;
/**
@@ -34,6 +35,7 @@ import org.springframework.core.convert.converter.Converter;
* @since 4.0
* @see TimeZone#getTimeZone(java.time.ZoneId)
*/
@UsesJava8
final class ZoneIdToTimeZoneConverter implements Converter<ZoneId, TimeZone> {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -20,6 +20,7 @@ import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.springframework.core.UsesJava8;
import org.springframework.core.convert.converter.Converter;
/**
@@ -35,6 +36,7 @@ import org.springframework.core.convert.converter.Converter;
* @since 4.0.1
* @see java.util.GregorianCalendar#from(java.time.ZonedDateTime)
*/
@UsesJava8
final class ZonedDateTimeToCalendarConverter implements Converter<ZonedDateTime, Calendar> {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -28,6 +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.util.Assert;
/**
@@ -39,6 +40,7 @@ import org.springframework.util.Assert;
* @since 4.0
* @see java.nio.file.Path
*/
@UsesJava8
public class PathResource extends AbstractResource implements WritableResource {
private final Path path;