changeset 924:611fdb7bcd4f icedtea-2.5pre04

Merge jdk7u60-b15
author andrew
date Thu, 17 Apr 2014 17:52:19 +0100
parents 72b336b5bb7f (current diff) fefd2d5c524b (diff)
children 89656c61a515
files .hgtags src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java src/com/sun/org/apache/xml/internal/serializer/CharInfo.java src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java
diffstat 7 files changed, 103 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Apr 02 20:04:06 2014 +0100
+++ b/.hgtags	Thu Apr 17 17:52:19 2014 +0100
@@ -397,6 +397,7 @@
 d9b92749a0f4c8e6c6f4fe11210c2a02d70bae74 jdk7u60-b00
 056494e83d15cd1c546d32a3b35bdb6f670b3876 jdk7u45-b33
 b5a83862ed2ab9cc2de3719e38c72519481a4bbb jdk7u45-b34
+7fda9b300e07738116b2b95b568229bdb4b31059 jdk7u45-b35
 0a8b95184728548be4b20876e05f76e0262e4195 jdk7u51-b00
 2450ace952f45202e5a3fd4f6a8356a196fe029e jdk7u51-b01
 68def851cc6b17944756f1986734b323d8569571 jdk7u51-b02
@@ -413,6 +414,26 @@
 114654a331e2f97a048d7ed43d06d7512e20e2c1 jdk7u51-b13
 3161567adae93d12c64b79592bda3046f0c0a22d jdk7u51-b30
 e85ee81daec2ea2fa21bf804d03431b0664c6dff jdk7u51-b31
+1a6c3258ad218bf286c47d65e4cd80eb6763f8df jdk7u51-b33
+9cdc04d76eb19a871c739625acd801ed1b24bed9 jdk7u51-b34
+807946db29f42477e8d8390be01c7e27280bc85c jdk7u55-b00
+bb7779a8fc4d14719e907b8890a2665476cf45ae jdk7u55-b01
+8275dc4db7f852edb331ae48d663d08b9ab2b5c7 jdk7u55-b02
+381e73f93a83e8d3bfd7dbf79f4f363a8fd6442f jdk7u55-b03
+c72c57f71c2ba6362d9ccfbf4743947b9ecefcac jdk7u55-b04
+5592b0c44617022e3c136eedfa1e98d4f254c964 jdk7u55-b05
+c59d714090080ad2e06f0ca5e8d354403059d8ce jdk7u55-b06
+125ea54089add3a16898b801a9989bf6cca05da6 jdk7u55-b07
+39337c00cb3ce29b4d67f6d247c3fa80f16cb49f jdk7u55-b08
+537f4f609132f3d6a4ce506c98f1dbd57f1320f8 jdk7u55-b09
+997bdd44d5de4aee319ff0a0d2892a912d9de6f5 jdk7u55-b09
+606483a43e8b6317d84922b9ed2b2c30d9e77419 jdk7u55-b10
+f3f02e67d867ae25cd4f3b9bc39a4fd17f593126 jdk7u55-b11
+708a1872f5bb8ba58ecc9fcbf4e12e6fa4783998 jdk7u55-b12
+14719f73596f5c90e3f46c0f4312f32e5b105edd jdk7u55-b13
+01f26830f88cf4f10897416fe1f4f372efcdecf5 jdk7u55-b30
+26187a65c765b3177f1b7ff0638259bf66f9ec47 jdk7u55-b14
+5be97f6c25d9eb3ef0a05fc860964cb3d27134b0 jdk7u55-b31
 d9b92749a0f4c8e6c6f4fe11210c2a02d70bae74 jdk7u60-b00
 ad39e88c503948fc4fc01e97c75b6e3c24599d23 jdk7u60-b01
 050986fd54e3ec4515032ee938bc59e86772b6c0 jdk7u60-b02
@@ -428,3 +449,7 @@
 28a6c0b3b22580101bf750383c2e48d34dea2124 jdk7u60-b10
 e57490e0b99917ea8e1da1bb4d0c57fd5b7705f9 jdk7u60-b11
 1fef0a819b0acd01898f16d75fe924720412c9fd icedtea-2.5pre03
+a9574b35f0af409fa1665aadd9b2997a0f9878dc jdk7u60-b12
+92cf0b5c1c3e9b61d36671d8fb5070716e0f016b jdk7u60-b13
+2814f43a6c73414dcb2b799e1a52d5b44688590d jdk7u60-b14
+10eed57b66336660f71f7524f2283478bdf373dc jdk7u60-b15
--- a/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Thu Apr 17 17:52:19 2014 +0100
@@ -54,8 +54,8 @@
     //
     // Constants
     //
-     private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal";
-     private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal";
+     private static final String JAXP_INTERNAL = "com.sun.org.apache";
+     private static final String STAX_INTERNAL = "com.sun.xml.internal";
 
     // name of default properties file to look for in JDK's jre/lib directory
     private static final String DEFAULT_PROPERTIES_FILENAME =
@@ -497,12 +497,8 @@
     public static Class findProviderClass(String className, boolean doFallback)
         throws ClassNotFoundException, ConfigurationError
     {
-        if (System.getSecurityManager()!=null) {
-            return Class.forName(className);
-        } else {
-            return findProviderClass (className,
+        return findProviderClass (className,
                 findClassLoader (), doFallback);
-        }
     }
 
     /**
@@ -517,8 +513,8 @@
         SecurityManager security = System.getSecurityManager();
         try{
             if (security != null){
-                if (className.startsWith(XALAN_INTERNAL) ||
-                    className.startsWith(XERCES_INTERNAL)) {
+                if (className.startsWith(JAXP_INTERNAL) ||
+                    className.startsWith(STAX_INTERNAL)) {
                     cl = null;
                 } else {
                     final int lastDot = className.lastIndexOf(".");
@@ -533,16 +529,7 @@
 
         Class providerClass;
         if (cl == null) {
-            // XXX Use the bootstrap ClassLoader.  There is no way to
-            // load a class using the bootstrap ClassLoader that works
-            // in both JDK 1.1 and Java 2.  However, this should still
-            // work b/c the following should be true:
-            //
-            // (cl == null) iff current ClassLoader == null
-            //
-            // Thus Class.forName(String) will use the current
-            // ClassLoader which will be the bootstrap ClassLoader.
-            providerClass = Class.forName(className);
+            providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader());
         } else {
             try {
                 providerClass = cl.loadClass(className);
--- a/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java	Thu Apr 17 17:52:19 2014 +0100
@@ -57,7 +57,7 @@
         return securitySupport;
     }
 
-    static ClassLoader getContextClassLoader() {
+    public static ClassLoader getContextClassLoader() {
         return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 ClassLoader cl = null;
--- a/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Thu Apr 17 17:52:19 2014 +0100
@@ -48,7 +48,8 @@
     //
     // Constants
     //
-    private static final String DEFAULT_INTERNAL_CLASSES = "com.sun.org.apache.";
+    private static final String JAXP_INTERNAL = "com.sun.org.apache";
+    private static final String STAX_INTERNAL = "com.sun.xml.internal";
 
     // name of default properties file to look for in JDK's jre/lib directory
     private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties";
@@ -288,12 +289,8 @@
     public static Class findProviderClass(String className, boolean doFallback)
         throws ClassNotFoundException, ConfigurationError
     {
-        if (System.getSecurityManager()!=null) {
-            return Class.forName(className);
-        } else {
-            return findProviderClass (className,
+        return findProviderClass (className,
                 findClassLoader (), doFallback);
-        }
     }
     /**
      * Find a Class using the specified ClassLoader
@@ -306,7 +303,8 @@
         //restrict the access to package as speicified in java.security policy
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
-            if (className.startsWith(DEFAULT_INTERNAL_CLASSES)) {
+            if (className.startsWith(JAXP_INTERNAL) ||
+                    className.startsWith(STAX_INTERNAL)) {
                 cl = null;
             } else {
                 final int lastDot = className.lastIndexOf(".");
@@ -318,7 +316,7 @@
         Class providerClass;
         if (cl == null) {
             //use the bootstrap ClassLoader.
-            providerClass = Class.forName(className);
+            providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader());
         } else {
             try {
                 providerClass = cl.loadClass(className);
--- a/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Thu Apr 17 17:52:19 2014 +0100
@@ -22,6 +22,11 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
+import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
+import com.sun.org.apache.xml.internal.serializer.utils.Utils;
+import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -29,19 +34,11 @@
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 import javax.xml.transform.TransformerException;
 
-import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
-import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
-import com.sun.org.apache.xml.internal.serializer.utils.Utils;
-import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-
 /**
  * This class provides services that tell if a character should have
  * special treatement, such as entity reference substitution or normalization
@@ -176,13 +173,19 @@
         //      file
         //   3) try treating the resource a URI
 
-        if (internal) {
-            try {
+        try {
+            if (internal) {
                 // Load entity property files by using PropertyResourceBundle,
                 // cause of security issure for applets
                 entities = PropertyResourceBundle.getBundle(entitiesResource);
-            } catch (Exception e) {}
-        }
+            } else {
+                ClassLoader cl = SecuritySupport.getContextClassLoader();
+                if (cl != null) {
+                    entities = PropertyResourceBundle.getBundle(entitiesResource,
+                            Locale.getDefault(), cl);
+                }
+            }
+        } catch (Exception e) {}
 
         if (entities != null) {
             Enumeration keys = entities.getKeys();
@@ -198,6 +201,7 @@
             set(S_CARRIAGERETURN);
         } else {
             InputStream is = null;
+            String err = null;
 
             // Load user specified resource file by using URL loading, it
             // requires a valid URI as parameter
@@ -205,18 +209,22 @@
                 if (internal) {
                     is = CharInfo.class.getResourceAsStream(entitiesResource);
                 } else {
-                    ClassLoader cl = ObjectFactory.findClassLoader();
-                    if (cl == null) {
-                        is = ClassLoader.getSystemResourceAsStream(entitiesResource);
-                    } else {
-                        is = cl.getResourceAsStream(entitiesResource);
+                    ClassLoader cl = SecuritySupport.getContextClassLoader();
+                    if (cl != null) {
+                        try {
+                            is = cl.getResourceAsStream(entitiesResource);
+                        } catch (Exception e) {
+                            err = e.getMessage();
+                        }
                     }
 
                     if (is == null) {
                         try {
                             URL url = new URL(entitiesResource);
                             is = url.openStream();
-                        } catch (Exception e) {}
+                        } catch (Exception e) {
+                            err = e.getMessage();
+                        }
                     }
                 }
 
@@ -224,7 +232,7 @@
                     throw new RuntimeException(
                         Utils.messages.createMessage(
                             MsgKey.ER_RESOURCE_COULD_NOT_FIND,
-                            new Object[] {entitiesResource, entitiesResource}));
+                            new Object[] {entitiesResource, err}));
                 }
 
                 // Fix Bugzilla#4000: force reading in UTF-8
@@ -456,64 +464,56 @@
         return isCleanTextASCII[value];
     }
 
-//  In the future one might want to use the array directly and avoid
-//  the method call, but I think the JIT alreay inlines this well enough
-//  so don't do it (for now) - bjm
-//    public final boolean[] getASCIIClean()
-//    {
-//        return isCleanTextASCII;
-//    }
-
 
-    private static CharInfo getCharInfoBasedOnPrivilege(
-        final String entitiesFileName, final String method,
-        final boolean internal){
-            return (CharInfo) AccessController.doPrivileged(
-                new PrivilegedAction() {
-                        public Object run() {
-                            return new CharInfo(entitiesFileName,
-                              method, internal);}
-            });
+    /**
+     * Read an internal resource file that describes the mapping of
+     * characters to entity references; Construct a CharInfo object.
+     *
+     * @param entitiesFileName Name of entities resource file that should
+     * be loaded, which describes the mapping of characters to entity references.
+     * @param method the output method type, which should be one of "xml", "html", and "text".
+     * @return an instance of CharInfo
+     *
+     * @xsl.usage internal
+     */
+    static CharInfo getCharInfoInternal(String entitiesFileName, String method)
+    {
+        CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
+        if (charInfo != null) {
+            return charInfo;
+        }
+
+        charInfo = new CharInfo(entitiesFileName, method, true);
+        m_getCharInfoCache.put(entitiesFileName, charInfo);
+        return charInfo;
     }
 
     /**
-     * Factory that reads in a resource file that describes the mapping of
-     * characters to entity references.
+     * Constructs a CharInfo object using the following process to try reading
+     * the entitiesFileName parameter:
      *
-     * Resource files must be encoded in UTF-8 and have a format like:
+     *   1) attempt to load it as a ResourceBundle
+     *   2) try using the class loader to find the specified file
+     *   3) try opening it as an URI
+     *
+     * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
+     * following format:
      * <pre>
      * # First char # is a comment
      * Entity numericValue
      * quot 34
      * amp 38
      * </pre>
-     * (Note: Why don't we just switch to .properties files? Oct-01 -sc)
      *
-     * @param entitiesResource Name of entities resource file that should
-     * be loaded, which describes that mapping of characters to entity references.
-     * @param method the output method type, which should be one of "xml", "html", "text"...
-     *
-     * @xsl.usage internal
+     * @param entitiesFileName Name of entities resource file that should
+     * be loaded, which describes the mapping of characters to entity references.
+     * @param method the output method type, which should be one of "xml", "html", and "text".
+     * @return an instance of CharInfo
      */
     static CharInfo getCharInfo(String entitiesFileName, String method)
     {
-        CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
-        if (charInfo != null) {
-            return charInfo;
-        }
-
-        // try to load it internally - cache
         try {
-            charInfo = getCharInfoBasedOnPrivilege(entitiesFileName,
-                                        method, true);
-            m_getCharInfoCache.put(entitiesFileName, charInfo);
-            return charInfo;
-        } catch (Exception e) {}
-
-        // try to load it externally - do not cache
-        try {
-            return getCharInfoBasedOnPrivilege(entitiesFileName,
-                                method, false);
+            return new CharInfo(entitiesFileName, method, false);
         } catch (Exception e) {}
 
         String absoluteEntitiesFileName;
@@ -530,8 +530,7 @@
             }
         }
 
-        return getCharInfoBasedOnPrivilege(entitiesFileName,
-                                method, false);
+        return new CharInfo(absoluteEntitiesFileName, method, false);
     }
 
     /** Table of user-specified char infos. */
--- a/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java	Thu Apr 17 17:52:19 2014 +0100
@@ -60,7 +60,7 @@
      */
     private static final CharInfo m_htmlcharInfo =
 //        new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
-        CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
+        CharInfo.getCharInfoInternal(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
 
     /** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
     static final Trie m_elementFlags = new Trie();
--- a/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java	Wed Apr 02 20:04:06 2014 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java	Thu Apr 17 17:52:19 2014 +0100
@@ -58,7 +58,7 @@
      */
     private static CharInfo m_xmlcharInfo =
 //      new CharInfo(CharInfo.XML_ENTITIES_RESOURCE);
-        CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
+        CharInfo.getCharInfoInternal(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
 
     /**
      * Default constructor.