/hg/release/icedtea7-forest-2.3/jaxp: 3 new changesets

omajid at icedtea.classpath.org omajid at icedtea.classpath.org
Tue Jan 14 13:06:23 PST 2014


changeset 13618d6637f6 in /hg/release/icedtea7-forest-2.3/jaxp
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.3/jaxp?cmd=changeset;node=13618d6637f6
author: joehw
date: Mon Aug 26 20:39:36 2013 -0700

	8022935: Enhance Apache resolver classes
	Reviewed-by: alanb, mchung, skoivu


changeset 29ea19c7c204 in /hg/release/icedtea7-forest-2.3/jaxp
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.3/jaxp?cmd=changeset;node=29ea19c7c204
author: joehw
date: Tue Oct 22 12:59:33 2013 -0700

	8025018: Enhance JAX-P set up
	Reviewed-by: alanb, dfuchs, lancea, ahgross


changeset 8bbd7289b29d in /hg/release/icedtea7-forest-2.3/jaxp
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.3/jaxp?cmd=changeset;node=8bbd7289b29d
author: joehw
date: Thu Nov 14 09:47:24 2013 -0800

	8027201: Enhance JAX-P set up
	Reviewed-by: alanb, dfuchs, lancea, hawtin


diffstat:

 src/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java                |  44 ++---
 src/com/sun/org/apache/xalan/internal/lib/Extensions.java                  |  68 ++-------
 src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java           |  13 +-
 src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java |  21 +-
 src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java |  27 +--
 5 files changed, 65 insertions(+), 108 deletions(-)

diffs (351 lines):

diff -r 190a4ffa6a95 -r 8bbd7289b29d src/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java
--- a/src/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java	Mon Oct 21 16:53:24 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java	Thu Nov 14 09:47:24 2013 -0800
@@ -52,6 +52,8 @@
  */
 public class ExsltStrings extends ExsltBase
 {
+   static final String JDK_DEFAULT_DOM = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
+
   /**
    * The str:align function aligns a string within another string.
    * <p>
@@ -225,7 +227,7 @@
         token = str.substring(fromIndex);
       }
 
-      Document doc = DocumentHolder.m_doc;
+      Document doc = getDocument();
       synchronized (doc)
       {
         Element element = doc.createElement("token");
@@ -289,7 +291,7 @@
     {
       StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
 
-      Document doc = DocumentHolder.m_doc;
+      Document doc = getDocument();
       synchronized (doc)
       {
         while (lTokenizer.hasMoreTokens())
@@ -305,7 +307,7 @@
     else
     {
 
-      Document doc = DocumentHolder.m_doc;
+      Document doc = getDocument();
       synchronized (doc)
       {
         for (int i = 0; i < toTokenize.length(); i++)
@@ -327,31 +329,23 @@
   {
     return tokenize(toTokenize, " \t\n\r");
   }
+
     /**
-     * This class is not loaded until first referenced (see Java Language
-     * Specification by Gosling/Joy/Steele, section 12.4.1)
-     *
-     * The static members are created when this class is first referenced, as a
-     * lazy initialization not needing checking against null or any
-     * synchronization.
-     *
+   * @return an instance of DOM Document
      */
-    private static class DocumentHolder
-    {
-        // Reuse the Document object to reduce memory usage.
-        private static final Document m_doc;
-        static {
-            try
-            {
-                m_doc =DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+   private static Document getDocument()
+   {
+        try
+        {
+            if (System.getSecurityManager() == null) {
+                return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+            } else {
+                return DocumentBuilderFactory.newInstance(JDK_DEFAULT_DOM, null).newDocumentBuilder().newDocument();
             }
-
-            catch(ParserConfigurationException pce)
-            {
-                  throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
-            }
-
+        }
+        catch(ParserConfigurationException pce)
+        {
+            throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
         }
     }
-
 }
diff -r 190a4ffa6a95 -r 8bbd7289b29d src/com/sun/org/apache/xalan/internal/lib/Extensions.java
--- a/src/com/sun/org/apache/xalan/internal/lib/Extensions.java	Mon Oct 21 16:53:24 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/lib/Extensions.java	Thu Nov 14 09:47:24 2013 -0800
@@ -56,6 +56,7 @@
  */
 public class Extensions
 {
+    static final String JDK_DEFAULT_DOM = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
   /**
    * Constructor Extensions
    *
@@ -114,23 +115,14 @@
 
       // This no longer will work right since the DTM.
       // Document myDoc = myProcessor.getContextNode().getOwnerDocument();
-      try
-      {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        DocumentBuilder db = dbf.newDocumentBuilder();
-        Document myDoc = db.newDocument();
+      Document myDoc = getDocument();
 
-        Text textNode = myDoc.createTextNode(textNodeValue);
-        DocumentFragment docFrag = myDoc.createDocumentFragment();
+      Text textNode = myDoc.createTextNode(textNodeValue);
+      DocumentFragment docFrag = myDoc.createDocumentFragment();
 
-        docFrag.appendChild(textNode);
+      docFrag.appendChild(textNode);
 
-        return new NodeSet(docFrag);
-      }
-      catch(ParserConfigurationException pce)
-      {
-        throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
-      }
+      return new NodeSet(docFrag);
     }
   }
 
@@ -249,8 +241,7 @@
   public static NodeList tokenize(String toTokenize, String delims)
   {
 
-    Document doc = DocumentHolder.m_doc;
-
+    Document doc = getDocument();
 
     StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
     NodeSet resultSet = new NodeSet();
@@ -308,17 +299,7 @@
   public static Node checkEnvironment(ExpressionContext myContext)
   {
 
-    Document factoryDocument;
-    try
-    {
-      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-      DocumentBuilder db = dbf.newDocumentBuilder();
-      factoryDocument = db.newDocument();
-    }
-    catch(ParserConfigurationException pce)
-    {
-      throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
-    }
+    Document factoryDocument = getDocument();
 
     Node resultNode = null;
     try
@@ -391,30 +372,21 @@
   }
 
     /**
-     * This class is not loaded until first referenced (see Java Language
-     * Specification by Gosling/Joy/Steele, section 12.4.1)
-     *
-     * The static members are created when this class is first referenced, as a
-     * lazy initialization not needing checking against null or any
-     * synchronization.
-     *
+   * @return an instance of DOM Document
      */
-    private static class DocumentHolder
-    {
-        // Reuse the Document object to reduce memory usage.
-        private static final Document m_doc;
-        static
+   private static Document getDocument()
+   {
+        try
         {
-            try
-            {
-                m_doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+            if (System.getSecurityManager() == null) {
+                return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+            } else {
+                return DocumentBuilderFactory.newInstance(JDK_DEFAULT_DOM, null).newDocumentBuilder().newDocument();
             }
-
-            catch(ParserConfigurationException pce)
-            {
-                  throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
-            }
-
+        }
+        catch(ParserConfigurationException pce)
+        {
+            throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
         }
     }
 }
diff -r 190a4ffa6a95 -r 8bbd7289b29d src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java
--- a/src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java	Mon Oct 21 16:53:24 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java	Thu Nov 14 09:47:24 2013 -0800
@@ -24,20 +24,17 @@
 package com.sun.org.apache.xml.internal.resolver;
 
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
+import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
 import java.io.InputStream;
-
+import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.MalformedURLException;
-
 import java.util.MissingResourceException;
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 import java.util.StringTokenizer;
 import java.util.Vector;
-
-import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
-import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
-import com.sun.org.apache.xml.internal.resolver.Catalog;
+import sun.reflect.misc.ReflectUtil;
 
 /**
  * CatalogManager provides an interface to the catalog properties.
@@ -687,7 +684,7 @@
           catalog = new Catalog();
         } else {
           try {
-            catalog = (Catalog) Class.forName(catalogClassName).newInstance();
+            catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
           } catch (ClassNotFoundException cnfe) {
             debug.message(1,"Catalog class named '"
                           + catalogClassName
diff -r 190a4ffa6a95 -r 8bbd7289b29d src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java
--- a/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java	Mon Oct 21 16:53:24 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java	Thu Nov 14 09:47:24 2013 -0800
@@ -23,24 +23,21 @@
 
 package com.sun.org.apache.xml.internal.resolver.readers;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xml.internal.resolver.Catalog;
+import com.sun.org.apache.xml.internal.resolver.CatalogException;
+import com.sun.org.apache.xml.internal.resolver.helpers.Namespaces;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.net.MalformedURLException;
-
+import java.util.Hashtable;
+import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.ParserConfigurationException;
-
-import com.sun.org.apache.xml.internal.resolver.Catalog;
-import com.sun.org.apache.xml.internal.resolver.CatalogException;
-import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
-import com.sun.org.apache.xml.internal.resolver.helpers.Namespaces;
-
+import org.w3c.dom.*;
 import org.xml.sax.SAXException;
-import org.w3c.dom.*;
+import sun.reflect.misc.ReflectUtil;
 
 /**
  * A DOM-based CatalogReader.
@@ -199,7 +196,7 @@
     DOMCatalogParser domParser = null;
 
     try {
-      domParser = (DOMCatalogParser) Class.forName(domParserClass).newInstance();
+      domParser = (DOMCatalogParser) ReflectUtil.forName(domParserClass).newInstance();
     } catch (ClassNotFoundException cnfe) {
       catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
       throw new CatalogException(CatalogException.UNPARSEABLE);
diff -r 190a4ffa6a95 -r 8bbd7289b29d src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java
--- a/src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Mon Oct 21 16:53:24 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Thu Nov 14 09:47:24 2013 -0800
@@ -23,19 +23,21 @@
 
 package com.sun.org.apache.xml.internal.resolver.readers;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xml.internal.resolver.Catalog;
+import com.sun.org.apache.xml.internal.resolver.CatalogException;
+import com.sun.org.apache.xml.internal.resolver.CatalogManager;
+import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
+import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.net.MalformedURLException;
 import java.net.UnknownHostException;
-
+import java.util.Hashtable;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
-
 import org.xml.sax.AttributeList;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -45,12 +47,7 @@
 import org.xml.sax.Locator;
 import org.xml.sax.Parser;
 import org.xml.sax.SAXException;
-
-import com.sun.org.apache.xml.internal.resolver.Catalog;
-import com.sun.org.apache.xml.internal.resolver.CatalogManager;
-import com.sun.org.apache.xml.internal.resolver.CatalogException;
-import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
-import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
+import sun.reflect.misc.ReflectUtil;
 
 /**
  * A SAX-based CatalogReader.
@@ -246,7 +243,7 @@
         }
         parser.parse(new InputSource(is), spHandler);
       } else {
-        Parser parser = (Parser) Class.forName(parserClass).newInstance();
+        Parser parser = (Parser) ReflectUtil.forName(parserClass).newInstance();
         parser.setDocumentHandler(this);
         if (bResolver != null) {
           parser.setEntityResolver(bResolver);
@@ -352,7 +349,7 @@
 
       try {
         saxParser = (SAXCatalogParser)
-          Class.forName(saxParserClass).newInstance();
+          ReflectUtil.forName(saxParserClass).newInstance();
 
         saxParser.setCatalog(catalog);
         saxParser.startDocument();
@@ -413,7 +410,7 @@
 
       try {
         saxParser = (SAXCatalogParser)
-          Class.forName(saxParserClass).newInstance();
+          ReflectUtil.forName(saxParserClass).newInstance();
 
         saxParser.setCatalog(catalog);
         saxParser.startDocument();


More information about the distro-pkg-dev mailing list