aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchegar <none@none>2013-10-11 19:24:06 +0100
committerchegar <none@none>2013-10-11 19:24:06 +0100
commitb02c4ffca28d0035020d2ca57396f0b509a2e9bc (patch)
tree39e39495a33b75ab0c08c89e94dbcbbbe6f9b918 /src
parent808336a88c29a1fbc3c3c7c2ab6fe2f1f8b802da (diff)
parent17901a8c2d7072c0ae69804624856163bcae876f (diff)
downloadjdk8u_jaxws-b02c4ffca28d0035020d2ca57396f0b509a2e9bc.tar.gz
Merge
Diffstat (limited to 'src')
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java4
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java4
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/MethodUtil.java94
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/MethodUtil.java94
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java23
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java92
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java8
7 files changed, 309 insertions, 10 deletions
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java
index e670ac45..560e98e9 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@ public abstract class AbstractInstanceResolver<T> extends InstanceResolver<T> {
if (!method.isAccessible()) {
method.setAccessible(true);
}
- method.invoke(instance,args);
+ MethodUtil.invoke(instance,method, args);
} catch (IllegalAccessException e) {
throw new ServerRtException("server.rt.err",e);
} catch (InvocationTargetException e) {
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java
index 625f59f4..7c11e645 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -232,7 +232,7 @@ public abstract class InstanceResolver<T> {
public Object invoke(Packet p, Method m, Object... args) throws InvocationTargetException, IllegalAccessException {
T t = resolve(p);
try {
- return m.invoke(t, args );
+ return MethodUtil.invoke(t, m, args );
} finally {
postInvoke(p,t);
}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/MethodUtil.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/MethodUtil.java
new file mode 100644
index 00000000..c8497055
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/MethodUtil.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.api.server;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ *
+ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/MethodUtil.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/MethodUtil.java
new file mode 100644
index 00000000..f0daea51
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/MethodUtil.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.client.sei;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ * <p/>
+ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java
index 7a5f0e3a..9ad1f6ed 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java
@@ -28,6 +28,7 @@ package com.sun.xml.internal.ws.client.sei;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.SOAPVersion;
+import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import com.sun.xml.internal.ws.api.client.WSPortInfo;
import com.sun.xml.internal.ws.api.databinding.Databinding;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
@@ -36,12 +37,16 @@ import com.sun.xml.internal.ws.api.message.Headers;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.MEP;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
-import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.Fiber;
+import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.api.server.ContainerResolver;
import com.sun.xml.internal.ws.binding.BindingImpl;
-import com.sun.xml.internal.ws.client.*;
+import com.sun.xml.internal.ws.client.AsyncResponseImpl;
+import com.sun.xml.internal.ws.client.RequestContext;
+import com.sun.xml.internal.ws.client.ResponseContextReceiver;
+import com.sun.xml.internal.ws.client.Stub;
+import com.sun.xml.internal.ws.client.WSServiceDelegate;
import com.sun.xml.internal.ws.model.JavaMethodImpl;
import com.sun.xml.internal.ws.model.SOAPSEIModel;
import com.sun.xml.internal.ws.wsdl.OperationDispatcher;
@@ -50,6 +55,8 @@ import javax.xml.namespace.QName;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
@@ -132,6 +139,7 @@ public final class SEIStub extends Stub implements InvocationHandler {
private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>();
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ validateInputs(proxy, method);
Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
try {
MethodHandler handler = methodHandlers.get(method);
@@ -155,6 +163,17 @@ public final class SEIStub extends Stub implements InvocationHandler {
}
}
+ private void validateInputs(Object proxy, Method method) {
+ if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
+ throw new IllegalStateException("Passed object is not proxy!");
+ }
+ Class<?> declaringClass = method.getDeclaringClass();
+ if (method == null || declaringClass == null
+ || Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Invoking static method is not allowed!");
+ }
+ }
+
public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) {
return super.process(request, rc, receiver);
}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java
new file mode 100644
index 00000000..ad2ad4a6
--- /dev/null
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.xml.internal.ws.policy.privateutil;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java
index d3a2752a..ec537d88 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -282,13 +282,13 @@ public final class PolicyUtils {
/**
* Reflection utilities wrapper
*/
- public static class Reflection {
+ static class Reflection {
private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyUtils.Reflection.class);
/**
* Reflectively invokes specified method on the specified target
*/
- public static <T> T invoke(final Object target, final String methodName,
+ static <T> T invoke(final Object target, final String methodName,
final Class<T> resultClass, final Object... parameters) throws RuntimePolicyUtilsException {
Class[] parameterTypes;
if (parameters != null && parameters.length > 0) {
@@ -311,7 +311,7 @@ public final class PolicyUtils {
final Object[] parameters, final Class[] parameterTypes) throws RuntimePolicyUtilsException {
try {
final Method method = target.getClass().getMethod(methodName, parameterTypes);
- final Object result = method.invoke(target, parameters);
+ final Object result = MethodUtil.invoke(target, method,parameters);
return resultClass.cast(result);
} catch (IllegalArgumentException e) {