From bd85c916eb98a8278ad55a393be4590a20eca4fd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 16 Jan 2014 16:11:13 +0100 Subject: [PATCH] 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 --- build.gradle | 47 +++++++++++++++++++ .../beans/propertyeditors/ZoneIdEditor.java | 5 +- .../datetime/joda/JodaTimeConverters.java | 2 +- .../datetime/standard/DateTimeContext.java | 4 +- .../standard/DateTimeContextHolder.java | 4 +- .../datetime/standard/DateTimeConverters.java | 41 +++++++++------- .../standard/DateTimeFormatterFactory.java | 4 +- .../standard/DateTimeFormatterRegistrar.java | 4 +- .../datetime/standard/InstantFormatter.java | 4 +- .../standard/TemporalAccessorParser.java | 4 +- .../standard/TemporalAccessorPrinter.java | 4 +- .../support/SimpleHttpServerFactoryBean.java | 4 +- .../concurrent/ForkJoinPoolFactoryBean.java | 4 +- ...dardReflectionParameterNameDiscoverer.java | 3 +- .../org/springframework/core/UsesJava7.java | 35 ++++++++++++++ .../org/springframework/core/UsesJava8.java | 36 ++++++++++++++ .../core/UsesSunHttpServer.java | 36 ++++++++++++++ .../support/ZoneIdToTimeZoneConverter.java | 4 +- .../ZonedDateTimeToCalendarConverter.java | 4 +- .../springframework/core/io/PathResource.java | 4 +- .../core/SqlRowSetResultSetExtractor.java | 2 + .../jdbc/support/JdbcUtils.java | 2 + .../caucho/SimpleBurlapServiceExporter.java | 4 +- .../caucho/SimpleHessianServiceExporter.java | 4 +- .../SimpleHttpInvokerServiceExporter.java | 4 +- .../jaxws/AbstractJaxWsServiceExporter.java | 4 +- .../jaxws/LocalJaxWsServiceFactory.java | 4 +- .../SimpleHttpServerJaxWsServiceExporter.java | 4 +- .../ServletRequestMethodArgumentResolver.java | 2 + .../standard/StandardWebSocketClient.java | 4 +- 30 files changed, 247 insertions(+), 40 deletions(-) create mode 100644 spring-core/src/main/java/org/springframework/core/UsesJava7.java create mode 100644 spring-core/src/main/java/org/springframework/core/UsesJava8.java create mode 100644 spring-core/src/main/java/org/springframework/core/UsesSunHttpServer.java diff --git a/build.gradle b/build.gradle index 5e1b9ea482..5597d37063 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ configure(allprojects) { project -> ext.tiles3Version = "3.0.3" ext.tomcatVersion = "8.0.5" ext.xstreamVersion = "1.4.7" + ext.snifferVersion = "1.11" ext.gradleScriptDir = "${rootProject.projectDir}/gradle" @@ -38,6 +39,11 @@ configure(allprojects) { project -> apply plugin: "test-source-set-dependencies" apply from: "${gradleScriptDir}/ide.gradle" + configurations { + sniffer + javaApiSignature + } + compileJava.options*.compilerArgs = [ "-Xlint:serial", "-Xlint:varargs", "-Xlint:cast", "-Xlint:classfile", "-Xlint:dep-ann", "-Xlint:divzero", "-Xlint:empty", "-Xlint:finally", @@ -89,6 +95,47 @@ configure(allprojects) { project -> exclude group:'org.hamcrest', module:'hamcrest-core' } testCompile("org.hamcrest:hamcrest-all:1.3") + testCompile("org.mockito:mockito-core:1.9.5") + + sniffer("org.codehaus.mojo:animal-sniffer-ant-tasks:${snifferVersion}") + javaApiSignature("org.codehaus.mojo.signature:java16:1.1@signature") // As from Java6_18 + } + + task copyJavaApiSignature(type: Copy) { + ext.to = file("$buildDir/javaApiSignature/") + description "Copy the resolved Animal Sniffer signature dependency artifact to a known location and name" + from configurations.javaApiSignature + into to + rename '.*signature', 'javaApi.signature' + } + + task sniff { + group = "Verification" + description = "Checks the Java API signatures" + + dependsOn compileJava + dependsOn copyJavaApiSignature + + inputs.dir sourceSets.main.output.classesDir + inputs.dir copyJavaApiSignature.to + outputs.upToDateWhen { true } + + doLast { + ant.taskdef( + name: 'animalSniffer', + classname: 'org.codehaus.mojo.animal_sniffer.ant.CheckSignatureTask', + classpath: configurations.sniffer.asPath + ) + + ant.animalSniffer( + 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") + } + } } ext.javadocLinks = [ diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ZoneIdEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ZoneIdEditor.java index 63bb9c44e8..e5b5ba2e4f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ZoneIdEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ZoneIdEditor.java @@ -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,8 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditorSupport; import java.time.ZoneId; +import org.springframework.core.UsesJava8; + /** * Editor for {@code java.time.ZoneId}, translating zone ID Strings into {@code ZoneId} * objects. Exposes the {@code TimeZone} ID as a text representation. @@ -28,6 +30,7 @@ import java.time.ZoneId; * @see java.time.ZoneId * @see TimeZoneEditor */ +@UsesJava8 public class ZoneIdEditor extends PropertyEditorSupport { @Override diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java index aa29be49d0..6d3435befc 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java @@ -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. diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java index 1d165ce923..257b213e74 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java @@ -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. @@ -24,6 +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; /** * A context that holds user-specific java.time (JSR-310) settings @@ -34,6 +35,7 @@ import org.springframework.context.i18n.TimeZoneAwareLocaleContext; * @since 4.0 * @see DateTimeContextHolder */ +@UsesJava8 public class DateTimeContext { private Chronology chronology; diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java index 85febf16bd..c9fef98bc2 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java @@ -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.format.datetime.standard; import java.time.format.DateTimeFormatter; import java.util.Locale; +import org.springframework.core.UsesJava8; import org.springframework.core.NamedThreadLocal; /** @@ -27,6 +28,7 @@ import org.springframework.core.NamedThreadLocal; * @author Juergen Hoeller * @since 4.0 */ +@UsesJava8 public final class DateTimeContextHolder { private static final ThreadLocal dateTimeContextHolder = diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java index d1a4919268..f4cb2bd6c8 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java @@ -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. @@ -26,6 +26,7 @@ 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; @@ -42,6 +43,7 @@ import org.springframework.format.datetime.DateFormatterRegistrar; * @author Juergen Hoeller * @since 4.0.1 */ +@UsesJava8 final class DateTimeConverters { /** @@ -83,7 +85,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class LocalDateTimeToLocalDateConverter implements Converter { @Override @@ -92,7 +94,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class LocalDateTimeToLocalTimeConverter implements Converter { @Override @@ -101,7 +103,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class ZonedDateTimeToLocalDateConverter implements Converter { @Override @@ -110,7 +112,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class ZonedDateTimeToLocalTimeConverter implements Converter { @Override @@ -119,7 +121,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class ZonedDateTimeToLocalDateTimeConverter implements Converter { @Override @@ -128,7 +130,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class ZonedDateTimeToOffsetDateTimeConverter implements Converter { @Override @@ -137,7 +139,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class ZonedDateTimeToInstantConverter implements Converter { @Override @@ -147,6 +149,7 @@ final class DateTimeConverters { } } + @UsesJava8 private static class OffsetDateTimeToLocalDateConverter implements Converter { @Override @@ -155,7 +158,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class OffsetDateTimeToLocalTimeConverter implements Converter { @Override @@ -164,7 +167,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class OffsetDateTimeToLocalDateTimeConverter implements Converter { @Override @@ -173,7 +176,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class OffsetDateTimeToZonedDateTimeConverter implements Converter { @Override @@ -182,7 +185,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class OffsetDateTimeToInstantConverter implements Converter { @Override @@ -191,7 +194,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToZonedDateTimeConverter implements Converter { @Override @@ -200,7 +203,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToOffsetDateTimeConverter implements Converter { @Override @@ -209,7 +212,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToLocalDateConverter implements Converter { @Override @@ -218,7 +221,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToLocalTimeConverter implements Converter { @Override @@ -227,7 +230,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToLocalDateTimeConverter implements Converter { @Override @@ -236,7 +239,7 @@ final class DateTimeConverters { } } - + @UsesJava8 private static class CalendarToInstantConverter implements Converter { @Override @@ -247,6 +250,7 @@ final class DateTimeConverters { } + @UsesJava8 private static class LongToInstantConverter implements Converter { @Override @@ -256,6 +260,7 @@ final class DateTimeConverters { } + @UsesJava8 private static class InstantToLongConverter implements Converter { @Override diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterFactory.java index fba9f7f857..71e9655e01 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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.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.util.Assert; import org.springframework.util.StringUtils; @@ -42,6 +43,7 @@ import org.springframework.util.StringUtils; * @see #setDateTimeStyle * @see DateTimeFormatterFactoryBean */ +@UsesJava8 public class DateTimeFormatterFactory { private String pattern; diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java index a514b65c28..1ce7e750e1 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java @@ -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.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; @@ -46,6 +47,7 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; * @see org.springframework.format.datetime.DateFormatterRegistrar * @see org.springframework.format.datetime.joda.DateTimeFormatterFactoryBean */ +@UsesJava8 public class DateTimeFormatterRegistrar implements FormatterRegistrar { private static enum Type {DATE, TIME, DATE_TIME} diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java index c968f9e46b..1022c4d4d7 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java @@ -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.text.ParseException; import java.time.Instant; import java.util.Locale; +import org.springframework.core.UsesJava8; import org.springframework.format.Formatter; /** @@ -31,6 +32,7 @@ import org.springframework.format.Formatter; * @since 4.0 * @see java.time.Instant#parse */ +@UsesJava8 public class InstantFormatter implements Formatter { @Override diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorParser.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorParser.java index dda2029ff3..9371879853 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorParser.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorParser.java @@ -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. @@ -27,6 +27,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAccessor; import java.util.Locale; +import org.springframework.core.UsesJava8; import org.springframework.format.Parser; /** @@ -43,6 +44,7 @@ import org.springframework.format.Parser; * @see java.time.OffsetDateTime#parse(CharSequence, java.time.format.DateTimeFormatter) * @see java.time.OffsetTime#parse(CharSequence, java.time.format.DateTimeFormatter) */ +@UsesJava8 public final class TemporalAccessorParser implements Parser { private final Class temporalAccessorType; diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorPrinter.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorPrinter.java index 92dceabec7..336a3dfc20 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorPrinter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorPrinter.java @@ -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.format.DateTimeFormatter; import java.time.temporal.TemporalAccessor; import java.util.Locale; +import org.springframework.core.UsesJava8; import org.springframework.format.Printer; /** @@ -31,6 +32,7 @@ import org.springframework.format.Printer; * @see DateTimeContextHolder#getFormatter * @see java.time.format.DateTimeFormatter#format(java.time.temporal.TemporalAccessor) */ +@UsesJava8 public final class TemporalAccessorPrinter implements Printer { private final DateTimeFormatter formatter; diff --git a/spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java b/spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java index 1cc5669e6c..f8fdb6dbc2 100644 --- a/spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -33,6 +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; /** * {@link org.springframework.beans.factory.FactoryBean} that creates a simple @@ -51,6 +52,7 @@ import org.springframework.beans.factory.InitializingBean; * @see #setPort * @see #setContexts */ +@UsesSunHttpServer public class SimpleHttpServerFactoryBean implements FactoryBean, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ForkJoinPoolFactoryBean.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ForkJoinPoolFactoryBean.java index 7d141ce51a..9960fdc931 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ForkJoinPoolFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ForkJoinPoolFactoryBean.java @@ -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. @@ -22,6 +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; /** * A Spring {@link FactoryBean} that builds and exposes a preconfigured {@link ForkJoinPool}. @@ -37,6 +38,7 @@ import org.springframework.beans.factory.InitializingBean; * @author Juergen Hoeller * @since 3.1 */ +@UsesJava7 public class ForkJoinPoolFactoryBean implements FactoryBean, InitializingBean, DisposableBean { private boolean commonPool = false; diff --git a/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java index d8a39bd47e..420e0d0208 100644 --- a/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java @@ -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 diff --git a/spring-core/src/main/java/org/springframework/core/UsesJava7.java b/spring-core/src/main/java/org/springframework/core/UsesJava7.java new file mode 100644 index 0000000000..ce8619a678 --- /dev/null +++ b/spring-core/src/main/java/org/springframework/core/UsesJava7.java @@ -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 { + +} diff --git a/spring-core/src/main/java/org/springframework/core/UsesJava8.java b/spring-core/src/main/java/org/springframework/core/UsesJava8.java new file mode 100644 index 0000000000..e4bf36db88 --- /dev/null +++ b/spring-core/src/main/java/org/springframework/core/UsesJava8.java @@ -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 { + +} diff --git a/spring-core/src/main/java/org/springframework/core/UsesSunHttpServer.java b/spring-core/src/main/java/org/springframework/core/UsesSunHttpServer.java new file mode 100644 index 0000000000..a9e66fa604 --- /dev/null +++ b/spring-core/src/main/java/org/springframework/core/UsesSunHttpServer.java @@ -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 { + +} diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ZoneIdToTimeZoneConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ZoneIdToTimeZoneConverter.java index e0416ea40e..afedc6648f 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ZoneIdToTimeZoneConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ZoneIdToTimeZoneConverter.java @@ -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 { @Override diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ZonedDateTimeToCalendarConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ZonedDateTimeToCalendarConverter.java index 02d6017dc4..d2bfb8a0d3 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ZonedDateTimeToCalendarConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ZonedDateTimeToCalendarConverter.java @@ -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 { @Override diff --git a/spring-core/src/main/java/org/springframework/core/io/PathResource.java b/spring-core/src/main/java/org/springframework/core/io/PathResource.java index 5a2c9f93b5..df48b89508 100644 --- a/spring-core/src/main/java/org/springframework/core/io/PathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/PathResource.java @@ -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; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlRowSetResultSetExtractor.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlRowSetResultSetExtractor.java index 7a69f2c44a..e254ff37eb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlRowSetResultSetExtractor.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlRowSetResultSetExtractor.java @@ -22,6 +22,7 @@ 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; @@ -109,6 +110,7 @@ public class SqlRowSetResultSetExtractor implements ResultSetExtractor requiredType) throws SQLException { if (requiredType == null) { return getResultSetValue(rs, index); diff --git a/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java index 430b41c5a0..cc35d4950e 100644 --- a/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java @@ -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. @@ -22,6 +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.util.FileCopyUtils; /** @@ -48,6 +49,7 @@ import org.springframework.util.FileCopyUtils; * and is effectively retired (in contrast to its sibling Hessian) */ @Deprecated +@UsesSunHttpServer public class SimpleBurlapServiceExporter extends BurlapExporter implements HttpHandler { /** diff --git a/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java index e773ed161b..5e218ae5c5 100644 --- a/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java @@ -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. @@ -22,6 +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.util.FileCopyUtils; /** @@ -44,6 +45,7 @@ import org.springframework.util.FileCopyUtils; * @see org.springframework.remoting.caucho.HessianProxyFactoryBean * @see org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter */ +@UsesSunHttpServer public class SimpleHessianServiceExporter extends HessianExporter implements HttpHandler { /** diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java index 88283205a9..e8b78fb57c 100644 --- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -25,6 +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.remoting.rmi.RemoteInvocationSerializingExporter; import org.springframework.remoting.support.RemoteInvocation; import org.springframework.remoting.support.RemoteInvocationResult; @@ -51,6 +52,7 @@ import org.springframework.remoting.support.RemoteInvocationResult; * @see org.springframework.remoting.caucho.SimpleHessianServiceExporter * @see org.springframework.remoting.caucho.SimpleBurlapServiceExporter */ +@UsesSunHttpServer public class SimpleHttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements HttpHandler { diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java index a8c9504c7a..4971d9aa25 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java @@ -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. @@ -34,6 +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.util.Assert; import org.springframework.util.ClassUtils; @@ -189,6 +190,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware, * @see Endpoint#create(Object) * @see Endpoint#create(String, Object) */ + @UsesJava7 // Endpoint#create with WebServiceFeature[] protected Endpoint createEndpoint(Object bean) { if (this.endpointFeatures != null || this.webServiceFeatures != null) { WebServiceFeature[] endpointFeaturesToUse = this.endpointFeatures; diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactory.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactory.java index 3833a0c2ea..2b3def780a 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactory.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/LocalJaxWsServiceFactory.java @@ -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. @@ -24,6 +24,7 @@ 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.util.Assert; @@ -146,6 +147,7 @@ public class LocalJaxWsServiceFactory { * @see #setServiceName * @see #setWsdlDocumentUrl */ + @UsesJava7 // Service#create with WebServiceFeature[] public Service createJaxWsService() { Assert.notNull(this.serviceName, "No service name specified"); Service service; diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java index 5b30a338dc..4b65c01496 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 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 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; /** * Simple exporter for JAX-WS services, autodetecting annotated service beans @@ -46,6 +47,7 @@ import org.apache.commons.logging.LogFactory; * @see javax.xml.ws.Endpoint#publish(Object) * @see SimpleJaxWsServiceExporter */ +@UsesSunHttpServer public class SimpleHttpServerJaxWsServiceExporter extends AbstractJaxWsServiceExporter { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java index fefc115c2e..c7e084d8f4 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolver.java @@ -27,6 +27,7 @@ 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.web.bind.support.WebDataBinderFactory; @@ -133,6 +134,7 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume /** * Inner class to avoid a hard-coded dependency on Java 8's {@link java.time.ZoneId}. */ + @UsesJava8 private static class ZoneIdResolver { public static Object resolveZoneId(HttpServletRequest request) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java index a485620e51..86e8b6f2b2 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java @@ -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. @@ -33,6 +33,7 @@ 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; @@ -145,6 +146,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient { return result; } + @UsesJava7 private InetAddress getLocalHost() { try { return InetAddress.getLocalHost(); -- GitLab