Browse Source

Compatibility with JDK 9 release candidate build (175)

Includes upgrade to Objenesis 2.6, Gradle 3.5.1, RxJava 2.1.1, JSON Binding API 1.0 final.

Issue: SPR-15686
Issue: SPR-15600
pull/1463/merge
Juergen Hoeller 8 years ago
parent
commit
098ff6f0f8
  1. 134
      build.gradle
  2. BIN
      gradle/wrapper/gradle-wrapper.jar
  3. 6
      gradle/wrapper/gradle-wrapper.properties
  4. 3
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java
  5. 12
      spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
  6. 23
      spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java
  7. 9
      spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java
  8. 13
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java

134
build.gradle

@ -68,7 +68,7 @@ configure(allprojects) { project -> @@ -68,7 +68,7 @@ configure(allprojects) { project ->
ext.jodaVersion = "2.9.9"
ext.jpaVersion = "2.1.1"
ext.jsfVersion = "2.2"
ext.jsonBindingVersion = "1.0.0-RC2"
ext.jsonBindingVersion = "1.0"
ext.jspVersion = "2.3.2-b02"
ext.jtaVersion = "1.2"
ext.junitVersion = "4.12"
@ -86,7 +86,7 @@ configure(allprojects) { project -> @@ -86,7 +86,7 @@ configure(allprojects) { project ->
ext.romeVersion = "1.7.3"
ext.rxjavaVersion = '1.3.0'
ext.rxjavaAdapterVersion = '1.2.1'
ext.rxjava2Version = '2.1.0'
ext.rxjava2Version = '2.1.1'
ext.rxnettyVersion = '0.5.2'
ext.servletVersion = "3.1.0"
ext.slf4jVersion = "1.7.25"
@ -322,7 +322,7 @@ project("spring-core") { @@ -322,7 +322,7 @@ project("spring-core") {
// further transformed by the JarJar task to depend on org.springframework.asm; this
// avoids including two different copies of asm unnecessarily.
def cglibVersion = "3.2.5"
def objenesisVersion = "2.5.1"
def objenesisVersion = "2.6"
configurations {
jarjar
@ -597,6 +597,7 @@ project("spring-messaging") { @@ -597,6 +597,7 @@ project("spring-messaging") {
testCompile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
testRuntime("javax.activation:activation:${activationApiVersion}")
}
}
@ -779,67 +780,6 @@ project("spring-web") { @@ -779,67 +780,6 @@ project("spring-web") {
}
}
project("spring-webflux") {
description = "Spring WebFlux"
dependencies {
compile(project(":spring-core"))
compile(project(":spring-web"))
compile("org.reactivestreams:reactive-streams")
compile("io.projectreactor:reactor-core")
optional(project(":spring-context-support")) // for FreeMarker support
provided "javax.servlet:javax.servlet-api:${servletVersion}"
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
optional("org.freemarker:freemarker:${freemarkerVersion}")
optional("org.apache.httpcomponents:httpclient:${httpclientVersion}") {
exclude group: "commons-logging", module: "commons-logging"
}
optional('org.webjars:webjars-locator:0.32-1')
optional("io.projectreactor.ipc:reactor-netty")
optional("io.reactivex:rxjava:${rxjavaVersion}")
optional("io.reactivex:rxjava-reactive-streams:${rxjavaAdapterVersion}")
optional("javax.websocket:javax.websocket-api:${websocketVersion}")
optional("org.apache.tomcat:tomcat-websocket:${tomcatVersion}") {
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
}
optional("org.eclipse.jetty.websocket:websocket-server:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec"
}
optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
optional("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testCompile("io.projectreactor:reactor-test")
testCompile("javax.validation:validation-api:${beanvalVersion}")
testCompile("org.hibernate:hibernate-validator:${hibvalVersion}")
testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}")
testCompile("org.eclipse.jetty:jetty-servlet:${jettyVersion}")
testCompile "io.reactivex.rxjava2:rxjava:${rxjava2Version}"
testCompile("io.undertow:undertow-core:${undertowVersion}")
testCompile("io.reactivex:rxnetty-http:${rxnettyVersion}") {
exclude group: 'io.reactivex', module: 'rxjava'
}
testCompile("com.fasterxml:aalto-xml:1.0.0")
testCompile("org.xmlunit:xmlunit-matchers:${xmlunitVersion}")
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}")
testRuntime("org.jetbrains.kotlin:kotlin-script-util:${kotlinVersion}")
testRuntime("org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}")
testRuntime("org.jruby:jruby:9.1.9.0")
testRuntime("org.python:jython-standalone:2.5.3")
testRuntime("org.webjars:underscorejs:1.8.3")
testRuntime("org.glassfish:javax.el:3.0.1-b08")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
testRuntime("org.synchronoss.cloud:nio-multipart-parser:${niomultipartVersion}")
}
}
project("spring-orm") {
description = "Spring Object/Relational Mapping"
@ -948,6 +888,7 @@ project("spring-webmvc") { @@ -948,6 +888,7 @@ project("spring-webmvc") {
testRuntime("org.glassfish:javax.el:3.0.1-b08")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
testRuntime("javax.activation:activation:${activationApiVersion}")
}
}
@ -995,6 +936,68 @@ project("spring-websocket") { @@ -995,6 +936,68 @@ project("spring-websocket") {
}
}
project("spring-webflux") {
description = "Spring WebFlux"
dependencies {
compile(project(":spring-core"))
compile(project(":spring-web"))
compile("org.reactivestreams:reactive-streams")
compile("io.projectreactor:reactor-core")
optional(project(":spring-context-support")) // for FreeMarker support
provided "javax.servlet:javax.servlet-api:${servletVersion}"
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
optional("org.freemarker:freemarker:${freemarkerVersion}")
optional("org.apache.httpcomponents:httpclient:${httpclientVersion}") {
exclude group: "commons-logging", module: "commons-logging"
}
optional('org.webjars:webjars-locator:0.32-1')
optional("io.projectreactor.ipc:reactor-netty")
optional("io.reactivex:rxjava:${rxjavaVersion}")
optional("io.reactivex:rxjava-reactive-streams:${rxjavaAdapterVersion}")
optional("javax.websocket:javax.websocket-api:${websocketVersion}")
optional("org.apache.tomcat:tomcat-websocket:${tomcatVersion}") {
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
}
optional("org.eclipse.jetty.websocket:websocket-server:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec"
}
optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
optional("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testCompile("io.projectreactor:reactor-test")
testCompile("javax.validation:validation-api:${beanvalVersion}")
testCompile("org.hibernate:hibernate-validator:${hibvalVersion}")
testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}")
testCompile("org.eclipse.jetty:jetty-servlet:${jettyVersion}")
testCompile "io.reactivex.rxjava2:rxjava:${rxjava2Version}"
testCompile("io.undertow:undertow-core:${undertowVersion}")
testCompile("io.reactivex:rxnetty-http:${rxnettyVersion}") {
exclude group: 'io.reactivex', module: 'rxjava'
}
testCompile("com.fasterxml:aalto-xml:1.0.0")
testCompile("org.xmlunit:xmlunit-matchers:${xmlunitVersion}")
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}")
testRuntime("org.jetbrains.kotlin:kotlin-script-util:${kotlinVersion}")
testRuntime("org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}")
testRuntime("org.jruby:jruby:9.1.9.0")
testRuntime("org.python:jython-standalone:2.5.3")
testRuntime("org.synchronoss.cloud:nio-multipart-parser:${niomultipartVersion}")
testRuntime("org.webjars:underscorejs:1.8.3")
testRuntime("org.glassfish:javax.el:3.0.1-b08")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
testRuntime("javax.activation:activation:${activationApiVersion}")
}
}
project("spring-test") {
description = "Spring TestContext Framework"
@ -1074,6 +1077,7 @@ project("spring-test") { @@ -1074,6 +1077,7 @@ project("spring-test") {
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}") // Java Util Logging for JUnit 5
testRuntime("org.ehcache:ehcache:${ehcache3Version}")
testRuntime("org.terracotta:management-model:2.0.0")
testRuntime("javax.annotation:javax.annotation-api:${annotationApiVersion}")
testRuntime("javax.el:javax.el-api:${elApiVersion}")
testRuntime("org.glassfish:javax.el:3.0.1-b08")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
@ -1251,7 +1255,7 @@ configure(rootProject) { @@ -1251,7 +1255,7 @@ configure(rootProject) {
task wrapper(type: Wrapper) {
description = "Generates gradlew[.bat] scripts"
gradleVersion = '3.5'
gradleVersion = '3.5.1'
doLast() {
def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"

BIN
gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

6
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#Mon Apr 10 21:20:52 CEST 2017
#Mon Jun 26 15:28:23 CEST 2017
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
zipStoreBase=GRADLE_USER_HOME

3
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -448,6 +448,7 @@ public abstract class ReflectionUtils { @@ -448,6 +448,7 @@ public abstract class ReflectionUtils {
* @param field the field to make accessible
* @see java.lang.reflect.Field#setAccessible
*/
@SuppressWarnings("deprecation") // on JDK 9
public static void makeAccessible(Field field) {
if ((!Modifier.isPublic(field.getModifiers()) ||
!Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
@ -464,6 +465,7 @@ public abstract class ReflectionUtils { @@ -464,6 +465,7 @@ public abstract class ReflectionUtils {
* @param method the method to make accessible
* @see java.lang.reflect.Method#setAccessible
*/
@SuppressWarnings("deprecation") // on JDK 9
public static void makeAccessible(Method method) {
if ((!Modifier.isPublic(method.getModifiers()) ||
!Modifier.isPublic(method.getDeclaringClass().getModifiers())) && !method.isAccessible()) {
@ -479,6 +481,7 @@ public abstract class ReflectionUtils { @@ -479,6 +481,7 @@ public abstract class ReflectionUtils {
* @param ctor the constructor to make accessible
* @see java.lang.reflect.Constructor#setAccessible
*/
@SuppressWarnings("deprecation") // on JDK 9
public static void makeAccessible(Constructor<?> ctor) {
if ((!Modifier.isPublic(ctor.getModifiers()) ||
!Modifier.isPublic(ctor.getDeclaringClass().getModifiers())) && !ctor.isAccessible()) {

12
spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

@ -581,13 +581,9 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { @@ -581,13 +581,9 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
private final TypeDescriptor typeDescriptor;
private final boolean needsToBeMadeAccessible;
OptimalPropertyAccessor(InvokerPair target) {
this.member = target.member;
this.typeDescriptor = target.typeDescriptor;
this.needsToBeMadeAccessible = (!Modifier.isPublic(this.member.getModifiers()) ||
!Modifier.isPublic(this.member.getDeclaringClass().getModifiers()));
}
@Override
@ -625,9 +621,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { @@ -625,9 +621,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
if (this.member instanceof Method) {
Method method = (Method) this.member;
try {
if (this.needsToBeMadeAccessible && !method.isAccessible()) {
method.setAccessible(true);
}
ReflectionUtils.makeAccessible(method);
Object value = method.invoke(target);
return new TypedValue(value, this.typeDescriptor.narrow(value));
}
@ -638,9 +632,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { @@ -638,9 +632,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
else {
Field field = (Field) this.member;
try {
if (this.needsToBeMadeAccessible && !field.isAccessible()) {
field.setAccessible(true);
}
ReflectionUtils.makeAccessible(field);
Object value = field.get(target);
return new TypedValue(value, this.typeDescriptor.narrow(value));
}

23
spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java

@ -18,10 +18,10 @@ package org.springframework.http.codec.xml; @@ -18,10 +18,10 @@ package org.springframework.http.codec.xml;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
@ -46,14 +46,16 @@ import org.springframework.util.MimeType; @@ -46,14 +46,16 @@ import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
/**
* Decodes a {@link DataBuffer} stream into a stream of {@link XMLEvent}s. That is, given
* the following XML:
* Decodes a {@link DataBuffer} stream into a stream of {@link XMLEvent}s.
* That is, given the following XML:
*
* <pre>{@code
* <root>
* <child>foo</child>
* <child>bar</child>
* </root>}
* </pre>
*
* this method with result in a flux with the following events:
* <ol>
* <li>{@link javax.xml.stream.events.StartDocument}</li>
@ -75,12 +77,12 @@ import org.springframework.util.MimeTypeUtils; @@ -75,12 +77,12 @@ import org.springframework.util.MimeTypeUtils;
*/
public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
private static final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
private static final boolean aaltoPresent = ClassUtils.isPresent(
"com.fasterxml.aalto.AsyncXMLStreamReader", XmlEventDecoder.class.getClassLoader());
private static final XMLInputFactory inputFactory = XMLInputFactory.newFactory();
boolean useAalto = true;
boolean useAalto = aaltoPresent;
public XmlEventDecoder() {
@ -89,12 +91,12 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> { @@ -89,12 +91,12 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({"rawtypes", "unchecked"}) // on JDK 9 where XMLEventReader is Iterator<Object>
public Flux<XMLEvent> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
Flux<DataBuffer> flux = Flux.from(inputStream);
if (useAalto && aaltoPresent) {
if (useAalto) {
return flux.flatMap(new AaltoDataBufferToXmlEvent());
}
else {
@ -103,7 +105,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> { @@ -103,7 +105,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
flatMapMany(dataBuffer -> {
try {
InputStream is = dataBuffer.asInputStream();
XMLEventReader eventReader = inputFactory.createXMLEventReader(is);
Iterator eventReader = inputFactory.createXMLEventReader(is);
return Flux.fromIterable((Iterable<XMLEvent>) () -> eventReader);
}
catch (XMLStreamException ex) {
@ -127,8 +129,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> { @@ -127,8 +129,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
private final AsyncXMLStreamReader<AsyncByteBufferFeeder> streamReader =
inputFactory.createAsyncForByteBuffer();
private final XMLEventAllocator eventAllocator =
EventAllocatorImpl.getDefaultInstance();
private final XMLEventAllocator eventAllocator = EventAllocatorImpl.getDefaultInstance();
@Override
public Publisher<? extends XMLEvent> apply(DataBuffer dataBuffer) {

9
spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java

@ -20,6 +20,7 @@ import java.util.HashMap; @@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -30,15 +31,15 @@ import org.springframework.http.MediaType; @@ -30,15 +31,15 @@ import org.springframework.http.MediaType;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
import org.springframework.mock.http.server.reactive.test.MockServerWebExchange;
import org.springframework.mock.web.test.MockHttpServletResponse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* Unit tests for Kotlin script templates running on Kotlin JSR 223 support
* Unit tests for Kotlin script templates running on Kotlin JSR-223 support.
*
* @author Sebastien Deleuze
*/
@Ignore // for JDK 9 compatibility
public class KotlinScriptTemplateTests {
@Test
@ -74,6 +75,7 @@ public class KotlinScriptTemplateTests { @@ -74,6 +75,7 @@ public class KotlinScriptTemplateTests {
response.getBodyAsString().block());
}
private MockServerHttpResponse renderViewWithModel(String viewUrl, Map<String, Object> model, Locale locale, Class<?> configuration) throws Exception {
ScriptTemplateView view = createViewWithUrl(viewUrl, configuration);
view.setLocale(locale);
@ -115,6 +117,7 @@ public class KotlinScriptTemplateTests { @@ -115,6 +117,7 @@ public class KotlinScriptTemplateTests {
}
}
@Configuration
static class ScriptTemplatingConfigurationWithoutRenderFunction {

13
spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -21,10 +21,9 @@ import java.util.Locale; @@ -21,10 +21,9 @@ import java.util.Locale;
import java.util.Map;
import javax.servlet.ServletContext;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@ -35,11 +34,15 @@ import org.springframework.mock.web.test.MockHttpServletResponse; @@ -35,11 +34,15 @@ import org.springframework.mock.web.test.MockHttpServletResponse;
import org.springframework.mock.web.test.MockServletContext;
import org.springframework.web.context.WebApplicationContext;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
* Unit tests for Kotlin script templates running on Kotlin JSR 223 support
* Unit tests for Kotlin script templates running on Kotlin JSR-223 support.
*
* @author Sebastien Deleuze
*/
@Ignore // for JDK 9 compatibility
public class KotlinScriptTemplateTests {
private WebApplicationContext webAppContext;
@ -54,6 +57,7 @@ public class KotlinScriptTemplateTests { @@ -54,6 +57,7 @@ public class KotlinScriptTemplateTests {
this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
}
@Test
public void renderTemplateWithFrenchLocale() throws Exception {
Map<String, Object> model = new HashMap<>();
@ -87,6 +91,7 @@ public class KotlinScriptTemplateTests { @@ -87,6 +91,7 @@ public class KotlinScriptTemplateTests {
response.getContentAsString());
}
private MockHttpServletResponse renderViewWithModel(String viewUrl, Map<String, Object> model, Locale locale, Class<?> configuration) throws Exception {
ScriptTemplateView view = createViewWithUrl(viewUrl, configuration);
view.setLocale(locale);

Loading…
Cancel
Save