Fri, 11 Oct 2013 19:24:06 +0100
Merge
1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java Thu Oct 10 21:22:53 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/AbstractInstanceResolver.java Fri Oct 11 19:24:06 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -66,7 +66,7 @@ 1.11 if (!method.isAccessible()) { 1.12 method.setAccessible(true); 1.13 } 1.14 - method.invoke(instance,args); 1.15 + MethodUtil.invoke(instance,method, args); 1.16 } catch (IllegalAccessException e) { 1.17 throw new ServerRtException("server.rt.err",e); 1.18 } catch (InvocationTargetException e) {
2.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java Thu Oct 10 21:22:53 2013 -0700 2.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/InstanceResolver.java Fri Oct 11 19:24:06 2013 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -232,7 +232,7 @@ 2.11 public Object invoke(Packet p, Method m, Object... args) throws InvocationTargetException, IllegalAccessException { 2.12 T t = resolve(p); 2.13 try { 2.14 - return m.invoke(t, args ); 2.15 + return MethodUtil.invoke(t, m, args ); 2.16 } finally { 2.17 postInvoke(p,t); 2.18 }
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/MethodUtil.java Fri Oct 11 19:24:06 2013 +0100 3.3 @@ -0,0 +1,94 @@ 3.4 +/* 3.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. Oracle designates this 3.11 + * particular file as subject to the "Classpath" exception as provided 3.12 + * by Oracle in the LICENSE file that accompanied this code. 3.13 + * 3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 + * version 2 for more details (a copy is included in the LICENSE file that 3.18 + * accompanied this code). 3.19 + * 3.20 + * You should have received a copy of the GNU General Public License version 3.21 + * 2 along with this work; if not, write to the Free Software Foundation, 3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 + * 3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.25 + * or visit www.oracle.com if you need additional information or have any 3.26 + * questions. 3.27 + */ 3.28 + 3.29 +package com.sun.xml.internal.ws.api.server; 3.30 + 3.31 +import java.lang.reflect.InvocationTargetException; 3.32 +import java.lang.reflect.Method; 3.33 +import java.util.logging.Level; 3.34 +import java.util.logging.Logger; 3.35 + 3.36 +/** 3.37 + * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks 3.38 + * to java.lang,reflect.Method.invoke() 3.39 + * 3.40 + * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too! 3.41 + */ 3.42 +class MethodUtil { 3.43 + 3.44 + private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName()); 3.45 + private static final Method INVOKE_METHOD; 3.46 + 3.47 + static { 3.48 + Method method; 3.49 + try { 3.50 + Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil"); 3.51 + method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class); 3.52 + if (LOGGER.isLoggable(Level.FINE)) { 3.53 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods."); 3.54 + } 3.55 + } catch (Throwable t) { 3.56 + method = null; 3.57 + if (LOGGER.isLoggable(Level.FINE)) { 3.58 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM"); 3.59 + } 3.60 + } 3.61 + INVOKE_METHOD = method; 3.62 + } 3.63 + 3.64 + static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException { 3.65 + if (INVOKE_METHOD != null) { 3.66 + // sun.reflect.misc.MethodUtil.invoke(method, owner, args) 3.67 + if (LOGGER.isLoggable(Level.FINE)) { 3.68 + LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil"); 3.69 + } 3.70 + try { 3.71 + return INVOKE_METHOD.invoke(null, method, target, args); 3.72 + } catch (InvocationTargetException ite) { 3.73 + // unwrap invocation exception added by reflection code ... 3.74 + throw unwrapException(ite); 3.75 + } 3.76 + } else { 3.77 + // other then Oracle JDK ... 3.78 + if (LOGGER.isLoggable(Level.FINE)) { 3.79 + LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM"); 3.80 + } 3.81 + return method.invoke(target, args); 3.82 + } 3.83 + } 3.84 + 3.85 + private static InvocationTargetException unwrapException(InvocationTargetException ite) { 3.86 + Throwable targetException = ite.getTargetException(); 3.87 + if (targetException != null && targetException instanceof InvocationTargetException) { 3.88 + if (LOGGER.isLoggable(Level.FINE)) { 3.89 + LOGGER.log(Level.FINE, "Unwrapping invocation target exception"); 3.90 + } 3.91 + return (InvocationTargetException) targetException; 3.92 + } else { 3.93 + return ite; 3.94 + } 3.95 + } 3.96 + 3.97 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/MethodUtil.java Fri Oct 11 19:24:06 2013 +0100 4.3 @@ -0,0 +1,94 @@ 4.4 +/* 4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. Oracle designates this 4.11 + * particular file as subject to the "Classpath" exception as provided 4.12 + * by Oracle in the LICENSE file that accompanied this code. 4.13 + * 4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.17 + * version 2 for more details (a copy is included in the LICENSE file that 4.18 + * accompanied this code). 4.19 + * 4.20 + * You should have received a copy of the GNU General Public License version 4.21 + * 2 along with this work; if not, write to the Free Software Foundation, 4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.23 + * 4.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.25 + * or visit www.oracle.com if you need additional information or have any 4.26 + * questions. 4.27 + */ 4.28 + 4.29 +package com.sun.xml.internal.ws.client.sei; 4.30 + 4.31 +import java.lang.reflect.InvocationTargetException; 4.32 +import java.lang.reflect.Method; 4.33 +import java.util.logging.Level; 4.34 +import java.util.logging.Logger; 4.35 + 4.36 +/** 4.37 + * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks 4.38 + * to java.lang,reflect.Method.invoke() 4.39 + * <p/> 4.40 + * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too! 4.41 + */ 4.42 +class MethodUtil { 4.43 + 4.44 + private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName()); 4.45 + private static final Method INVOKE_METHOD; 4.46 + 4.47 + static { 4.48 + Method method; 4.49 + try { 4.50 + Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil"); 4.51 + method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class); 4.52 + if (LOGGER.isLoggable(Level.FINE)) { 4.53 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods."); 4.54 + } 4.55 + } catch (Throwable t) { 4.56 + method = null; 4.57 + if (LOGGER.isLoggable(Level.FINE)) { 4.58 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM"); 4.59 + } 4.60 + } 4.61 + INVOKE_METHOD = method; 4.62 + } 4.63 + 4.64 + static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException { 4.65 + if (INVOKE_METHOD != null) { 4.66 + // sun.reflect.misc.MethodUtil.invoke(method, owner, args) 4.67 + if (LOGGER.isLoggable(Level.FINE)) { 4.68 + LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil"); 4.69 + } 4.70 + try { 4.71 + return INVOKE_METHOD.invoke(null, method, target, args); 4.72 + } catch (InvocationTargetException ite) { 4.73 + // unwrap invocation exception added by reflection code ... 4.74 + throw unwrapException(ite); 4.75 + } 4.76 + } else { 4.77 + // other then Oracle JDK ... 4.78 + if (LOGGER.isLoggable(Level.FINE)) { 4.79 + LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM"); 4.80 + } 4.81 + return method.invoke(target, args); 4.82 + } 4.83 + } 4.84 + 4.85 + private static InvocationTargetException unwrapException(InvocationTargetException ite) { 4.86 + Throwable targetException = ite.getTargetException(); 4.87 + if (targetException != null && targetException instanceof InvocationTargetException) { 4.88 + if (LOGGER.isLoggable(Level.FINE)) { 4.89 + LOGGER.log(Level.FINE, "Unwrapping invocation target exception"); 4.90 + } 4.91 + return (InvocationTargetException) targetException; 4.92 + } else { 4.93 + return ite; 4.94 + } 4.95 + } 4.96 + 4.97 +}
5.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java Thu Oct 10 21:22:53 2013 -0700 5.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/SEIStub.java Fri Oct 11 19:24:06 2013 +0100 5.3 @@ -28,6 +28,7 @@ 5.4 import com.sun.istack.internal.NotNull; 5.5 import com.sun.istack.internal.Nullable; 5.6 import com.sun.xml.internal.ws.api.SOAPVersion; 5.7 +import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; 5.8 import com.sun.xml.internal.ws.api.client.WSPortInfo; 5.9 import com.sun.xml.internal.ws.api.databinding.Databinding; 5.10 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; 5.11 @@ -36,12 +37,16 @@ 5.12 import com.sun.xml.internal.ws.api.message.Packet; 5.13 import com.sun.xml.internal.ws.api.model.MEP; 5.14 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; 5.15 +import com.sun.xml.internal.ws.api.pipe.Fiber; 5.16 import com.sun.xml.internal.ws.api.pipe.Tube; 5.17 -import com.sun.xml.internal.ws.api.pipe.Fiber; 5.18 import com.sun.xml.internal.ws.api.server.Container; 5.19 import com.sun.xml.internal.ws.api.server.ContainerResolver; 5.20 import com.sun.xml.internal.ws.binding.BindingImpl; 5.21 -import com.sun.xml.internal.ws.client.*; 5.22 +import com.sun.xml.internal.ws.client.AsyncResponseImpl; 5.23 +import com.sun.xml.internal.ws.client.RequestContext; 5.24 +import com.sun.xml.internal.ws.client.ResponseContextReceiver; 5.25 +import com.sun.xml.internal.ws.client.Stub; 5.26 +import com.sun.xml.internal.ws.client.WSServiceDelegate; 5.27 import com.sun.xml.internal.ws.model.JavaMethodImpl; 5.28 import com.sun.xml.internal.ws.model.SOAPSEIModel; 5.29 import com.sun.xml.internal.ws.wsdl.OperationDispatcher; 5.30 @@ -50,6 +55,8 @@ 5.31 import java.lang.reflect.InvocationHandler; 5.32 import java.lang.reflect.InvocationTargetException; 5.33 import java.lang.reflect.Method; 5.34 +import java.lang.reflect.Modifier; 5.35 +import java.lang.reflect.Proxy; 5.36 import java.util.HashMap; 5.37 import java.util.Map; 5.38 5.39 @@ -132,6 +139,7 @@ 5.40 private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>(); 5.41 5.42 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 5.43 + validateInputs(proxy, method); 5.44 Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer()); 5.45 try { 5.46 MethodHandler handler = methodHandlers.get(method); 5.47 @@ -155,6 +163,17 @@ 5.48 } 5.49 } 5.50 5.51 + private void validateInputs(Object proxy, Method method) { 5.52 + if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) { 5.53 + throw new IllegalStateException("Passed object is not proxy!"); 5.54 + } 5.55 + Class<?> declaringClass = method.getDeclaringClass(); 5.56 + if (method == null || declaringClass == null 5.57 + || Modifier.isStatic(method.getModifiers())) { 5.58 + throw new IllegalStateException("Invoking static method is not allowed!"); 5.59 + } 5.60 + } 5.61 + 5.62 public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) { 5.63 return super.process(request, rc, receiver); 5.64 }
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java Fri Oct 11 19:24:06 2013 +0100 6.3 @@ -0,0 +1,92 @@ 6.4 +/* 6.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. Oracle designates this 6.11 + * particular file as subject to the "Classpath" exception as provided 6.12 + * by Oracle in the LICENSE file that accompanied this code. 6.13 + * 6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.17 + * version 2 for more details (a copy is included in the LICENSE file that 6.18 + * accompanied this code). 6.19 + * 6.20 + * You should have received a copy of the GNU General Public License version 6.21 + * 2 along with this work; if not, write to the Free Software Foundation, 6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.23 + * 6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.25 + * or visit www.oracle.com if you need additional information or have any 6.26 + * questions. 6.27 + */ 6.28 + 6.29 +package com.sun.xml.internal.ws.policy.privateutil; 6.30 + 6.31 +import java.lang.reflect.InvocationTargetException; 6.32 +import java.lang.reflect.Method; 6.33 +import java.util.logging.Level; 6.34 +import java.util.logging.Logger; 6.35 + 6.36 +/** 6.37 + * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks 6.38 + * to java.lang,reflect.Method.invoke() 6.39 + */ 6.40 +class MethodUtil { 6.41 + 6.42 + private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName()); 6.43 + private static final Method INVOKE_METHOD; 6.44 + 6.45 + static { 6.46 + Method method; 6.47 + try { 6.48 + Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil"); 6.49 + method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class); 6.50 + if (LOGGER.isLoggable(Level.FINE)) { 6.51 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods."); 6.52 + } 6.53 + } catch (Throwable t) { 6.54 + method = null; 6.55 + if (LOGGER.isLoggable(Level.FINE)) { 6.56 + LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM"); 6.57 + } 6.58 + } 6.59 + INVOKE_METHOD = method; 6.60 + } 6.61 + 6.62 + static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException { 6.63 + if (INVOKE_METHOD != null) { 6.64 + // sun.reflect.misc.MethodUtil.invoke(method, owner, args) 6.65 + if (LOGGER.isLoggable(Level.FINE)) { 6.66 + LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil"); 6.67 + } 6.68 + try { 6.69 + return INVOKE_METHOD.invoke(null, method, target, args); 6.70 + } catch (InvocationTargetException ite) { 6.71 + // unwrap invocation exception added by reflection code ... 6.72 + throw unwrapException(ite); 6.73 + } 6.74 + } else { 6.75 + // other then Oracle JDK ... 6.76 + if (LOGGER.isLoggable(Level.FINE)) { 6.77 + LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM"); 6.78 + } 6.79 + return method.invoke(target, args); 6.80 + } 6.81 + } 6.82 + 6.83 + private static InvocationTargetException unwrapException(InvocationTargetException ite) { 6.84 + Throwable targetException = ite.getTargetException(); 6.85 + if (targetException != null && targetException instanceof InvocationTargetException) { 6.86 + if (LOGGER.isLoggable(Level.FINE)) { 6.87 + LOGGER.log(Level.FINE, "Unwrapping invocation target exception"); 6.88 + } 6.89 + return (InvocationTargetException) targetException; 6.90 + } else { 6.91 + return ite; 6.92 + } 6.93 + } 6.94 + 6.95 +}
7.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java Thu Oct 10 21:22:53 2013 -0700 7.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/privateutil/PolicyUtils.java Fri Oct 11 19:24:06 2013 +0100 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -282,13 +282,13 @@ 7.11 /** 7.12 * Reflection utilities wrapper 7.13 */ 7.14 - public static class Reflection { 7.15 + static class Reflection { 7.16 private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyUtils.Reflection.class); 7.17 7.18 /** 7.19 * Reflectively invokes specified method on the specified target 7.20 */ 7.21 - public static <T> T invoke(final Object target, final String methodName, 7.22 + static <T> T invoke(final Object target, final String methodName, 7.23 final Class<T> resultClass, final Object... parameters) throws RuntimePolicyUtilsException { 7.24 Class[] parameterTypes; 7.25 if (parameters != null && parameters.length > 0) { 7.26 @@ -311,7 +311,7 @@ 7.27 final Object[] parameters, final Class[] parameterTypes) throws RuntimePolicyUtilsException { 7.28 try { 7.29 final Method method = target.getClass().getMethod(methodName, parameterTypes); 7.30 - final Object result = method.invoke(target, parameters); 7.31 + final Object result = MethodUtil.invoke(target, method,parameters); 7.32 7.33 return resultClass.cast(result); 7.34 } catch (IllegalArgumentException e) {