Framework build compatible with JDK 9 (even with -target 1.9)
Issue: SPR-13344
This commit is contained in:
parent
9f2cb3e276
commit
75fc0f8538
25
build.gradle
25
build.gradle
|
@ -32,6 +32,7 @@ configure(allprojects) { project ->
|
|||
version = qualifyVersionIfNecessary(version)
|
||||
|
||||
ext.activationApiVersion = "1.1.1"
|
||||
ext.annotationApiVersion = "1.2"
|
||||
ext.aspectjVersion = "1.9.0.BETA-4"
|
||||
ext.beanvalVersion = "1.1.0.Final"
|
||||
ext.caffeineVersion = "2.3.1"
|
||||
|
@ -55,6 +56,7 @@ configure(allprojects) { project ->
|
|||
ext.jackson2Version = "2.8.1"
|
||||
ext.javamailVersion = "1.5.5"
|
||||
ext.jaxbVersion = "2.2.11"
|
||||
ext.jaxwsVersion = "2.2.11"
|
||||
ext.jcaVersion = "1.7"
|
||||
ext.jettyVersion = "9.3.10.v20160621"
|
||||
ext.jodaVersion = "2.9.4"
|
||||
|
@ -489,6 +491,8 @@ project("spring-context") {
|
|||
compile(files(project(":spring-core").cglibRepackJar))
|
||||
optional(project(":spring-instrument"))
|
||||
optional("javax.inject:javax.inject:1")
|
||||
optional("javax.annotation:javax.annotation-api:${annotationApiVersion}")
|
||||
optional("javax.xml.ws:jaxws-api:${jaxwsVersion}")
|
||||
optional("javax.ejb:javax.ejb-api:${ejbApiVersion}")
|
||||
optional("javax.interceptor:javax.interceptor-api:${interceptorApiVersion}")
|
||||
optional("javax.enterprise.concurrent:javax.enterprise.concurrent-api:1.0")
|
||||
|
@ -517,6 +521,8 @@ project("spring-oxm") {
|
|||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
optional("javax.activation:activation:${activationApiVersion}")
|
||||
optional("org.codehaus.castor:castor-xml:1.4.1") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
exclude group: "org.springframework", module: "spring-context"
|
||||
|
@ -535,10 +541,8 @@ project("spring-oxm") {
|
|||
testCompile(files(genCastor.classesDir).builtBy(genCastor))
|
||||
testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
testRuntime("xerces:xercesImpl:2.11.0") // for Castor
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,6 +566,7 @@ project("spring-messaging") {
|
|||
}
|
||||
optional("org.eclipse.jetty.websocket:websocket-client:${jettyVersion}")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testCompile("javax.inject:javax.inject-tck:1")
|
||||
testCompile("javax.servlet:javax.servlet-api:${servletVersion}")
|
||||
testCompile("javax.validation:validation-api:${beanvalVersion}")
|
||||
|
@ -579,7 +584,6 @@ project("spring-messaging") {
|
|||
testCompile("io.netty:netty-all:${nettyVersion}")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile("org.xmlunit:xmlunit-matchers:${xmlunitVersion}")
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
|
@ -650,6 +654,7 @@ project("spring-context-support") {
|
|||
compile(project(":spring-context"))
|
||||
optional(project(":spring-jdbc")) // for Quartz support
|
||||
optional(project(":spring-tx")) // for Quartz support
|
||||
optional("javax.activation:activation:${activationApiVersion}")
|
||||
optional("javax.mail:javax.mail-api:${javamailVersion}")
|
||||
optional("javax.cache:cache-api:1.0.0")
|
||||
optional("com.github.ben-manes.caffeine:caffeine:${caffeineVersion}")
|
||||
|
@ -697,6 +702,7 @@ project("spring-web") {
|
|||
optional("javax.el:javax.el-api:${elApiVersion}")
|
||||
optional("javax.faces:javax.faces-api:2.2")
|
||||
optional("javax.validation:validation-api:${beanvalVersion}")
|
||||
optional("javax.activation:activation:${activationApiVersion}")
|
||||
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
|
||||
optional("com.caucho:hessian:4.0.38")
|
||||
optional("commons-fileupload:commons-fileupload:${fileuploadVersion}")
|
||||
|
@ -731,6 +737,8 @@ project("spring-web") {
|
|||
optional("com.google.protobuf:protobuf-java:${protobufVersion}")
|
||||
optional("com.google.protobuf:protobuf-java-util:${protobufVersion}")
|
||||
optional("com.googlecode.protobuf-java-format:protobuf-java-format:1.4")
|
||||
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
optional("javax.xml.ws:jaxws-api:${jaxwsVersion}")
|
||||
optional("javax.mail:javax.mail-api:${javamailVersion}")
|
||||
testCompile(project(":spring-context-support")) // for JafMediaTypeFactory
|
||||
testCompile("org.xmlunit:xmlunit-matchers:${xmlunitVersion}")
|
||||
|
@ -747,11 +755,8 @@ project("spring-web") {
|
|||
testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}")
|
||||
testCompile("org.eclipse.jetty:jetty-servlet:${jettyVersion}")
|
||||
testCompile("com.squareup.okhttp3:mockwebserver:3.0.1")
|
||||
testRuntime("javax.xml.ws:jaxws-api:2.2.11")
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -765,6 +770,7 @@ project("spring-web-reactive") {
|
|||
compile "io.projectreactor:reactor-core:${reactorCoreVersion}"
|
||||
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:4.5.1" // Needed to run Javadoc without error
|
||||
|
@ -782,7 +788,6 @@ project("spring-web-reactive") {
|
|||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile("javax.validation:validation-api:${beanvalVersion}")
|
||||
testCompile("org.xmlunit:xmlunit-matchers:${xmlunitVersion}")
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
|
@ -830,6 +835,7 @@ project("spring-webmvc") {
|
|||
optional(project(":spring-oxm")) // for MarshallingView
|
||||
optional("javax.servlet.jsp:javax.servlet.jsp-api:${jspVersion}")
|
||||
optional("javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1")
|
||||
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
optional("org.apache.poi:poi:${poiVersion}")
|
||||
optional("org.apache.poi:poi-ooxml:${poiVersion}")
|
||||
optional("org.freemarker:freemarker:${freemarkerVersion}")
|
||||
|
@ -883,7 +889,6 @@ project("spring-webmvc") {
|
|||
testRuntime("org.jruby:jruby:9.1.2.0")
|
||||
testRuntime("org.python:jython-standalone:2.5.3")
|
||||
testRuntime("org.webjars:underscorejs:1.8.3")
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
|
@ -965,6 +970,8 @@ project("spring-test") {
|
|||
}
|
||||
optional("javax.el:javax.el-api:${elApiVersion}")
|
||||
optional("javax.websocket:javax.websocket-api:${websocketVersion}")
|
||||
optional("javax.activation:activation:${activationApiVersion}")
|
||||
optional("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
|
||||
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
|
||||
optional("org.hamcrest:hamcrest-core:${hamcrestVersion}")
|
||||
|
@ -1004,10 +1011,8 @@ project("spring-test") {
|
|||
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
|
||||
testRuntime("org.ehcache:ehcache:${ehcache3Version}")
|
||||
testRuntime("org.terracotta:management-model:2.0.0")
|
||||
testRuntime("javax.xml.bind:jaxb-api:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl:${jaxbVersion}")
|
||||
testRuntime("javax.activation:activation:${activationApiVersion}")
|
||||
}
|
||||
|
||||
task testNG(type: Test) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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,28 +21,23 @@ import java.lang.reflect.Method;
|
|||
import java.rmi.RemoteException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.omg.CORBA.OBJECT_NOT_EXIST;
|
||||
import org.omg.CORBA.SystemException;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jndi.JndiObjectLocator;
|
||||
import org.springframework.remoting.RemoteAccessException;
|
||||
import org.springframework.remoting.RemoteConnectFailureException;
|
||||
import org.springframework.remoting.RemoteInvocationFailureException;
|
||||
import org.springframework.remoting.RemoteLookupFailureException;
|
||||
import org.springframework.remoting.support.DefaultRemoteInvocationFactory;
|
||||
import org.springframework.remoting.support.RemoteInvocation;
|
||||
import org.springframework.remoting.support.RemoteInvocationFactory;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* {@link org.aopalliance.intercept.MethodInterceptor} for accessing RMI services from JNDI.
|
||||
* Typically used for RMI-IIOP (CORBA), but can also be used for EJB home objects
|
||||
* {@link org.aopalliance.intercept.MethodInterceptor} for accessing RMI services
|
||||
* from JNDI. Typically used for RMI-IIOP but can also be used for EJB home objects
|
||||
* (for example, a Stateful Session Bean home). In contrast to a plain JNDI lookup,
|
||||
* this accessor also performs narrowing through PortableRemoteObject.
|
||||
*
|
||||
|
@ -74,7 +69,6 @@ import org.springframework.util.ReflectionUtils;
|
|||
* @see org.springframework.remoting.RemoteAccessException
|
||||
* @see java.rmi.RemoteException
|
||||
* @see java.rmi.Remote
|
||||
* @see javax.rmi.PortableRemoteObject#narrow
|
||||
*/
|
||||
public class JndiRmiClientInterceptor extends JndiObjectLocator implements MethodInterceptor, InitializingBean {
|
||||
|
||||
|
@ -227,17 +221,7 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
*/
|
||||
protected Object lookupStub() throws RemoteLookupFailureException {
|
||||
try {
|
||||
Object stub = lookup();
|
||||
if (getServiceInterface() != null && !(stub instanceof RmiInvocationHandler)) {
|
||||
try {
|
||||
stub = PortableRemoteObject.narrow(stub, getServiceInterface());
|
||||
}
|
||||
catch (ClassCastException ex) {
|
||||
throw new RemoteLookupFailureException(
|
||||
"Could not narrow RMI stub to service interface [" + getServiceInterface().getName() + "]", ex);
|
||||
}
|
||||
}
|
||||
return stub;
|
||||
return lookup();
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
throw new RemoteLookupFailureException("JNDI lookup for RMI service [" + getJndiName() + "] failed", ex);
|
||||
|
@ -306,14 +290,6 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (SystemException ex) {
|
||||
if (isConnectFailure(ex)) {
|
||||
return handleRemoteConnectFailure(invocation, ex);
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
getJndiTemplate().releaseContext(ctx);
|
||||
}
|
||||
|
@ -330,17 +306,6 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
return RmiClientInterceptorUtils.isConnectFailure(ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the given CORBA exception indicates a connect failure.
|
||||
* <p>The default implementation checks for CORBA's
|
||||
* {@link org.omg.CORBA.OBJECT_NOT_EXIST} exception.
|
||||
* @param ex the RMI exception to check
|
||||
* @return whether the exception should be treated as connect failure
|
||||
*/
|
||||
protected boolean isConnectFailure(SystemException ex) {
|
||||
return (ex instanceof OBJECT_NOT_EXIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the stub and retry the remote invocation if necessary.
|
||||
* <p>If not configured to refresh on connect failure, this method
|
||||
|
@ -402,9 +367,6 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
catch (RemoteException ex) {
|
||||
throw convertRmiAccessException(ex, invocation.getMethod());
|
||||
}
|
||||
catch (SystemException ex) {
|
||||
throw convertCorbaAccessException(ex, invocation.getMethod());
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
throw ex.getTargetException();
|
||||
}
|
||||
|
@ -423,9 +385,6 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
if (targetEx instanceof RemoteException) {
|
||||
throw convertRmiAccessException((RemoteException) targetEx, invocation.getMethod());
|
||||
}
|
||||
else if (targetEx instanceof SystemException) {
|
||||
throw convertCorbaAccessException((SystemException) targetEx, invocation.getMethod());
|
||||
}
|
||||
else {
|
||||
throw targetEx;
|
||||
}
|
||||
|
@ -483,27 +442,4 @@ public class JndiRmiClientInterceptor extends JndiObjectLocator implements Metho
|
|||
return RmiClientInterceptorUtils.convertRmiAccessException(method, ex, isConnectFailure(ex), getJndiName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given CORBA SystemException that happened during remote access
|
||||
* to Spring's RemoteAccessException if the method signature does not declare
|
||||
* RemoteException. Else, return the SystemException wrapped in a RemoteException.
|
||||
* @param method the invoked method
|
||||
* @param ex the RemoteException that happened
|
||||
* @return the exception to be thrown to the caller
|
||||
*/
|
||||
private Exception convertCorbaAccessException(SystemException ex, Method method) {
|
||||
if (ReflectionUtils.declaresException(method, RemoteException.class)) {
|
||||
// A traditional RMI service: wrap CORBA exceptions in standard RemoteExceptions.
|
||||
return new RemoteException("Failed to access CORBA service [" + getJndiName() + "]", ex);
|
||||
}
|
||||
else {
|
||||
if (isConnectFailure(ex)) {
|
||||
return new RemoteConnectFailureException("Could not connect to CORBA service [" + getJndiName() + "]", ex);
|
||||
}
|
||||
else {
|
||||
return new RemoteAccessException("Could not access CORBA service [" + getJndiName() + "]", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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,7 +21,6 @@ import java.rmi.Remote;
|
|||
import java.rmi.RemoteException;
|
||||
import java.util.Properties;
|
||||
import javax.naming.NamingException;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
@ -117,7 +116,6 @@ public class JndiRmiServiceExporter extends RmiBasedExporter implements Initiali
|
|||
|
||||
// Initialize and cache exported object.
|
||||
this.exportedObject = getObjectToExport();
|
||||
PortableRemoteObject.exportObject(this.exportedObject);
|
||||
|
||||
rebind();
|
||||
}
|
||||
|
@ -143,7 +141,6 @@ public class JndiRmiServiceExporter extends RmiBasedExporter implements Initiali
|
|||
logger.info("Unbinding RMI service from JNDI location [" + this.jndiName + "]");
|
||||
}
|
||||
this.jndiTemplate.unbind(this.jndiName);
|
||||
PortableRemoteObject.unexportObject(this.exportedObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue