changeset 776:2b5bf002ae54

Merge
author Goetz
date Mon, 03 Jun 2013 15:28:41 +0200
parents 3aac503f5b44 (current diff) aafab1efbd4c (diff)
children d3369261d069
files .hgtags
diffstat 10 files changed, 371 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Mar 12 09:58:17 2013 +0100
+++ b/.hgtags	Mon Jun 03 15:28:41 2013 +0200
@@ -216,6 +216,8 @@
 45cf55bc1732e8495425dceb385740c6852c0fc8 jdk7u9-b02
 66a2e01550a9e84e907a7f7b96e64ee90a4ec0e4 jdk7u9-b04
 f3e42e044584b1b21de29eef1b82974d273c77dc jdk7u9-b05
+5e5703e9d18d66d7388057040d3c36e978488dc5 jdk7u9-b31
+987bb65e7b73ad94fb0edecce80d84ee5f8bda6e jdk7u9-b32
 dd8e4098681aa581d0398ad7d2d1e2547517c7e5 jdk7u10-b10
 1784290b63bcf021334b0accdb3868fdc4ca854e jdk7u10-b11
 fde9a060a04d9f9b54f36d645e91ec9a2b40cb81 jdk7u10-b12
@@ -226,8 +228,11 @@
 e63292c59ed8481864302cc3f53b498cbdea3470 jdk7u10-b17
 6a372e9b4ae978cdaf0b95277db31827794e2c1f jdk7u10-b18
 df3e4c85e26c651d098cddd546916a625fd777cd jdk7u10-b30
+29d469fac9106ce7c2f8656ee125e792908aca98 jdk7u10-b31
 846f4e01218ffe37b2dbceaf89c222c0aea43180 jdk7u11-b20
 1f06394ca182cb392e472ba7b63b28a40725629d jdk7u11-b21
+ac21be8046e06e5460d041b7e4f8140d635887fb jdk7u11-b32
+41abf18b24e9483de775bf938f8d5e673c08209d jdk7u11-b33
 ed609545e38c2e499437292c1541e4d1c2b8b992 jdk7u11-b03
 4e1dd1192649575e80d893bcab411077b77c9a0c jdk7u11-b04
 0e1eefefc2d0c8f0d0cd9e7fb7d78ae026aa8ba0 jdk7u11-b05
@@ -235,6 +240,8 @@
 66786f9d73c479ce70a306e14dd7f653f5b3a4f9 jdk7u11-b07
 a3cadd00459f1146fdcfa8702bbb29efdcd58960 jdk7u11-b08
 c7ea4220ad61b125bd7c4b7f112dd9ff18e9be33 jdk7u13-b09
+1d2eb88cadaf29bf577a71c69b04afe2468d8ff6 jdk7u13-b10
+21dbdd72a46a29c148ea3519268447c467540637 jdk7u13-b30
 1d2eb88cadaf29bf577a71c69b04afe2468d8ff6 jdk7u13-b20
 55dcda93e8c8b5c3170def946de35dd0407eab59 jdk7u8-b01
 c025e953f655b375f27f8f94493ceeb43ef1d979 jdk7u8-b02
@@ -260,3 +267,39 @@
 4fe9a362c3277cd4c7a5149853e5cf59dbba7cb7 jdk7u14-b13
 a2b2e716637acdb9884d21fc4b9aef3c8b59e702 jdk7u14-b14
 53bd8e6a5ffabdc878a312509cf84a72020ddf9a ppc-aix-port-b04
+b5c8ac5253ef735e5aa770b7325843ec89b56633 jdk7u14-b15
+abcaebcead605f89cd0919add20d8ac16637ddc2 jdk7u15-b01
+62f9e7f5eb644fedd93dd93bd36bcf817a8d9c8a jdk7u15-b02
+ed9f270009f2b8606e9e0f58aeedbed36e13963e jdk7u15-b30
+297240e69d8ffcf85fc68b12af6523f7ea16397e jdk7u15-b31
+4fda3b01c75ecd80dba505f6152c21f3e1db5cce jdk7u15-b33
+eaf9b299067069826a5acdc88e15402e5a22cb5d jdk7u15-b03
+c7ea4220ad61b125bd7c4b7f112dd9ff18e9be33 jdk7u15-b32
+b8496d1dc0058341da1790bc2e7d2dbba6d4f90e jdk7u17-b01
+defde3ef03605b1660a246ea85d2e810e3fe4f6e jdk7u17-b02
+ae4272d61bc738e2d9265a68aefdc20ec648f22c jdk7u17-b30
+52c4fbd4f58f336dfdf4f680b7e7d7361ec0c3f8 jdk7u17-b31
+e07c518282bad3b315d8064da5fad222a5e3f7ed jdk7u21-b01
+0c1365d2fefb652aea34775749d68774c171ba1a jdk7u21-b02
+017171d6bc217f26e230503dd38bcf4473f339d2 jdk7u21-b03
+68e8364feffcc98b57d59675994dcb12e170ddf0 jdk7u21-b04
+8c43fd5d8cfef4d97bddc4fee7747f23a3c2bffa jdk7u21-b05
+dab51e98ee7d0f3a30b9e18b0d3591b944346868 jdk7u21-b06
+4a9533495068359d574da1060bc5a8fa6946cbc6 jdk7u21-b07
+ab11cef1dfaaec32281dc3d24a366f6691b51b7a jdk7u21-b08
+53c87e8a2ac494b57f6220bd7e25c7380aa7f418 jdk7u21-b09
+29c03ced9215a0bb63a4527dc5858b486cc4099d jdk7u21-b10
+fe6f5b57b9e67a7c6f52a5f926ac17e5c337d4a4 jdk7u21-b11
+12183763c6205c5cfe27924ccc4ca5480106c3b4 jdk7u21-b30
+d4eba65d0f776b77ef137022cd7bf49dc3b88a3e jdk7u21-b12
+a367ebf0c21512867f4ab5cdd206dd8c7817c004 jdk7u14-b16
+74c34f35912d8d7145b3ff34fefea2d2f189f2b4 jdk7u14-b17
+c93a35b3638f45de91013d65543217a002577684 jdk7u14-b18
+82be38857de3b2f6d8def98034f3e7b0827fd9f0 jdk7u14-b19
+82be38857de3b2f6d8def98034f3e7b0827fd9f0 jdk7u14-b19
+d63b21e6c3d29305400dbfc1500090cab89f25d1 jdk7u14-b19
+dd695ad6c5ec797fe61db31600a3fd2dbc62247b jdk7u14-b20
+97bbac299eb801709a924fe777b3ee9c96829d8b jdk7u14-b21
+6e74b3e1773cfbac99998431a5a54c70baaf1dc5 jdk7u14-b22
+e9bbdf789d2b512550e0ca80629980e96f02146d jdk7u40-b23
+adaf9cf486fab1b14c5af9fc6525565760bb9c11 jdk7u40-b24
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ModelBuilder.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ModelBuilder.java	Mon Jun 03 15:28:41 2013 +0200
@@ -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
@@ -235,7 +235,7 @@
                         String pkg = nav.getPackageName(ci.getClazz());
                         if(!registries.containsKey(pkg)) {
                             // insert the package's object factory
-                            C c = nav.findClass(pkg + ".ObjectFactory",ci.getClazz());
+                            C c = loadObjectFactory(ci, pkg);
                             if(c!=null)
                                 addRegistry(c,(Locatable)p);
                         }
@@ -264,6 +264,15 @@
         return r;
     }
 
+    private C loadObjectFactory(ClassInfoImpl<T, C, F, M> ci, String pkg) {
+        try {
+            return nav.findClass(pkg + ".ObjectFactory", ci.getClazz());
+        } catch (SecurityException ignored) {
+            // treat SecurityException in same way as ClassNotFoundException in this case
+            return null;
+        }
+    }
+
     /**
      * Checks the uniqueness of the type name.
      */
--- a/src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/MemoryData.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/MemoryData.java	Mon Jun 03 15:28:41 2013 +0200
@@ -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
@@ -28,6 +28,7 @@
 import java.nio.ByteBuffer;
 import java.io.File;
 import java.io.IOException;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -50,41 +51,45 @@
     }
 
     // size of the chunk given by the parser
+    @Override
     public int size() {
         return len;
     }
 
+    @Override
     public byte[] read() {
         return data;
     }
 
+    @Override
     public long writeTo(DataFile file) {
         return file.writeTo(data, 0, len);
     }
 
     /**
-     *
      * @param dataHead
      * @param buf
      * @return
      */
+    @Override
     public Data createNext(DataHead dataHead, ByteBuffer buf) {
         if (!config.isOnlyMemory() && dataHead.inMemory >= config.memoryThreshold) {
             try {
                 String prefix = config.getTempFilePrefix();
                 String suffix = config.getTempFileSuffix();
-                File dir = config.getTempDir();
-                File tempFile = (dir == null)
-                        ? File.createTempFile(prefix, suffix)
-                        : File.createTempFile(prefix, suffix, dir);
-                LOGGER.fine("Created temp file = "+tempFile);
+                File tempFile = TempFiles.createTempFile(prefix, suffix, config.getTempDir());
+                // delete the temp file when VM exits as a last resort for file clean up
+                tempFile.deleteOnExit();
+                if (LOGGER.isLoggable(Level.FINE)) {
+                    LOGGER.log(Level.FINE, "Created temp file = {0}", tempFile);
+                }
                 dataHead.dataFile = new DataFile(tempFile);
-            } catch(IOException ioe) {
+            } catch (IOException ioe) {
                 throw new MIMEParsingException(ioe);
             }
 
             if (dataHead.head != null) {
-                for(Chunk c=dataHead.head; c != null; c=c.next) {
+                for (Chunk c = dataHead.head; c != null; c = c.next) {
                     long pointer = c.data.writeTo(dataHead.dataFile);
                     c.data = new FileData(dataHead.dataFile, pointer, len);
                 }
@@ -94,4 +99,5 @@
             return new MemoryData(buf, config);
         }
     }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/TempFiles.java	Mon Jun 03 15:28:41 2013 +0200
@@ -0,0 +1,144 @@
+/*
+ * 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.org.jvnet.mimepull;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Helper utility to support jdk <= jdk1.6. After jdk1.6 EOL reflection can be removed and API can be used directly.
+ */
+class TempFiles {
+
+    private static final Logger LOGGER = Logger.getLogger(TempFiles.class.getName());
+
+    private static final Class<?> CLASS_FILES;
+    private static final Class<?> CLASS_PATH;
+    private static final Class<?> CLASS_FILE_ATTRIBUTE;
+    private static final Class<?> CLASS_FILE_ATTRIBUTES;
+    private static final Method METHOD_FILE_TO_PATH;
+    private static final Method METHOD_FILES_CREATE_TEMP_FILE;
+    private static final Method METHOD_FILES_CREATE_TEMP_FILE_WITHPATH;
+
+    private static final Method METHOD_PATH_TO_FILE;
+
+    private static boolean useJdk6API;
+
+    static {
+        useJdk6API = isJdk6();
+
+        CLASS_FILES = safeGetClass("java.nio.file.Files");
+        CLASS_PATH = safeGetClass("java.nio.file.Path");
+        CLASS_FILE_ATTRIBUTE = safeGetClass("java.nio.file.attribute.FileAttribute");
+        CLASS_FILE_ATTRIBUTES = safeGetClass("[Ljava.nio.file.attribute.FileAttribute;");
+        METHOD_FILE_TO_PATH = safeGetMethod(File.class, "toPath");
+        METHOD_FILES_CREATE_TEMP_FILE = safeGetMethod(CLASS_FILES, "createTempFile", String.class, String.class, CLASS_FILE_ATTRIBUTES);
+        METHOD_FILES_CREATE_TEMP_FILE_WITHPATH = safeGetMethod(CLASS_FILES, "createTempFile", CLASS_PATH, String.class, String.class, CLASS_FILE_ATTRIBUTES);
+        METHOD_PATH_TO_FILE = safeGetMethod(CLASS_PATH, "toFile");
+    }
+
+    private static boolean isJdk6() {
+        String javaVersion = System.getProperty("java.version");
+        LOGGER.log(Level.FINEST, "Detected java version = {0}", javaVersion);
+        return javaVersion.startsWith("1.6.");
+    }
+
+    private static Class<?> safeGetClass(String className) {
+        // it is jdk 6 or something failed already before
+        if (useJdk6API) return null;
+        try {
+            return Class.forName(className);
+        } catch (ClassNotFoundException e) {
+            LOGGER.log(Level.SEVERE, "Exception cought", e);
+            LOGGER.log(Level.WARNING, "Class {0} not found. Temp files will be created using old java.io API.", className);
+            useJdk6API = true;
+            return null;
+        }
+    }
+
+    private static Method safeGetMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
+        // it is jdk 6 or something failed already before
+        if (useJdk6API) return null;
+        try {
+            return clazz.getMethod(methodName, parameterTypes);
+        } catch (NoSuchMethodException e) {
+            LOGGER.log(Level.SEVERE, "Exception cought", e);
+            LOGGER.log(Level.WARNING, "Method {0} not found. Temp files will be created using old java.io API.", methodName);
+            useJdk6API = true;
+            return null;
+        }
+    }
+
+
+    static Object toPath(File f) throws InvocationTargetException, IllegalAccessException {
+        return METHOD_FILE_TO_PATH.invoke(f);
+    }
+
+    static File toFile(Object path) throws InvocationTargetException, IllegalAccessException {
+        return (File) METHOD_PATH_TO_FILE.invoke(path);
+    }
+
+    static File createTempFile(String prefix, String suffix, File dir) throws IOException {
+
+        if (useJdk6API) {
+            LOGGER.log(Level.FINEST, "Jdk6 detected, temp file (prefix:{0}, suffix:{1}) being created using old java.io API.", new Object[]{prefix, suffix});
+            return File.createTempFile(prefix, suffix, dir);
+
+        } else {
+
+            try {
+                if (dir != null) {
+                    Object path = toPath(dir);
+                    LOGGER.log(Level.FINEST, "Temp file (path: {0}, prefix:{1}, suffix:{2}) being created using NIO API.", new Object[]{dir.getAbsolutePath(), prefix, suffix});
+                    return toFile(METHOD_FILES_CREATE_TEMP_FILE_WITHPATH.invoke(null, path, prefix, suffix, Array.newInstance(CLASS_FILE_ATTRIBUTE, 0)));
+                } else {
+                    LOGGER.log(Level.FINEST, "Temp file (prefix:{0}, suffix:{1}) being created using NIO API.", new Object[]{prefix, suffix});
+                    return toFile(METHOD_FILES_CREATE_TEMP_FILE.invoke(null, prefix, suffix, Array.newInstance(CLASS_FILE_ATTRIBUTE, 0)));
+                }
+
+            } catch (IllegalAccessException e) {
+                LOGGER.log(Level.SEVERE, "Exception caught", e);
+                LOGGER.log(Level.WARNING, "Error invoking java.nio API, temp file (path: {0}, prefix:{1}, suffix:{2}) being created using old java.io API.",
+                        new Object[]{dir != null ? dir.getAbsolutePath() : null, prefix, suffix});
+                return File.createTempFile(prefix, suffix, dir);
+
+            } catch (InvocationTargetException e) {
+                LOGGER.log(Level.SEVERE, "Exception caught", e);
+                LOGGER.log(Level.WARNING, "Error invoking java.nio API, temp file (path: {0}, prefix:{1}, suffix:{2}) being created using old java.io API.",
+                        new Object[]{dir != null ? dir.getAbsolutePath() : null, prefix, suffix});
+                return File.createTempFile(prefix, suffix, dir);
+            }
+        }
+
+    }
+
+
+}
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java	Mon Jun 03 15:28:41 2013 +0200
@@ -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
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package com.sun.xml.internal.ws.client;
 
 import com.sun.istack.internal.NotNull;
@@ -30,13 +29,11 @@
 import com.sun.xml.internal.ws.Closeable;
 import com.sun.xml.internal.ws.api.BindingID;
 import com.sun.xml.internal.ws.api.EndpointAddress;
-import com.sun.xml.internal.ws.api.WSBinding;
 import com.sun.xml.internal.ws.api.WSService;
 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
 import com.sun.xml.internal.ws.api.client.ServiceInterceptor;
 import com.sun.xml.internal.ws.api.client.ServiceInterceptorFactory;
-import com.sun.xml.internal.ws.api.model.SEIModel;
-import com.sun.xml.internal.ws.api.pipe.*;
+import com.sun.xml.internal.ws.api.pipe.Stubs;
 import com.sun.xml.internal.ws.api.server.Container;
 import com.sun.xml.internal.ws.api.server.ContainerResolver;
 import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
@@ -45,8 +42,8 @@
 import com.sun.xml.internal.ws.client.HandlerConfigurator.AnnotationConfigurator;
 import com.sun.xml.internal.ws.client.HandlerConfigurator.HandlerResolverImpl;
 import com.sun.xml.internal.ws.client.sei.SEIStub;
+import com.sun.xml.internal.ws.developer.UsesJAXBContextFeature;
 import com.sun.xml.internal.ws.developer.WSBindingProvider;
-import com.sun.xml.internal.ws.developer.UsesJAXBContextFeature;
 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl;
 import com.sun.xml.internal.ws.model.RuntimeModeler;
 import com.sun.xml.internal.ws.model.SOAPSEIModel;
@@ -59,7 +56,6 @@
 import com.sun.xml.internal.ws.util.JAXWSUtils;
 import com.sun.xml.internal.ws.util.ServiceConfigurationError;
 import com.sun.xml.internal.ws.util.ServiceFinder;
-import static com.sun.xml.internal.ws.util.xml.XmlUtil.createDefaultCatalogResolver;
 import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser;
 import org.xml.sax.SAXException;
 
@@ -74,16 +70,17 @@
 import javax.xml.ws.handler.HandlerResolver;
 import javax.xml.ws.soap.AddressingFeature;
 import java.io.IOException;
+import java.lang.RuntimePermission;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import java.security.*;
 import java.util.*;
 import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
+import static com.sun.xml.internal.ws.util.xml.XmlUtil.createDefaultCatalogResolver;
+
 /**
  * <code>Service</code> objects provide the client view of a Web service.
  *
@@ -578,7 +575,7 @@
         }
     }
 
-    private <T> T createEndpointIFBaseProxy(@Nullable WSEndpointReference epr,QName portName, Class<T> portInterface,
+    private <T> T createEndpointIFBaseProxy(@Nullable WSEndpointReference epr,QName portName, final Class<T> portInterface,
                                             WebServiceFeature[] webServiceFeatures, SEIPortInfo eif) {
         //fail if service doesnt have WSDL
         if (wsdlService == null)
@@ -592,14 +589,37 @@
         BindingImpl binding = eif.createBinding(webServiceFeatures,portInterface);
         SEIStub pis = new SEIStub(eif, binding, eif.model, epr);
 
-        T proxy = portInterface.cast(Proxy.newProxyInstance(portInterface.getClassLoader(),
-                new Class[]{portInterface, WSBindingProvider.class, Closeable.class}, pis));
+        T proxy = createProxy(portInterface, pis);
+
         if (serviceInterceptor != null) {
             serviceInterceptor.postCreateProxy((WSBindingProvider)proxy, portInterface);
         }
         return proxy;
     }
 
+    private <T> T createProxy(final Class<T> portInterface, final SEIStub pis) {
+
+        // accessClassInPackage privilege needs to be granted ...
+        RuntimePermission perm = new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.*");
+        PermissionCollection perms = perm.newPermissionCollection();
+        perms.add(perm);
+
+        return AccessController.doPrivileged(
+                new PrivilegedAction<T>() {
+                    @Override
+                    public T run() {
+                        Object proxy = Proxy.newProxyInstance(portInterface.getClassLoader(),
+                                new Class[]{portInterface, WSBindingProvider.class, Closeable.class}, pis);
+                        return portInterface.cast(proxy);
+                    }
+                },
+                new AccessControlContext(
+                        new ProtectionDomain[]{
+                                new ProtectionDomain(null, perms)
+                        })
+        );
+    }
+
     /**
      * Lists up the port names in WSDL. For error diagnostics.
      */
--- a/src/share/jaxws_classes/javax/xml/soap/FactoryFinder.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/javax/xml/soap/FactoryFinder.java	Mon Jun 03 15:28:41 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -43,20 +43,12 @@
         throws SOAPException
     {
         try {
-            Class spiClass;
-            if (classLoader == null) {
-                spiClass = Class.forName(className);
-            } else {
-                spiClass = classLoader.loadClass(className);
-            }
+            Class spiClass = safeLoadClass(className, classLoader);
             return spiClass.newInstance();
         } catch (ClassNotFoundException x) {
-            throw new SOAPException(
-                "Provider " + className + " not found", x);
+            throw new SOAPException("Provider " + className + " not found", x);
         } catch (Exception x) {
-            throw new SOAPException(
-                "Provider " + className + " could not be instantiated: " + x,
-                x);
+            throw new SOAPException("Provider " + className + " could not be instantiated: " + x, x);
         }
     }
 
@@ -73,11 +65,65 @@
      *                              a system property
      * @exception SOAPException if there is a SOAP error
      */
-    static Object find(String factId)
+    static Object find(String factoryId)
+        throws SOAPException
+    {
+        return find(factoryId, null, false);
+    }
+
+    /**
+     * Finds the implementation <code>Class</code> object for the given
+     * factory name, or if that fails, finds the <code>Class</code> object
+     * for the given fallback class name. The arguments supplied must be
+     * used in order. If using the first argument is successful, the second
+     * one will not be used.
+     * <P>
+     * This method is package private so that this code can be shared.
+     *
+     * @return the <code>Class</code> object of the specified message factory;
+     *         may be <code>null</code>
+     *
+     * @param factoryId             the name of the factory to find, which is
+     *                              a system property
+     * @param fallbackClassName     the implementation class name, which is
+     *                              to be used only if nothing else
+     *                              is found; <code>null</code> to indicate that
+     *                              there is no fallback class name
+     * @exception SOAPException if there is a SOAP error
+     */
+    static Object find(String factoryId, String fallbackClassName)
         throws SOAPException
     {
-        final ClassLoader classLoader;
-        final String factoryId = factId;
+        return find(factoryId, fallbackClassName, true);
+    }
+
+    /**
+     * Finds the implementation <code>Class</code> object for the given
+     * factory name, or if that fails, finds the <code>Class</code> object
+     * for the given default class name, but only if <code>tryFallback</code>
+     * is <code>true</code>.  The arguments supplied must be used in order
+     * If using the first argument is successful, the second one will not
+     * be used.  Note the default class name may be needed even if fallback
+     * is not to be attempted, so certain error conditions can be handled.
+     * <P>
+     * This method is package private so that this code can be shared.
+     *
+     * @return the <code>Class</code> object of the specified message factory;
+     *         may not be <code>null</code>
+     *
+     * @param factoryId             the name of the factory to find, which is
+     *                              a system property
+     * @param defaultClassName      the implementation class name, which is
+     *                              to be used only if nothing else
+     *                              is found; <code>null</code> to indicate
+     *                              that there is no default class name
+     * @param tryFallback           whether to try the default class as a
+     *                              fallback
+     * @exception SOAPException if there is a SOAP error
+     */
+    static Object find(String factoryId, String defaultClassName,
+            boolean tryFallback) throws SOAPException {
+        ClassLoader classLoader;
         try {
             classLoader = Thread.currentThread().getContextClassLoader();
         } catch (Exception x) {
@@ -99,7 +145,7 @@
             String javah=System.getProperty( "java.home" );
             String configFile = javah + File.separator +
                 "lib" + File.separator + "jaxm.properties";
-            final File f=new File( configFile );
+            File f=new File( configFile );
             if( f.exists()) {
                 Properties props=new Properties();
                 props.load( new FileInputStream(f));
@@ -134,49 +180,56 @@
         } catch( Exception ex ) {
         }
 
-        return null;
+        // If not found and fallback should not be tried, return a null result.
+        if (!tryFallback)
+            return null;
+
+        // We didn't find the class through the usual means so try the default
+        // (built in) factory if specified.
+        if (defaultClassName == null) {
+            throw new SOAPException(
+                "Provider for " + factoryId + " cannot be found", null);
+        }
+        return newInstance(defaultClassName, classLoader);
     }
 
     /**
-     * Finds the implementation <code>Class</code> object for the given
-     * factory name, or if that fails, finds the <code>Class</code> object
-     * for the given fallback class name. The arguments supplied must be
-     * used in order. If using the first argument is successful, the second
-     * one will not be used.
-     * <P>
-     * This method is package private so that this code can be shared.
-     *
-     * @return the <code>Class</code> object of the specified message factory;
-     *         may not be <code>null</code>
-     *
-     * @param factoryId             the name of the factory to find, which is
-     *                              a system property
-     * @param fallbackClassName     the implementation class name, which is
-     *                              to be used only if nothing else
-     *                              is found; <code>null</code> to indicate that
-     *                              there is no fallback class name
-     * @exception SOAPException if there is a SOAP error
+     * Loads the class, provided that the calling thread has an access to the
+     * class being loaded. If this is the specified default factory class and it
+     * is restricted by package.access we get a SecurityException and can do a
+     * Class.forName() on it so it will be loaded by the bootstrap class loader.
      */
-    static Object find(String factoryId, String fallbackClassName)
-        throws SOAPException
-    {
-
-        Object obj = find(factoryId);
-        if (obj != null)
-            return obj;
-
-        ClassLoader classLoader;
+    private static Class safeLoadClass(String className,
+            ClassLoader classLoader)
+            throws ClassNotFoundException {
         try {
-            classLoader = Thread.currentThread().getContextClassLoader();
-        } catch (Exception x) {
-            throw new SOAPException(x.toString(), x);
-        }
+            // make sure that the current thread has an access to the package of the given name.
+            SecurityManager s = System.getSecurityManager();
+            if (s != null) {
+                int i = className.lastIndexOf('.');
+                if (i != -1) {
+                    s.checkPackageAccess(className.substring(0, i));
+                }
+            }
 
-        if (fallbackClassName == null) {
-            throw new SOAPException(
-                "Provider for " + factoryId + " cannot be found", null);
+            if (classLoader == null)
+                return Class.forName(className);
+            else
+                return classLoader.loadClass(className);
+        } catch (SecurityException se) {
+            // (only) default implementation can be loaded
+            // using bootstrap class loader ...
+            if (isDefaultImplementation(className))
+                return Class.forName(className);
+
+            throw se;
         }
+    }
 
-        return newInstance(fallbackClassName, classLoader);
+    private static boolean isDefaultImplementation(String className) {
+        return MessageFactory.DEFAULT_MESSAGE_FACTORY.equals(className) ||
+                SOAPFactory.DEFAULT_SOAP_FACTORY.equals(className) ||
+                SOAPConnectionFactory.DEFAULT_SOAP_CONNECTION_FACTORY.equals(className) ||
+                SAAJMetaFactory.DEFAULT_META_FACTORY_CLASS.equals(className);
     }
 }
--- a/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java	Mon Jun 03 15:28:41 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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 MessageFactory {
 
-    static private final String DEFAULT_MESSAGE_FACTORY
+    static final String DEFAULT_MESSAGE_FACTORY
         = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl";
 
     static private final String MESSAGE_FACTORY_PROPERTY
@@ -99,11 +99,14 @@
     public static MessageFactory newInstance()
         throws SOAPException {
         try {
-            MessageFactory factory = (MessageFactory)
-                FactoryFinder.find(MESSAGE_FACTORY_PROPERTY);
+            MessageFactory factory = (MessageFactory) FactoryFinder.find(
+                    MESSAGE_FACTORY_PROPERTY,
+                    DEFAULT_MESSAGE_FACTORY,
+                    false);
 
-            if (factory != null)
+            if (factory != null) {
                 return factory;
+            }
 
             return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
         } catch (Exception ex) {
--- a/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java	Mon Jun 03 15:28:41 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -44,7 +44,7 @@
 public abstract class SAAJMetaFactory {
     static private final String META_FACTORY_CLASS_PROPERTY =
         "javax.xml.soap.MetaFactory";
-    static private final String DEFAULT_META_FACTORY_CLASS =
+    static final String DEFAULT_META_FACTORY_CLASS =
         "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
 
     /**
--- a/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java	Mon Jun 03 15:28:41 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -38,7 +38,7 @@
      * A constant representing the default value for a <code>SOAPConnection</code>
      * object. The default is the point-to-point SOAP connection.
      */
-    static private final String DEFAULT_SOAP_CONNECTION_FACTORY
+    static final String DEFAULT_SOAP_CONNECTION_FACTORY
         = "com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory";
 
     /**
--- a/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java	Tue Mar 12 09:58:17 2013 +0100
+++ b/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java	Mon Jun 03 15:28:41 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -54,6 +54,12 @@
         "javax.xml.soap.SOAPFactory";
 
     /**
+     * Class name of default <code>SOAPFactory</code> implementation.
+     */
+    static final String DEFAULT_SOAP_FACTORY
+        = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl";
+
+    /**
      * Creates a <code>SOAPElement</code> object from an existing DOM
      * <code>Element</code>. If the DOM <code>Element</code> that is passed in
      * as an argument is already a <code>SOAPElement</code> then this method
@@ -255,7 +261,7 @@
         throws SOAPException
     {
         try {
-            SOAPFactory factory = (SOAPFactory) FactoryFinder.find(SOAP_FACTORY_PROPERTY);
+            SOAPFactory factory = (SOAPFactory) FactoryFinder.find(SOAP_FACTORY_PROPERTY, DEFAULT_SOAP_FACTORY, false);
             if (factory != null)
                 return factory;
             return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);