Mercurial > hg > openjdk > jdk8 > jaxp
changeset 453:f8f257062d53
Merge
author | chegar |
---|---|
date | Mon, 10 Jun 2013 09:51:09 +0100 |
parents | 231034c73ed5 (current diff) c2957e596bee (diff) |
children | ec38586b8bf3 |
files | src/com/sun/org/apache/xalan/META-INF/services/javax.xml.transform.TransformerFactory src/com/sun/org/apache/xalan/META-INF/services/javax.xml.xpath.XPathFactory src/com/sun/org/apache/xalan/META-INF/services/org.apache.xml.dtm.DTMManager src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java |
diffstat | 34 files changed, 237 insertions(+), 2121 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/sun/org/apache/xalan/META-INF/services/javax.xml.transform.TransformerFactory Fri May 31 10:27:50 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
--- a/src/com/sun/org/apache/xalan/META-INF/services/javax.xml.xpath.XPathFactory Fri May 31 10:27:50 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl \ No newline at end of file
--- a/src/com/sun/org/apache/xalan/META-INF/services/org.apache.xml.dtm.DTMManager Fri May 31 10:27:50 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault
--- a/src/com/sun/org/apache/xalan/internal/XalanConstants.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/XalanConstants.java Mon Jun 10 09:51:09 2013 +0100 @@ -80,59 +80,6 @@ /** * FEATURE_SECURE_PROCESSING (FSP) is false by default */ - public static final String EXTERNAL_ACCESS_DEFAULT = getExternalAccessDefault(false); - - /** - * Determine the default value of the external access properties - * - * jaxp 1.5 does not require implementations to restrict by default - * - * For JDK8: - * The default value is 'file' (including jar:file); The keyword "all" grants permission - * to all protocols. When {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is on, - * the default value is an empty string indicating no access is allowed. - * - * For JDK7: - * The default value is 'all' granting permission to all protocols. If by default, - * {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is true, it should - * not change the default value. However, if {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} - * is set explicitly, the values of the properties shall be set to an empty string - * indicating no access is allowed. - * - * @param isSecureProcessing indicating if Secure Processing is set - * @return default value - */ - public static String getExternalAccessDefault(boolean isSecureProcessing) { - String defaultValue = "all"; - if (isJDKandAbove(RESTRICT_BY_DEFAULT_JDK_VERSION)) { - defaultValue = "file"; - if (isSecureProcessing) { - defaultValue = EXTERNAL_ACCESS_DEFAULT_FSP; - } - } - return defaultValue; - } - - /* - * Check the version of the current JDK against that specified in the - * parameter - * - * There is a proposal to change the java version string to: - * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL - * This method would work with both the current format and that proposed - * - * @param compareTo a JDK version to be compared to - * @return true if the current version is the same or above that represented - * by the parameter - */ - public static boolean isJDKandAbove(int compareTo) { - String javaVersion = SecuritySupport.getSystemProperty("java.version"); - String versions[] = javaVersion.split("\\.", 3); - if (Integer.parseInt(versions[0]) >= compareTo || - Integer.parseInt(versions[1]) >= compareTo) { - return true; - } - return false; - } + public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; } // class Constants
--- a/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Mon Jun 10 09:51:09 2013 +0100 @@ -23,26 +23,11 @@ package com.sun.org.apache.xalan.internal.utils; -import java.io.InputStream; -import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; -import java.io.InputStreamReader; - /** * This class is duplicated for each JAXP subpackage so keep it in sync. * It is package private and therefore is not exposed as part of the JAXP * API. * <p> - * This code is designed to implement the JAXP 1.1 spec pluggability - * feature and is designed to run on JDK version 1.1 and - * later, and to compile on JDK 1.2 and onward. - * The code also runs both as part of an unbundled jar file and - * when bundled as part of the JDK. - * <p> * This class was moved from the <code>javax.xml.parsers.ObjectFactory</code> * class and modified to be used as a general utility for creating objects * dynamically. @@ -57,329 +42,9 @@ private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal"; private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal"; - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = - "xalan.properties"; - - private static final String SERVICES_PATH = "META-INF/services/"; - /** Set to true for debugging */ private static final boolean DEBUG = false; - /** cache the contents of the xalan.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXalanProperties = null; - - /*** - * Cache the time stamp of the xalan.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // Public static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return instance of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - public static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return instance of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xalan.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - Class factoryClass = lookUpFactoryClass(factoryId, - propertiesFilename, - fallbackClassName); - - if (factoryClass == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - try{ - Object instance = factoryClass.newInstance(); - if (DEBUG) debugPrintln("created new instance of factory " + factoryId); - return instance; - } catch (Exception x) { - throw new ConfigurationError( - "Provider for factory " + factoryId - + " could not be instantiated: " + x, x); - } - } // createObject(String,String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xalan.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - public static Class lookUpFactoryClass(String factoryId) - throws ConfigurationError - { - return lookUpFactoryClass(factoryId, null, null); - } // lookUpFactoryClass(String):Class - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object that provides factory service, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xalan.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - public static Class lookUpFactoryClass(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - String factoryClassName = lookUpFactoryClassName(factoryId, - propertiesFilename, - fallbackClassName); - ClassLoader cl = findClassLoader(); - - if (factoryClassName == null) { - factoryClassName = fallbackClassName; - } - - // assert(className != null); - try{ - Class providerClass = findProviderClass(factoryClassName, - cl, - true); - if (DEBUG) debugPrintln("created new instance of " + providerClass + - " using ClassLoader: " + cl); - return providerClass; - } catch (ClassNotFoundException x) { - throw new ConfigurationError( - "Provider " + factoryClassName + " not found", x); - } catch (Exception x) { - throw new ConfigurationError( - "Provider "+factoryClassName+" could not be instantiated: "+x, - x); - } - } // lookUpFactoryClass(String,String,String):Class - - /** - * Finds the name of the required implementation class in the specified - * order. The specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return name of class that provides factory service, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xalan.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static String lookUpFactoryClassName(String factoryId, - String propertiesFilename, - String fallbackClassName) - { - // Use the system property first - try { - String systemProp = SecuritySupport.getSystemProperty(factoryId); - if (systemProp != null) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return systemProp; - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // Try to read from propertiesFilename, or - // $java.home/lib/xalan.properties - String factoryClassName = null; - // no properties file name specified; use - // $JAVA_HOME/lib/xalan.properties: - if (propertiesFilename == null) { - File propertiesFile = null; - boolean propertiesFileExists = false; - try { - String javah = SecuritySupport.getSystemProperty("java.home"); - propertiesFilename = javah + File.separator + - "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME; - propertiesFile = new File(propertiesFilename); - propertiesFileExists = SecuritySupport.getFileExists(propertiesFile); - } catch (SecurityException e) { - // try again... - fLastModified = -1; - fXalanProperties = null; - } - - synchronized (ObjectFactory.class) { - boolean loadProperties = false; - FileInputStream fis = null; - try { - // file existed last time - if(fLastModified >= 0) { - if(propertiesFileExists && - (fLastModified < (fLastModified = SecuritySupport.getLastModified(propertiesFile)))) { - loadProperties = true; - } else { - // file has stopped existing... - if(!propertiesFileExists) { - fLastModified = -1; - fXalanProperties = null; - } // else, file wasn't modified! - } - } else { - // file has started to exist: - if(propertiesFileExists) { - loadProperties = true; - fLastModified = SecuritySupport.getLastModified(propertiesFile); - } // else, nothing's changed - } - if(loadProperties) { - // must never have attempted to read xalan.properties - // before (or it's outdeated) - fXalanProperties = new Properties(); - fis = SecuritySupport.getFileInputStream(propertiesFile); - fXalanProperties.load(fis); - } - } catch (Exception x) { - fXalanProperties = null; - fLastModified = -1; - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if(fXalanProperties != null) { - factoryClassName = fXalanProperties.getProperty(factoryId); - } - } else { - FileInputStream fis = null; - try { - fis = SecuritySupport.getFileInputStream(new File(propertiesFilename)); - Properties props = new Properties(); - props.load(fis); - factoryClassName = props.getProperty(factoryId); - } catch (Exception x) { - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if (factoryClassName != null) { - if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value=" - + factoryClassName); - return factoryClassName; - } - - // Try Jar Service Provider Mechanism - return findJarServiceProviderName(factoryId); - } // lookUpFactoryClass(String,String):String - - // - // Private static methods - // /** Prints a message to standard error if debugging is enabled. */ private static void debugPrintln(String msg) { @@ -393,7 +58,6 @@ * the context ClassLoader. */ public static ClassLoader findClassLoader() - throws ConfigurationError { if (System.getSecurityManager()!=null) { //this will ensure bootclassloader is used @@ -452,8 +116,8 @@ } // findClassLoader():ClassLoader /** - * Create an instance of a class using the same classloader for the ObjectFactory by default - * or bootclassloader when Security Manager is in place + * Create an instance of a class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place */ public static Object newInstance(String className, boolean doFallback) throws ConfigurationError @@ -491,10 +155,10 @@ } /** - * Find a Class using the same classloader for the ObjectFactory by default - * or bootclassloader when Security Manager is in place + * Find a Class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place */ - public static Class findProviderClass(String className, boolean doFallback) + public static Class<?> findProviderClass(String className, boolean doFallback) throws ClassNotFoundException, ConfigurationError { if (System.getSecurityManager()!=null) { @@ -508,7 +172,7 @@ /** * Find a Class using the specified ClassLoader */ - static Class findProviderClass(String className, ClassLoader cl, + private static Class<?> findProviderClass(String className, ClassLoader cl, boolean doFallback) throws ClassNotFoundException, ConfigurationError { @@ -531,7 +195,7 @@ throw e; } - Class providerClass; + Class<?> providerClass; if (cl == null) { // XXX Use the bootstrap ClassLoader. There is no way to // load a class using the bootstrap ClassLoader that works @@ -567,93 +231,4 @@ return providerClass; } - /** - * Find the name of service provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static String findJarServiceProviderName(String factoryId) - { - String serviceId = SERVICES_PATH + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = SecuritySupport.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = SecuritySupport.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is)); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return factoryClassName; - } - - // No provider found - return null; - } - } // class ObjectFactory
--- a/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java Mon Jun 10 09:51:09 2013 +0100 @@ -23,34 +23,30 @@ package com.sun.org.apache.xalan.internal.xsltc.cmdline; -import java.io.FileNotFoundException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; -import java.util.Vector; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.sax.SAXSource; - +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM; +import com.sun.org.apache.xalan.internal.xsltc.StripFilter; import com.sun.org.apache.xalan.internal.xsltc.TransletException; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; -import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM; +import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter; import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager; import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet; import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants; import com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter; import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory; +import com.sun.org.apache.xml.internal.dtm.DTMWSFilter; import com.sun.org.apache.xml.internal.serializer.SerializationHandler; - +import java.io.FileNotFoundException; +import java.net.MalformedURLException; +import java.net.UnknownHostException; +import java.util.Vector; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; -import com.sun.org.apache.xalan.internal.xsltc.StripFilter; -import com.sun.org.apache.xml.internal.dtm.DTMWSFilter; -import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter; -import com.sun.org.apache.xalan.internal.utils.ObjectFactory; - /** * @author Jacek Ambroziak * @author Santiago Pericas-Geertsen @@ -115,8 +111,7 @@ // Set the DOM's DOM builder as the XMLReader's SAX2 content handler XSLTCDTMManager dtmManager = - (XSLTCDTMManager)XSLTCDTMManager.getDTMManagerClass() - .newInstance(); + XSLTCDTMManager.createNewDTMManagerInstance(); DTMWSFilter wsfilter; if (translet != null && translet instanceof StripFilter) {
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Mon Jun 10 09:51:09 2013 +0100 @@ -449,7 +449,7 @@ * Note to translators: access to the stylesheet target is denied */ {ErrorMsg.ACCESSING_XSLT_TARGET_ERR, - "Could not read stylesheet target ''{0}'', because ''{1}'' access is not allowed."}, + "Could not read stylesheet target ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalStylesheet property."}, /* * Note to translators: This message represents an internal error in
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java Mon Jun 10 09:51:09 2013 +0100 @@ -156,8 +156,7 @@ public DocumentCache(int size) throws SAXException { this(size, null); try { - _dtmManager = (XSLTCDTMManager)XSLTCDTMManager.getDTMManagerClass() - .newInstance(); + _dtmManager = XSLTCDTMManager.createNewDTMManagerInstance(); } catch (Exception e) { throw new SAXException(e); } @@ -255,6 +254,7 @@ * Returns a document either by finding it in the cache or * downloading it and putting it in the cache. */ + @Override public DOM retrieveDocument(String baseURI, String href, Translet trs) { CachedDocument doc;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/XSLTCDTMManager.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/XSLTCDTMManager.java Mon Jun 10 09:51:09 2013 +0100 @@ -30,7 +30,6 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stax.StAXSource; - import com.sun.org.apache.xml.internal.dtm.DTM; import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase; import com.sun.org.apache.xml.internal.dtm.DTMException; @@ -42,7 +41,6 @@ import com.sun.org.apache.xalan.internal.xsltc.trax.DOM2SAX; import com.sun.org.apache.xalan.internal.xsltc.trax.StAXEvent2SAX; import com.sun.org.apache.xalan.internal.xsltc.trax.StAXStream2SAX; -import com.sun.org.apache.xalan.internal.utils.ObjectFactory; import org.xml.sax.InputSource; import org.xml.sax.SAXNotRecognizedException; @@ -55,13 +53,6 @@ public class XSLTCDTMManager extends DTMManagerDefault { - /** The default class name to use as the manager. */ - private static final String DEFAULT_CLASS_NAME = - "com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager"; - - private static final String DEFAULT_PROP_NAME = - "com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager"; - /** Set this to true if you want a dump of the DTM after creation */ private static final boolean DUMPTREE = false; @@ -88,42 +79,13 @@ } /** - * Look up the class that provides the XSLTC DTM Manager service. - * The following lookup procedure is used to find the service provider. - * <ol> - * <li>The value of the - * <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code> property, is - * checked.</li> - * <li>The <code>xalan.propeties</code> file is checked for a property - * of the same name.</li> - * <li>The - * <code>META-INF/services/com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code> - * file is checked. - * </ol> - * The default is <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code>. + * Creates a new instance of the XSLTC DTM Manager service. + * Creates a new instance of the default class + * <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code>. */ - public static Class getDTMManagerClass() { - return getDTMManagerClass(true); - } - - public static Class getDTMManagerClass(boolean useServicesMechanism) { - Class mgrClass = null; - if (useServicesMechanism) { - mgrClass = ObjectFactory.lookUpFactoryClass(DEFAULT_PROP_NAME, - null, - DEFAULT_CLASS_NAME); - } else { - try { - mgrClass = ObjectFactory.findProviderClass(DEFAULT_CLASS_NAME, true); - } catch (Exception e) { - //will not happen - } - } - // If no class found, default to this one. (This should never happen - - // the ObjectFactory has already been told that the current class is - // the default). - return (mgrClass != null) ? mgrClass : XSLTCDTMManager.class; - } + public static XSLTCDTMManager createNewDTMManagerInstance() { + return newInstance(); + } /** * Get an instance of a DTM, loaded with the content from the @@ -146,6 +108,7 @@ * * @return a non-null DTM reference. */ + @Override public DTM getDTM(Source source, boolean unique, DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing)
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Mon Jun 10 09:51:09 2013 +0100 @@ -23,6 +23,17 @@ package com.sun.org.apache.xalan.internal.xsltc.trax; +import com.sun.org.apache.xalan.internal.XalanConstants; +import com.sun.org.apache.xalan.internal.utils.FactoryImpl; +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.utils.SecuritySupport; +import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; +import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; +import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager; +import com.sun.org.apache.xml.internal.utils.StopParseException; +import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -37,11 +48,9 @@ import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; - import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.ErrorListener; import javax.xml.transform.Source; @@ -58,23 +67,9 @@ import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TemplatesHandler; import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stax.*; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.stax.*; - -import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler; -import com.sun.org.apache.xml.internal.utils.StopParseException; - -import com.sun.org.apache.xalan.internal.XalanConstants; -import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; -import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; -import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; -import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; -import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager; -import com.sun.org.apache.xalan.internal.utils.ObjectFactory; -import com.sun.org.apache.xalan.internal.utils.FactoryImpl; -import com.sun.org.apache.xalan.internal.utils.SecuritySupport; - import org.xml.sax.InputSource; import org.xml.sax.XMLFilter; import org.xml.sax.XMLReader; @@ -201,14 +196,6 @@ private int _indentNumber = -1; /** - * The provider of the XSLTC DTM Manager service. This is fixed for any - * instance of this class. In order to change service providers, a new - * XSLTC <code>TransformerFactory</code> must be instantiated. - * @see XSLTCDTMManager#getDTMManagerClass() - */ - private Class m_DTMManagerClass; - - /** * <p>State of secure processing feature.</p> */ private boolean _isNotSecureProcessing = true; @@ -246,14 +233,12 @@ } private TransformerFactoryImpl(boolean useServicesMechanism) { - this.m_DTMManagerClass = XSLTCDTMManager.getDTMManagerClass(useServicesMechanism); this._useServicesMechanism = useServicesMechanism; String defaultAccess = XalanConstants.EXTERNAL_ACCESS_DEFAULT; if (System.getSecurityManager() != null) { _isSecureMode = true; _isNotSecureProcessing = false; - defaultAccess = XalanConstants.getExternalAccessDefault(true); } _accessExternalStylesheet = SecuritySupport.getDefaultAccessProperty( XalanConstants.SP_ACCESS_EXTERNAL_STYLESHEET, defaultAccess); @@ -270,6 +255,7 @@ * @param listener The error listener to use with the TransformerFactory * @throws IllegalArgumentException */ + @Override public void setErrorListener(ErrorListener listener) throws IllegalArgumentException { @@ -287,6 +273,7 @@ * * @return The error listener used with the TransformerFactory */ + @Override public ErrorListener getErrorListener() { return _errorListener; } @@ -299,6 +286,7 @@ * @return An object representing the attribute value * @throws IllegalArgumentException */ + @Override public Object getAttribute(String name) throws IllegalArgumentException { @@ -338,6 +326,7 @@ * @param value An object representing the attribute value * @throws IllegalArgumentException */ + @Override public void setAttribute(String name, Object value) throws IllegalArgumentException { @@ -460,6 +449,7 @@ * or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature. * @throws NullPointerException If the <code>name</code> parameter is null. */ + @Override public void setFeature(String name, boolean value) throws TransformerConfigurationException { @@ -504,6 +494,7 @@ * @param name The feature name * @return 'true' if feature is supported, 'false' if not */ + @Override public boolean getFeature(String name) { // All supported features should be listed here String[] features = { @@ -555,6 +546,7 @@ * @return The URLResolver used for this TransformerFactory and all * Templates and Transformer objects created using this factory */ + @Override public URIResolver getURIResolver() { return _uriResolver; } @@ -569,6 +561,7 @@ * @param resolver The URLResolver used for this TransformerFactory and all * Templates and Transformer objects created using this factory */ + @Override public void setURIResolver(URIResolver resolver) { _uriResolver = resolver; } @@ -588,13 +581,14 @@ * @return A Source object suitable for passing to the TransformerFactory. * @throws TransformerConfigurationException */ + @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { String baseId; - XMLReader reader = null; - InputSource isource = null; + XMLReader reader; + InputSource isource; /** @@ -676,6 +670,7 @@ * @return A Transformer object that simply copies the source to the result. * @throws TransformerConfigurationException */ + @Override public Transformer newTransformer() throws TransformerConfigurationException { @@ -701,6 +696,7 @@ * @return A Templates object that can be used to create Transformers. * @throws TransformerConfigurationException */ + @Override public Transformer newTransformer(Source source) throws TransformerConfigurationException { @@ -764,6 +760,7 @@ * @return A Templates object that can be used to create Transformers. * @throws TransformerConfigurationException */ + @Override public Templates newTemplates(Source source) throws TransformerConfigurationException { @@ -797,7 +794,7 @@ // If _autoTranslet is true, we will try to load the bytecodes // from the translet classes without compiling the stylesheet. if (_autoTranslet) { - byte[][] bytecodes = null; + byte[][] bytecodes; String transletClassName = getTransletBaseName(source); if (_packageName != null) @@ -919,7 +916,7 @@ // Check that the transformation went well before returning if (bytecodes == null) { Vector errs = xsltc.getErrors(); - ErrorMsg err = null; + ErrorMsg err; if (errs != null) { err = (ErrorMsg)errs.elementAt(errs.size()-1); } else { @@ -964,6 +961,7 @@ * @return A TemplatesHandler object that can handle SAX events * @throws TransformerConfigurationException */ + @Override public TemplatesHandler newTemplatesHandler() throws TransformerConfigurationException { @@ -983,6 +981,7 @@ * @return A TransformerHandler object that can handle SAX events * @throws TransformerConfigurationException */ + @Override public TransformerHandler newTransformerHandler() throws TransformerConfigurationException { @@ -1003,6 +1002,7 @@ * @return A TransformerHandler object that can handle SAX events * @throws TransformerConfigurationException */ + @Override public TransformerHandler newTransformerHandler(Source src) throws TransformerConfigurationException { @@ -1023,6 +1023,7 @@ * @return A TransformerHandler object that can handle SAX events * @throws TransformerConfigurationException */ + @Override public TransformerHandler newTransformerHandler(Templates templates) throws TransformerConfigurationException { @@ -1040,6 +1041,7 @@ * @return An XMLFilter object, or null if this feature is not supported. * @throws TransformerConfigurationException */ + @Override public XMLFilter newXMLFilter(Source src) throws TransformerConfigurationException { @@ -1057,6 +1059,7 @@ * @return An XMLFilter object, or null if this feature is not supported. * @throws TransformerConfigurationException */ + @Override public XMLFilter newXMLFilter(Templates templates) throws TransformerConfigurationException { @@ -1088,6 +1091,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ + @Override public void error(TransformerException e) throws TransformerException { @@ -1116,6 +1120,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ + @Override public void fatalError(TransformerException e) throws TransformerException { @@ -1144,6 +1149,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (never does in our case). */ + @Override public void warning(TransformerException e) throws TransformerException { @@ -1167,6 +1173,7 @@ * @param xsltc The compiler that resuests the document * @return An InputSource with the loaded document */ + @Override public InputSource loadSource(String href, String context, XSLTC xsltc) { try { if (_uriResolver != null) { @@ -1253,7 +1260,7 @@ Vector bytecodes = new Vector(); int fileLength = (int)transletFile.length(); if (fileLength > 0) { - FileInputStream input = null; + FileInputStream input; try { input = new FileInputStream(transletFile); } @@ -1285,6 +1292,7 @@ // Find all the auxiliary files which have a name pattern of "transletClass$nnn.class". final String transletAuxPrefix = transletName + "$"; File[] auxfiles = transletParentFile.listFiles(new FilenameFilter() { + @Override public boolean accept(File dir, String name) { return (name.endsWith(".class") && name.startsWith(transletAuxPrefix)); @@ -1348,7 +1356,7 @@ xslFile = new File(xslFileName); // Construct the path for the jar file - String jarPath = null; + String jarPath; if (_destinationDirectory != null) jarPath = _destinationDirectory + "/" + _jarFileName; else { @@ -1373,7 +1381,7 @@ } // Create a ZipFile object for the jar file - ZipFile jarFile = null; + ZipFile jarFile; try { jarFile = new ZipFile(file); } @@ -1491,7 +1499,7 @@ if (file.exists()) return systemId; else { - URL url = null; + URL url; try { url = new URL(systemId); } @@ -1510,9 +1518,9 @@ } /** - * Returns the Class object the provides the XSLTC DTM Manager service. + * Returns a new instance of the XSLTC DTM Manager service. */ - protected Class getDTMManagerClass() { - return m_DTMManagerClass; + protected final XSLTCDTMManager createNewDTMManagerInstance() { + return XSLTCDTMManager.createNewDTMManagerInstance(); } }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerHandlerImpl.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerHandlerImpl.java Mon Jun 10 09:51:09 2013 +0100 @@ -96,6 +96,7 @@ * resolved. * @return The systemID that was set with setSystemId(String id) */ + @Override public String getSystemId() { return _systemId; } @@ -106,6 +107,7 @@ * resolved. * @param id Base URI for this stylesheet */ + @Override public void setSystemId(String id) { _systemId = id; } @@ -116,6 +118,7 @@ * order to set parameters and output properties. * @return The Transformer object */ + @Override public Transformer getTransformer() { return _transformer; } @@ -127,6 +130,7 @@ * @param result A Result instance, should not be null * @throws IllegalArgumentException if result is invalid for some reason */ + @Override public void setResult(Result result) throws IllegalArgumentException { _result = result; @@ -166,6 +170,7 @@ * Implements org.xml.sax.ContentHandler.characters() * Receive notification of character data. */ + @Override public void characters(char[] ch, int start, int length) throws SAXException { @@ -176,6 +181,7 @@ * Implements org.xml.sax.ContentHandler.startDocument() * Receive notification of the beginning of a document. */ + @Override public void startDocument() throws SAXException { // Make sure setResult() was called before the first SAX event if (_result == null) { @@ -189,10 +195,8 @@ // Create an internal DOM (not W3C) and get SAX2 input handler try { - dtmManager = - (XSLTCDTMManager)_transformer.getTransformerFactory() - .getDTMManagerClass() - .newInstance(); + dtmManager = _transformer.getTransformerFactory() + .createNewDTMManagerInstance(); } catch (Exception e) { throw new SAXException(e); } @@ -230,6 +234,7 @@ * Implements org.xml.sax.ContentHandler.endDocument() * Receive notification of the end of a document. */ + @Override public void endDocument() throws SAXException { // Signal to the DOMBuilder that the document is complete _handler.endDocument(); @@ -260,6 +265,7 @@ * Implements org.xml.sax.ContentHandler.startElement() * Receive notification of the beginning of an element. */ + @Override public void startElement(String uri, String localName, String qname, Attributes attributes) throws SAXException @@ -271,6 +277,7 @@ * Implements org.xml.sax.ContentHandler.endElement() * Receive notification of the end of an element. */ + @Override public void endElement(String namespaceURI, String localName, String qname) throws SAXException { @@ -281,6 +288,7 @@ * Implements org.xml.sax.ContentHandler.processingInstruction() * Receive notification of a processing instruction. */ + @Override public void processingInstruction(String target, String data) throws SAXException { @@ -290,6 +298,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.startCDATA() */ + @Override public void startCDATA() throws SAXException { if (_lexHandler != null) { _lexHandler.startCDATA(); @@ -299,6 +308,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.endCDATA() */ + @Override public void endCDATA() throws SAXException { if (_lexHandler != null) { _lexHandler.endCDATA(); @@ -309,6 +319,7 @@ * Implements org.xml.sax.ext.LexicalHandler.comment() * Receieve notification of a comment */ + @Override public void comment(char[] ch, int start, int length) throws SAXException { @@ -322,6 +333,7 @@ * Receive notification of ignorable whitespace in element * content. Similar to characters(char[], int, int). */ + @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { @@ -332,6 +344,7 @@ * Implements org.xml.sax.ContentHandler.setDocumentLocator() * Receive an object for locating the origin of SAX document events. */ + @Override public void setDocumentLocator(Locator locator) { _locator = locator; @@ -344,6 +357,7 @@ * Implements org.xml.sax.ContentHandler.skippedEntity() * Receive notification of a skipped entity. */ + @Override public void skippedEntity(String name) throws SAXException { _handler.skippedEntity(name); } @@ -352,6 +366,7 @@ * Implements org.xml.sax.ContentHandler.startPrefixMapping() * Begin the scope of a prefix-URI Namespace mapping. */ + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { _handler.startPrefixMapping(prefix, uri); @@ -361,6 +376,7 @@ * Implements org.xml.sax.ContentHandler.endPrefixMapping() * End the scope of a prefix-URI Namespace mapping. */ + @Override public void endPrefixMapping(String prefix) throws SAXException { _handler.endPrefixMapping(prefix); } @@ -368,6 +384,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.startDTD() */ + @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { @@ -379,6 +396,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.endDTD() */ + @Override public void endDTD() throws SAXException { if (_lexHandler != null) { _lexHandler.endDTD(); @@ -388,6 +406,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.startEntity() */ + @Override public void startEntity(String name) throws SAXException { if (_lexHandler != null) { _lexHandler.startEntity(name); @@ -397,6 +416,7 @@ /** * Implements org.xml.sax.ext.LexicalHandler.endEntity() */ + @Override public void endEntity(String name) throws SAXException { if (_lexHandler != null) { _lexHandler.endEntity(name); @@ -406,6 +426,7 @@ /** * Implements org.xml.sax.DTDHandler.unparsedEntityDecl() */ + @Override public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException { @@ -418,6 +439,7 @@ /** * Implements org.xml.sax.DTDHandler.notationDecl() */ + @Override public void notationDecl(String name, String publicId, String systemId) throws SAXException { @@ -429,6 +451,7 @@ /** * Implements org.xml.sax.ext.DeclHandler.attributeDecl() */ + @Override public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException { @@ -440,6 +463,7 @@ /** * Implements org.xml.sax.ext.DeclHandler.elementDecl() */ + @Override public void elementDecl(String name, String model) throws SAXException { @@ -451,6 +475,7 @@ /** * Implements org.xml.sax.ext.DeclHandler.externalEntityDecl() */ + @Override public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException { @@ -462,6 +487,7 @@ /** * Implements org.xml.sax.ext.DeclHandler.externalEntityDecl() */ + @Override public void internalEntityDecl(String name, String value) throws SAXException {
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Mon Jun 10 09:51:09 2013 +0100 @@ -99,10 +99,6 @@ public final class TransformerImpl extends Transformer implements DOMCache, ErrorListener { - private final static String EMPTY_STRING = ""; - private final static String NO_STRING = "no"; - private final static String YES_STRING = "yes"; - private final static String XML_STRING = "xml"; private final static String LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler"; @@ -156,7 +152,7 @@ private TransletOutputHandlerFactory _tohFactory = null; /** - * A reference to a internal DOM represenation of the input. + * A reference to a internal DOM representation of the input. */ private DOM _dom = null; @@ -238,6 +234,7 @@ _errorListener = errorListener; } + @Override public void displayMessage(String msg) { if(_errorListener == null) { System.err.println(msg); @@ -323,6 +320,7 @@ * @param result Will contain the output from the transformation * @throws TransformerException */ + @Override public void transform(Source source, Result result) throws TransformerException { @@ -465,7 +463,7 @@ // System Id may be in one of several forms, (1) a uri // that starts with 'file:', (2) uri that starts with 'http:' // or (3) just a filename on the local system. - URL url = null; + URL url; if (systemId.startsWith("file:")) { // if StreamResult(File) or setSystemID(File) was used, // the systemId will be URI encoded as a result of File.toURI(), @@ -537,7 +535,7 @@ */ private DOM getDOM(Source source) throws TransformerException { try { - DOM dom = null; + DOM dom; if (source != null) { DTMWSFilter wsfilter; @@ -552,8 +550,7 @@ if (_dtmManager == null) { _dtmManager = - (XSLTCDTMManager)_tfactory.getDTMManagerClass() - .newInstance(); + _tfactory.createNewDTMManagerInstance(); _dtmManager.setServicesMechnism(_useServicesMechanism); } dom = (DOM)_dtmManager.getDTM(source, false, wsfilter, true, @@ -676,8 +673,8 @@ } } else if (source instanceof StAXSource) { final StAXSource staxSource = (StAXSource)source; - StAXEvent2SAX staxevent2sax = null; - StAXStream2SAX staxStream2SAX = null; + StAXEvent2SAX staxevent2sax; + StAXStream2SAX staxStream2SAX; if (staxSource.getXMLEventReader() != null) { final XMLEventReader xmlEventReader = staxSource.getXMLEventReader(); staxevent2sax = new StAXEvent2SAX(xmlEventReader); @@ -770,6 +767,7 @@ * * @return The error event handler currently in effect */ + @Override public ErrorListener getErrorListener() { return _errorListener; } @@ -783,6 +781,7 @@ * @param listener The error event listener to use * @throws IllegalArgumentException */ + @Override public void setErrorListener(ErrorListener listener) throws IllegalArgumentException { if (listener == null) { @@ -830,7 +829,7 @@ // Return a 'null' string if no CDATA section elements were specified if (cdata == null) return null; - StringBuffer result = new StringBuffer(); + final StringBuilder result = new StringBuilder(); // Get an enumeration of all the elements in the hashtable Enumeration elements = cdata.keys(); @@ -857,6 +856,7 @@ * * @return Properties in effect for this Transformer */ + @Override public Properties getOutputProperties() { return (Properties) _properties.clone(); } @@ -870,6 +870,7 @@ * @param name A non-null string that contains the name of the property * @throws IllegalArgumentException if the property name is not known */ + @Override public String getOutputProperty(String name) throws IllegalArgumentException { @@ -889,6 +890,7 @@ * @param properties The properties to use for the Transformer * @throws IllegalArgumentException Never, errors are ignored */ + @Override public void setOutputProperties(Properties properties) throws IllegalArgumentException { @@ -925,6 +927,7 @@ * @param value The value to assign to the property * @throws IllegalArgumentException Never, errors are ignored */ + @Override public void setOutputProperty(String name, String value) throws IllegalArgumentException { @@ -1205,6 +1208,7 @@ * @param name The name of the parameter * @param value The value to assign to the parameter */ + @Override public void setParameter(String name, Object value) { if (value == null) { @@ -1228,6 +1232,7 @@ * Clear all parameters set with setParameter. Clears the translet's * parameter stack. */ + @Override public void clearParameters() { if (_isIdentity && _parameters != null) { _parameters.clear(); @@ -1245,6 +1250,7 @@ * @param name The name of the parameter * @return An object that contains the value assigned to the parameter */ + @Override public final Object getParameter(String name) { if (_isIdentity) { return (_parameters != null) ? _parameters.get(name) : null; @@ -1260,6 +1266,7 @@ * * @return The URLResolver object currently in use */ + @Override public URIResolver getURIResolver() { return _uriResolver; } @@ -1270,6 +1277,7 @@ * * @param resolver The URIResolver to use in document() */ + @Override public void setURIResolver(URIResolver resolver) { _uriResolver = resolver; } @@ -1288,6 +1296,7 @@ * @param href The href argument passed to the document function. * @param translet A reference to the translet requesting the document */ + @Override public DOM retrieveDocument(String baseURI, String href, Translet translet) { try { // Argument to document function was: document(''); @@ -1330,6 +1339,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ + @Override public void error(TransformerException e) throws TransformerException { @@ -1358,6 +1368,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ + @Override public void fatalError(TransformerException e) throws TransformerException { @@ -1386,6 +1397,7 @@ * @throws TransformerException if the application chooses to discontinue * the transformation (never does in our case). */ + @Override public void warning(TransformerException e) throws TransformerException { @@ -1406,6 +1418,7 @@ * created * @since 1.5 */ + @Override public void reset() { _method = null;
--- a/src/com/sun/org/apache/xerces/internal/impl/Constants.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/Constants.java Mon Jun 10 09:51:09 2013 +0100 @@ -202,7 +202,7 @@ /** * FEATURE_SECURE_PROCESSING (FSP) is true by default */ - public static final String EXTERNAL_ACCESS_DEFAULT = getExternalAccessDefault(true); + public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; // // DOM features @@ -697,58 +697,6 @@ ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; } // getXercesProperties():Enumeration - /** - * Determine the default value of the external access properties - * - * jaxp 1.5 does not require implementations to restrict by default - * - * For JDK8: - * The default value is 'file' (including jar:file); The keyword "all" grants permission - * to all protocols. When {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is on, - * the default value is an empty string indicating no access is allowed. - * - * For JDK7: - * The default value is 'all' granting permission to all protocols. If by default, - * {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is true, it should - * not change the default value. However, if {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} - * is set explicitly, the values of the properties shall be set to an empty string - * indicating no access is allowed. - * - * @param isSecureProcessing indicating if Secure Processing is set - * @return default value - */ - public static String getExternalAccessDefault(boolean isSecureProcessing) { - String defaultValue = "all"; - if (isJDKandAbove(RESTRICT_BY_DEFAULT_JDK_VERSION)) { - defaultValue = "file"; - if (isSecureProcessing) { - defaultValue = EXTERNAL_ACCESS_DEFAULT_FSP; - } - } - return defaultValue; - } - - /* - * Check the version of the current JDK against that specified in the - * parameter - * - * There is a proposal to change the java version string to: - * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL - * This method would work with both the current format and that proposed - * - * @param compareTo a JDK version to be compared to - * @return true if the current version is the same or above that represented - * by the parameter - */ - public static boolean isJDKandAbove(int compareTo) { - String javaVersion = SecuritySupport.getSystemProperty("java.version"); - String versions[] = javaVersion.split("\\.", 3); - if (Integer.parseInt(versions[0]) >= compareTo || - Integer.parseInt(versions[1]) >= compareTo) { - return true; - } - return false; - } // // Classes
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Mon Jun 10 09:51:09 2013 +0100 @@ -261,8 +261,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = The external entity reference \"&{0};\" is not permitted in an attribute value. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = The entity \"{0}\" was referenced, but not declared.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = Externe Entit\u00E4tsreferenz \"&{0};\" ist in einem Attributwert nicht zul\u00E4ssig. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = Entit\u00E4t \"{0}\" wurde referenziert aber nicht deklariert.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = La referencia de entidad externa \"&{0};\" no est\u00E1 permitida en un valor de atributo. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = Se hizo referencia a la entidad \"{0}\", pero no se declar\u00F3.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = La r\u00E9f\u00E9rence d''entit\u00E9 externe \"&{0};\" n''est pas autoris\u00E9e dans une valeur d''attribut. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = L''entit\u00E9 \"{0}\" \u00E9tait r\u00E9f\u00E9renc\u00E9e, mais pas d\u00E9clar\u00E9e.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = Il riferimento di entit\u00E0 esterna \"&{0};\" non \u00E8 consentito in un valore di attributo. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = L''entit\u00E0 \"{0}\" \u00E8 indicata da un riferimento, ma non \u00E8 dichiarata.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = \u5916\u90E8\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u53C2\u7167\"&{0};\"\u306F\u3001\u5C5E\u6027\u5024\u3067\u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\"{0}\"\u304C\u53C2\u7167\u3055\u308C\u3066\u3044\u307E\u3059\u304C\u3001\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = \uC18D\uC131\uAC12\uC5D0\uC11C\uB294 \uC678\uBD80 \uC5D4\uD2F0\uD2F0 \uCC38\uC870 \"&{0};\"\uC774 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = \"{0}\" \uC5D4\uD2F0\uD2F0\uAC00 \uCC38\uC870\uB418\uC5C8\uC9C0\uB9CC \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = A refer\u00EAncia da entidade externa \"&{0};\" n\u00E3o \u00E9 permitida em um valor do atributo. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = A entidade \"{0}\" foi referenciada, mas n\u00E3o declarada.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = Den externa enhetsreferensen \"&{0};\" till\u00E5ts inte i ett attributv\u00E4rde. - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = Enheten \"{0}\" har refererats, men \u00E4r inte deklarerad.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = \u5C5E\u6027\u503C\u4E2D\u4E0D\u5141\u8BB8\u91C7\u7528\u5916\u90E8\u5B9E\u4F53\u5F15\u7528 \"&{0};\"\u3002 - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = \u5F15\u7528\u4E86\u5B9E\u4F53 \"{0}\", \u4F46\u672A\u58F0\u660E\u5B83\u3002
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties Mon Jun 10 09:51:09 2013 +0100 @@ -289,8 +289,8 @@ # Entity related messages # 3.1 Start-Tags, End-Tags, and Empty-Element Tags ReferenceToExternalEntity = \u5C6C\u6027\u503C\u4E0D\u5141\u8A31\u53C3\u7167\u5916\u90E8\u500B\u9AD4 \"&{0};\"\u3002 - AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed. - AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed. + AccessExternalDTD = External DTD: Failed to read external DTD ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. + AccessExternalEntity = External Entity: Failed to read external document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalDTD property. # 4.1 Character and Entity References EntityNotDeclared = \u53C3\u7167\u4E86\u500B\u9AD4 \"{0}\"\uFF0C\u4F46\u662F\u672A\u5BA3\u544A\u3002
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties Mon Jun 10 09:51:09 2013 +0100 @@ -86,7 +86,7 @@ #schema valid (3.X.3) - schema_reference.access = schema_reference: Failed to read schema document ''{0}'', because ''{1}'' access is not allowed. + schema_reference.access = schema_reference: Failed to read schema document ''{0}'', because ''{1}'' access is not allowed due to restriction set by the accessExternalSchema property. schema_reference.4 = schema_reference.4: Failed to read schema document ''{0}'', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. src-annotation = src-annotation: <annotation> elements can only contain <appinfo> and <documentation> elements, but ''{0}'' was found. src-attribute.1 = src-attribute.1: The properties ''default'' and ''fixed'' cannot both be present in attribute declaration ''{0}''. Use only one of them.
--- a/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Mon Jun 10 09:51:09 2013 +0100 @@ -236,10 +236,6 @@ String feature = (String) entry.getKey(); boolean value = ((Boolean) entry.getValue()).booleanValue(); domParser.setFeature(feature, value); - if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { - domParser.setProperty(ACCESS_EXTERNAL_DTD, ""); - domParser.setProperty(ACCESS_EXTERNAL_SCHEMA, ""); - } } } }
--- a/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Mon Jun 10 09:51:09 2013 +0100 @@ -242,10 +242,6 @@ String feature = (String) entry.getKey(); boolean value = ((Boolean) entry.getValue()).booleanValue(); xmlReader.setFeature0(feature, value); - if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING) && value) { - xmlReader.setProperty0(ACCESS_EXTERNAL_DTD, ""); - xmlReader.setProperty0(ACCESS_EXTERNAL_SCHEMA, ""); - } } } }
--- a/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Mon Jun 10 09:51:09 2013 +0100 @@ -364,10 +364,15 @@ SAXMessageFormatter.formatMessage(null, "jaxp-secureprocessing-feature", null)); } - fSecurityManager = value ? new SecurityManager() : null; + if (value) { + fSecurityManager = new SecurityManager(); + fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); + fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); + } else { + fSecurityManager = null; + } + fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); - fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); - fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); return; } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) { //in secure mode, let _useServicesMechanism be determined by the constructor
--- a/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Mon Jun 10 09:51:09 2013 +0100 @@ -20,15 +20,6 @@ package com.sun.org.apache.xerces.internal.utils; -import java.io.InputStream; -import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; -import java.io.InputStreamReader; - /** * This class is duplicated for each JAXP subpackage so keep it in sync. * It is package private and therefore is not exposed as part of the JAXP @@ -50,113 +41,9 @@ // private static final String DEFAULT_INTERNAL_CLASSES = "com.sun.org.apache."; - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; - /** Set to true for debugging */ private static final boolean DEBUG = isDebugEnabled(); - /** - * Default columns per line. - */ - private static final int DEFAULT_LINE_LENGTH = 80; - - /** cache the contents of the xerces.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXercesProperties = null; - - /*** - * Cache the time stamp of the xerces.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - public static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xerces.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - public static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - if (DEBUG) debugPrintln("debug is on"); - - ClassLoader cl = findClassLoader(); - - // Use the system property first - try { - String systemProp = SecuritySupport.getSystemProperty(factoryId); - if (systemProp != null && systemProp.length() > 0) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return newInstance(systemProp, cl, true); - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // JAXP specific change - // always use fallback class to avoid the expense of constantly - // "stat"ing a non-existent "xerces.properties" and jar SPI entry - // see CR 6400863: Expensive creating of SAX parser in Mustang - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - - } // createObject(String,String,String):Object // // Private static methods @@ -235,7 +122,7 @@ // Check for any extension ClassLoaders in chain up to // boot ClassLoader chain = SecuritySupport.getParentClassLoader(chain); - }; + } // Assert: Context ClassLoader not in chain of // boot/extension/system ClassLoaders @@ -343,94 +230,4 @@ return providerClass; } - /* - * Try to find provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static Object findJarServiceProvider(String factoryId) - throws ConfigurationError - { - String serviceId = "META-INF/services/" + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = SecuritySupport.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = SecuritySupport.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); - } - - // No provider found - return null; - } - } // class ObjectFactory
--- a/src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java Fri May 31 10:27:50 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,553 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xerces.internal.xinclude; - -import java.io.InputStream; -import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; -import java.io.InputStreamReader; - -/** - * This class is duplicated for each JAXP subpackage so keep it in sync. - * It is package private and therefore is not exposed as part of the JAXP - * API. - * <p> - * This code is designed to implement the JAXP 1.1 spec pluggability - * feature and is designed to run on JDK version 1.1 and - * later, and to compile on JDK 1.2 and onward. - * The code also runs both as part of an unbundled jar file and - * when bundled as part of the JDK. - * <p> - * - */ -final class ObjectFactory { - - // - // Constants - // - - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; - - /** Set to true for debugging */ - private static final boolean DEBUG = false; - - /** - * Default columns per line. - */ - private static final int DEFAULT_LINE_LENGTH = 80; - - /** cache the contents of the xerces.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXercesProperties = null; - - /*** - * Cache the time stamp of the xerces.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xerces.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - if (DEBUG) debugPrintln("debug is on"); - - SecuritySupport ss = SecuritySupport.getInstance(); - ClassLoader cl = findClassLoader(); - - // Use the system property first - try { - String systemProp = ss.getSystemProperty(factoryId); - if (systemProp != null) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return newInstance(systemProp, cl, true); - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // JAXP specific change - // always use fallback class to avoid the expense of constantly - // "stat"ing a non-existent "xerces.properties" and jar SPI entry - // see CR 6400863: Expensive creating of SAX parser in Mustang - if (true) { - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } - - // Try to read from propertiesFilename, or $java.home/lib/xerces.properties - String factoryClassName = null; - // no properties file name specified; use $JAVA_HOME/lib/xerces.properties: - if (propertiesFilename == null) { - File propertiesFile = null; - boolean propertiesFileExists = false; - try { - String javah = ss.getSystemProperty("java.home"); - propertiesFilename = javah + File.separator + - "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME; - propertiesFile = new File(propertiesFilename); - propertiesFileExists = ss.getFileExists(propertiesFile); - } catch (SecurityException e) { - // try again... - fLastModified = -1; - fXercesProperties = null; - } - - synchronized (ObjectFactory.class) { - boolean loadProperties = false; - FileInputStream fis = null; - try { - // file existed last time - if(fLastModified >= 0) { - if(propertiesFileExists && - (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) { - loadProperties = true; - } else { - // file has stopped existing... - if(!propertiesFileExists) { - fLastModified = -1; - fXercesProperties = null; - } // else, file wasn't modified! - } - } else { - // file has started to exist: - if(propertiesFileExists) { - loadProperties = true; - fLastModified = ss.getLastModified(propertiesFile); - } // else, nothing's changed - } - if(loadProperties) { - // must never have attempted to read xerces.properties before (or it's outdeated) - fXercesProperties = new Properties(); - fis = ss.getFileInputStream(propertiesFile); - fXercesProperties.load(fis); - } - } catch (Exception x) { - fXercesProperties = null; - fLastModified = -1; - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if(fXercesProperties != null) { - factoryClassName = fXercesProperties.getProperty(factoryId); - } - } else { - FileInputStream fis = null; - try { - fis = ss.getFileInputStream(new File(propertiesFilename)); - Properties props = new Properties(); - props.load(fis); - factoryClassName = props.getProperty(factoryId); - } catch (Exception x) { - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if (factoryClassName != null) { - if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); - return newInstance(factoryClassName, cl, true); - } - - // Try Jar Service Provider Mechanism - Object provider = findJarServiceProvider(factoryId); - if (provider != null) { - return provider; - } - - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } // createObject(String,String,String):Object - - // - // Private static methods - // - - /** Prints a message to standard error if debugging is enabled. */ - private static void debugPrintln(String msg) { - if (DEBUG) { - System.err.println("JAXP: " + msg); - } - } // debugPrintln(String) - - /** - * Figure out which ClassLoader to use. For JDK 1.2 and later use - * the context ClassLoader. - */ - static ClassLoader findClassLoader() - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - - // Figure out which ClassLoader to use for loading the provider - // class. If there is a Context ClassLoader then use it. - ClassLoader context = ss.getContextClassLoader(); - ClassLoader system = ss.getSystemClassLoader(); - - ClassLoader chain = system; - while (true) { - if (context == chain) { - // Assert: we are on JDK 1.1 or we have no Context ClassLoader - // or any Context ClassLoader in chain of system classloader - // (including extension ClassLoader) so extend to widest - // ClassLoader (always look in system ClassLoader if Xerces - // is in boot/extension/system classpath and in current - // ClassLoader otherwise); normal classloaders delegate - // back to system ClassLoader first so this widening doesn't - // change the fact that context ClassLoader will be consulted - ClassLoader current = ObjectFactory.class.getClassLoader(); - - chain = system; - while (true) { - if (current == chain) { - // Assert: Current ClassLoader in chain of - // boot/extension/system ClassLoaders - return system; - } - if (chain == null) { - break; - } - chain = ss.getParentClassLoader(chain); - } - - // Assert: Current ClassLoader not in chain of - // boot/extension/system ClassLoaders - return current; - } - - if (chain == null) { - // boot ClassLoader reached - break; - } - - // Check for any extension ClassLoaders in chain up to - // boot ClassLoader - chain = ss.getParentClassLoader(chain); - }; - - // Assert: Context ClassLoader not in chain of - // boot/extension/system ClassLoaders - return context; - } // findClassLoader():ClassLoader - - /** - * Create an instance of a class using the specified ClassLoader - */ - static Object newInstance(String className, ClassLoader cl, - boolean doFallback) - throws ConfigurationError - { - // assert(className != null); - try{ - Class providerClass = findProviderClass(className, cl, doFallback); - Object instance = providerClass.newInstance(); - if (DEBUG) debugPrintln("created new instance of " + providerClass + - " using ClassLoader: " + cl); - return instance; - } catch (ClassNotFoundException x) { - throw new ConfigurationError( - "Provider " + className + " not found", x); - } catch (Exception x) { - throw new ConfigurationError( - "Provider " + className + " could not be instantiated: " + x, - x); - } - } - - /** - * Find a Class using the specified ClassLoader - */ - static Class findProviderClass(String className, ClassLoader cl, - boolean doFallback) - throws ClassNotFoundException, ConfigurationError - { - //throw security exception if the calling thread is not allowed to access the package - //restrict the access to package as speicified in java.security policy - SecurityManager security = System.getSecurityManager(); - if (security != null) { - final int lastDot = className.lastIndexOf("."); - String packageName = className; - if (lastDot != -1) packageName = className.substring(0, lastDot); - security.checkPackageAccess(packageName); - } - 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); - } else { - try { - providerClass = cl.loadClass(className); - } catch (ClassNotFoundException x) { - if (doFallback) { - // Fall back to current classloader - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (current == null) { - providerClass = Class.forName(className); - } else if (cl != current) { - cl = current; - providerClass = cl.loadClass(className); - } else { - throw x; - } - } else { - throw x; - } - } - } - - return providerClass; - } - - /* - * Try to find provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static Object findJarServiceProvider(String factoryId) - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - String serviceId = "META-INF/services/" + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = ss.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = ss.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); - } - - // No provider found - return null; - } - - // - // Classes - // - - /** - * A configuration error. - */ - static final class ConfigurationError - extends Error { - - /** Serialization version. */ - static final long serialVersionUID = 5061904944269807898L; - - // - // Data - // - - /** Exception. */ - private Exception exception; - - // - // Constructors - // - - /** - * Construct a new instance with the specified detail string and - * exception. - */ - ConfigurationError(String msg, Exception x) { - super(msg); - this.exception = x; - } // <init>(String,Exception) - - // - // methods - // - - /** Returns the exception associated to this error. */ - Exception getException() { - return exception; - } // getException():Exception - - } // class ConfigurationError - -} // class ObjectFactory
--- a/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java Mon Jun 10 09:51:09 2013 +0100 @@ -52,14 +52,6 @@ public abstract class DTMManager { - /** The default property name to load the manager. */ - private static final String defaultPropName = - "com.sun.org.apache.xml.internal.dtm.DTMManager"; - - /** The default class name to use as the manager. */ - private static String defaultClassName = - "com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault"; - /** * Factory for creating XMLString objects. * %TBD% Make this set by the caller. @@ -97,29 +89,7 @@ /** * Obtain a new instance of a <code>DTMManager</code>. * This static method creates a new factory instance - * This method uses the following ordered lookup procedure to determine - * the <code>DTMManager</code> implementation class to - * load: - * <ul> - * <li> - * Use the <code>com.sun.org.apache.xml.internal.dtm.DTMManager</code> system - * property. - * </li> - * <li> - * Use the JAVA_HOME(the parent directory where jdk is - * installed)/lib/xalan.properties for a property file that contains the - * name of the implementation class keyed on the same value as the - * system property defined above. - * </li> - * <li> - * Use the Services API (as detailed in the JAR specification), if - * available, to determine the classname. The Services API will look - * for a classname in the file - * <code>META-INF/services/com.sun.org.apache.xml.internal.dtm.DTMManager</code> - * in jars available to the runtime. - * </li> - * <li> - * Use the default <code>DTMManager</code> classname, which is + * using the default <code>DTMManager</code> implementation, which is * <code>com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault</code>. * </li> * </ul> @@ -136,39 +106,10 @@ public static DTMManager newInstance(XMLStringFactory xsf) throws DTMConfigurationException { - return newInstance(xsf, true); - } + final DTMManager factoryImpl = new com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault(); + factoryImpl.setXMLStringFactory(xsf); - public static DTMManager newInstance(XMLStringFactory xsf, boolean useServicesMechanism) - throws DTMConfigurationException - { - DTMManager factoryImpl = null; - try - { - if (useServicesMechanism) { - factoryImpl = (DTMManager) ObjectFactory - .createObject(defaultPropName, defaultClassName); - } else { - factoryImpl = new com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault(); - } - } - catch (ConfigurationError e) - { - throw new DTMConfigurationException(XMLMessages.createXMLMessage( - XMLErrorResources.ER_NO_DEFAULT_IMPL, null), e.getException()); - //"No default implementation found"); - } - - if (factoryImpl == null) - { - throw new DTMConfigurationException(XMLMessages.createXMLMessage( - XMLErrorResources.ER_NO_DEFAULT_IMPL, null)); - //"No default implementation found"); - } - - factoryImpl.setXMLStringFactory(xsf); - - return factoryImpl; + return factoryImpl; } /**
--- a/src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java Fri May 31 10:27:50 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,553 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.serialize; - -import java.io.InputStream; -import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; -import java.io.InputStreamReader; - -/** - * This class is duplicated for each JAXP subpackage so keep it in sync. - * It is package private and therefore is not exposed as part of the JAXP - * API. - * <p> - * This code is designed to implement the JAXP 1.1 spec pluggability - * feature and is designed to run on JDK version 1.1 and - * later, and to compile on JDK 1.2 and onward. - * The code also runs both as part of an unbundled jar file and - * when bundled as part of the JDK. - * <p> - * - */ -final class ObjectFactory { - - // - // Constants - // - - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; - - /** Set to true for debugging */ - private static final boolean DEBUG = false; - - /** - * Default columns per line. - */ - private static final int DEFAULT_LINE_LENGTH = 80; - - /** cache the contents of the xerces.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXercesProperties = null; - - /*** - * Cache the time stamp of the xerces.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - * <ol> - * <li>query the system property using <code>System.getProperty</code> - * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file - * <li>read <code>META-INF/services/<i>factoryId</i></code> file - * <li>use fallback classname - * </ol> - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xerces.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - if (DEBUG) debugPrintln("debug is on"); - - SecuritySupport ss = SecuritySupport.getInstance(); - ClassLoader cl = findClassLoader(); - - // Use the system property first - try { - String systemProp = ss.getSystemProperty(factoryId); - if (systemProp != null) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return newInstance(systemProp, cl, true); - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // JAXP specific change - // always use fallback class to avoid the expense of constantly - // "stat"ing a non-existent "xerces.properties" and jar SPI entry - // see CR 6400863: Expensive creating of SAX parser in Mustang - if (true) { - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } - - // Try to read from propertiesFilename, or $java.home/lib/xerces.properties - String factoryClassName = null; - // no properties file name specified; use $JAVA_HOME/lib/xerces.properties: - if (propertiesFilename == null) { - File propertiesFile = null; - boolean propertiesFileExists = false; - try { - String javah = ss.getSystemProperty("java.home"); - propertiesFilename = javah + File.separator + - "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME; - propertiesFile = new File(propertiesFilename); - propertiesFileExists = ss.getFileExists(propertiesFile); - } catch (SecurityException e) { - // try again... - fLastModified = -1; - fXercesProperties = null; - } - - synchronized (ObjectFactory.class) { - boolean loadProperties = false; - FileInputStream fis = null; - try { - // file existed last time - if(fLastModified >= 0) { - if(propertiesFileExists && - (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) { - loadProperties = true; - } else { - // file has stopped existing... - if(!propertiesFileExists) { - fLastModified = -1; - fXercesProperties = null; - } // else, file wasn't modified! - } - } else { - // file has started to exist: - if(propertiesFileExists) { - loadProperties = true; - fLastModified = ss.getLastModified(propertiesFile); - } // else, nothing's changed - } - if(loadProperties) { - // must never have attempted to read xerces.properties before (or it's outdeated) - fXercesProperties = new Properties(); - fis = ss.getFileInputStream(propertiesFile); - fXercesProperties.load(fis); - } - } catch (Exception x) { - fXercesProperties = null; - fLastModified = -1; - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if(fXercesProperties != null) { - factoryClassName = fXercesProperties.getProperty(factoryId); - } - } else { - FileInputStream fis = null; - try { - fis = ss.getFileInputStream(new File(propertiesFilename)); - Properties props = new Properties(); - props.load(fis); - factoryClassName = props.getProperty(factoryId); - } catch (Exception x) { - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if (factoryClassName != null) { - if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); - return newInstance(factoryClassName, cl, true); - } - - // Try Jar Service Provider Mechanism - Object provider = findJarServiceProvider(factoryId); - if (provider != null) { - return provider; - } - - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } // createObject(String,String,String):Object - - // - // Private static methods - // - - /** Prints a message to standard error if debugging is enabled. */ - private static void debugPrintln(String msg) { - if (DEBUG) { - System.err.println("JAXP: " + msg); - } - } // debugPrintln(String) - - /** - * Figure out which ClassLoader to use. For JDK 1.2 and later use - * the context ClassLoader. - */ - static ClassLoader findClassLoader() - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - - // Figure out which ClassLoader to use for loading the provider - // class. If there is a Context ClassLoader then use it. - ClassLoader context = ss.getContextClassLoader(); - ClassLoader system = ss.getSystemClassLoader(); - - ClassLoader chain = system; - while (true) { - if (context == chain) { - // Assert: we are on JDK 1.1 or we have no Context ClassLoader - // or any Context ClassLoader in chain of system classloader - // (including extension ClassLoader) so extend to widest - // ClassLoader (always look in system ClassLoader if Xerces - // is in boot/extension/system classpath and in current - // ClassLoader otherwise); normal classloaders delegate - // back to system ClassLoader first so this widening doesn't - // change the fact that context ClassLoader will be consulted - ClassLoader current = ObjectFactory.class.getClassLoader(); - - chain = system; - while (true) { - if (current == chain) { - // Assert: Current ClassLoader in chain of - // boot/extension/system ClassLoaders - return system; - } - if (chain == null) { - break; - } - chain = ss.getParentClassLoader(chain); - } - - // Assert: Current ClassLoader not in chain of - // boot/extension/system ClassLoaders - return current; - } - - if (chain == null) { - // boot ClassLoader reached - break; - } - - // Check for any extension ClassLoaders in chain up to - // boot ClassLoader - chain = ss.getParentClassLoader(chain); - }; - - // Assert: Context ClassLoader not in chain of - // boot/extension/system ClassLoaders - return context; - } // findClassLoader():ClassLoader - - /** - * Create an instance of a class using the specified ClassLoader - */ - static Object newInstance(String className, ClassLoader cl, - boolean doFallback) - throws ConfigurationError - { - // assert(className != null); - try{ - Class providerClass = findProviderClass(className, cl, doFallback); - Object instance = providerClass.newInstance(); - if (DEBUG) debugPrintln("created new instance of " + providerClass + - " using ClassLoader: " + cl); - return instance; - } catch (ClassNotFoundException x) { - throw new ConfigurationError( - "Provider " + className + " not found", x); - } catch (Exception x) { - throw new ConfigurationError( - "Provider " + className + " could not be instantiated: " + x, - x); - } - } - - /** - * Find a Class using the specified ClassLoader - */ - static Class findProviderClass(String className, ClassLoader cl, - boolean doFallback) - throws ClassNotFoundException, ConfigurationError - { - //throw security exception if the calling thread is not allowed to access the package - //restrict the access to package as speicified in java.security policy - SecurityManager security = System.getSecurityManager(); - if (security != null) { - final int lastDot = className.lastIndexOf("."); - String packageName = className; - if (lastDot != -1) packageName = className.substring(0, lastDot); - security.checkPackageAccess(packageName); - } - 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); - } else { - try { - providerClass = cl.loadClass(className); - } catch (ClassNotFoundException x) { - if (doFallback) { - // Fall back to current classloader - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (current == null) { - providerClass = Class.forName(className); - } else if (cl != current) { - cl = current; - providerClass = cl.loadClass(className); - } else { - throw x; - } - } else { - throw x; - } - } - } - - return providerClass; - } - - /* - * Try to find provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static Object findJarServiceProvider(String factoryId) - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - String serviceId = "META-INF/services/" + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = ss.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = ss.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); - } - - // No provider found - return null; - } - - // - // Classes - // - - /** - * A configuration error. - */ - static final class ConfigurationError - extends Error { - - /** Serialization version. */ - static final long serialVersionUID = 937647395548533254L; - - // - // Data - // - - /** Exception. */ - private Exception exception; - - // - // Constructors - // - - /** - * Construct a new instance with the specified detail string and - * exception. - */ - ConfigurationError(String msg, Exception x) { - super(msg); - this.exception = x; - } // <init>(String,Exception) - - // - // methods - // - - /** Returns the exception associated to this error. */ - Exception getException() { - return exception; - } // getException():Exception - - } // class ConfigurationError - -} // class ObjectFactory
--- a/src/com/sun/org/apache/xpath/internal/XPathContext.java Fri May 31 10:27:50 2013 +0100 +++ b/src/com/sun/org/apache/xpath/internal/XPathContext.java Mon Jun 10 09:51:09 2013 +0100 @@ -22,17 +22,6 @@ */ package com.sun.org.apache.xpath.internal; -import java.lang.reflect.Method; -import java.util.Stack; -import java.util.Vector; -import java.util.HashMap; -import java.util.Iterator; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.SourceLocator; -import javax.xml.transform.TransformerException; -import javax.xml.transform.URIResolver; - import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; import com.sun.org.apache.xalan.internal.res.XSLMessages; import com.sun.org.apache.xml.internal.dtm.Axis; @@ -46,14 +35,21 @@ import com.sun.org.apache.xml.internal.utils.NodeVector; import com.sun.org.apache.xml.internal.utils.ObjectStack; import com.sun.org.apache.xml.internal.utils.PrefixResolver; -import com.sun.org.apache.xml.internal.utils.SAXSourceLocator; import com.sun.org.apache.xml.internal.utils.XMLString; import com.sun.org.apache.xpath.internal.axes.SubContextList; +import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag; import com.sun.org.apache.xpath.internal.objects.XObject; -import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag; import com.sun.org.apache.xpath.internal.objects.XString; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; - +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Stack; +import java.util.Vector; +import javax.xml.transform.ErrorListener; +import javax.xml.transform.SourceLocator; +import javax.xml.transform.TransformerException; +import javax.xml.transform.URIResolver; import org.xml.sax.XMLReader; /** @@ -339,8 +335,8 @@ m_saxLocations.push(null); m_useServicesMechanism = useServicesMechanism; m_dtmManager = DTMManager.newInstance( - com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory(), - m_useServicesMechanism); + com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory() + ); } /** @@ -363,8 +359,8 @@ m_dtmManager = DTMManager.newInstance( - com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory(), - m_useServicesMechanism); + com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory() + ); m_saxLocations.removeAllElements(); m_axesIteratorStack.removeAllElements(); @@ -622,32 +618,6 @@ /** Misnamed string manager for XPath messages. */ // private static XSLMessages m_XSLMessages = new XSLMessages(); - /** - * Tell the user of an assertion error, and probably throw an - * exception. - * - * @param b If false, a TransformerException will be thrown. - * @param msg The assertion message, which should be informative. - * - * @throws javax.xml.transform.TransformerException if b is false. - */ - private void assertion(boolean b, String msg) throws javax.xml.transform.TransformerException - { - if (!b) - { - ErrorListener errorHandler = getErrorListener(); - - if (errorHandler != null) - { - errorHandler.fatalError( - new TransformerException( - XSLMessages.createMessage( - XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION, - new Object[]{ msg }), (SAXSourceLocator)this.getSAXLocator())); - } - } - } - //========================================================== // SECTION: Execution context state tracking //========================================================== @@ -664,7 +634,7 @@ * Get the current context node list. * * @return the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>, - * also refered to here as a <term>context node list</term>. + * also referred to here as a <term>context node list</term>. */ public final DTMIterator getContextNodeList() { @@ -679,7 +649,7 @@ * Set the current context node list. * * @param nl the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>, - * also refered to here as a <term>context node list</term>. + * also referred to here as a <term>context node list</term>. * @xsl.usage internal */ public final void pushContextNodeList(DTMIterator nl) @@ -700,7 +670,7 @@ } /** - * The ammount to use for stacks that record information during the + * The amount to use for stacks that record information during the * recursive execution. */ public static final int RECURSIONLIMIT = (1024*4);
--- a/src/javax/xml/xpath/XPathException.java Fri May 31 10:27:50 2013 +0100 +++ b/src/javax/xml/xpath/XPathException.java Mon Jun 10 09:51:09 2013 +0100 @@ -26,6 +26,11 @@ package javax.xml.xpath; import java.io.PrintWriter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamField; +import java.io.InvalidClassException; /** * <code>XPathException</code> represents a generic XPath exception.</p> @@ -36,7 +41,9 @@ */ public class XPathException extends Exception { - private final Throwable cause; + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField( "cause", Throwable.class ) + }; /** * <p>Stream Unique Identifier.</p> @@ -62,7 +69,6 @@ if ( message == null ) { throw new NullPointerException ( "message can't be null"); } - this.cause = null; } /** @@ -77,8 +83,7 @@ * @throws NullPointerException if <code>cause</code> is <code>null</code>. */ public XPathException(Throwable cause) { - super(); - this.cause = cause; + super(cause); if ( cause == null ) { throw new NullPointerException ( "cause can't be null"); } @@ -90,7 +95,47 @@ * @return Cause of this XPathException. */ public Throwable getCause() { - return cause; + return super.getCause(); + } + + /** + * Writes "cause" field to the stream. + * The cause is got from the parent class. + * + * @param out stream used for serialization. + * @throws IOException thrown by <code>ObjectOutputStream</code> + * + */ + private void writeObject(ObjectOutputStream out) + throws IOException + { + ObjectOutputStream.PutField fields = out.putFields(); + fields.put("cause", (Throwable) super.getCause()); + out.writeFields(); + } + + /** + * Reads the "cause" field from the stream. + * And initializes the "cause" if it wasn't + * done before. + * + * @param in stream used for deserialization + * @throws IOException thrown by <code>ObjectInputStream</code> + * @throws ClassNotFoundException thrown by <code>ObjectInputStream</code> + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + ObjectInputStream.GetField fields = in.readFields(); + Throwable scause = (Throwable) fields.get("cause", null); + + if (super.getCause() == null && scause != null) { + try { + super.initCause(scause); + } catch(IllegalStateException e) { + throw new InvalidClassException("Inconsistent state: two causes"); + } + } } /**