changeset 419:e27c35e24ebe preview_rc1

Merge up to jdk8-b90
author Edward Nevill edward.nevill@linaro.org
date Fri, 27 Sep 2013 15:40:15 +0100
parents 102bfdf5036d (current diff) 668acc0e1034 (diff)
children c073a7c71352
files .hgtags
diffstat 124 files changed, 2980 insertions(+), 5291 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Aug 13 17:06:23 2013 +0100
+++ b/.hgtags	Fri Sep 27 15:40:15 2013 +0100
@@ -208,3 +208,8 @@
 a46d69a1a8ec9652a48114823535372e1c980799 jdk8-b83
 f5f40094ffcc1230e2a5f76ea4c968645369be6c jdk8-b84
 aa68d933af52ed7c53affdb4660ee451c9516b53 aarch64-20130813
+41b50e2c5ea3f4aa1af729e1deb1678cb3e1ef9c jdk8-b85
+ca71ec37b2efc9c3f0971ebabb3a6eb1213d76de jdk8-b86
+eddbc8ad2435a89f64729512337c9f2669e4dd85 jdk8-b87
+7122f7bb0fcc8a39e5254402119b2ee3fa0ad313 jdk8-b88
+893d2ba8bbea3a8d090e51d8eaea285b390789ea jdk8-b89
--- a/build.xml	Tue Aug 13 17:06:23 2013 +0100
+++ b/build.xml	Fri Sep 27 15:40:15 2013 +0100
@@ -176,4 +176,42 @@
         <echo message="+---------------------------------------+"/>
     </target>
 
+    <target name="javadoc" depends="init" description="Build basic Javadoc for public packages.">
+        <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
+        <!-- Note: even with this default value, includes/excludes
+         from share.src.dir get javadoc'd; see packageset below -->
+        <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
+        <property name="javadoc.dir" value="${build.dir}/docs/api"/>
+        <property name="includes" value="**"/>
+        <javadoc destdir="${javadoc.dir}" source="1.5"
+            windowtitle="UNOFFICIAL" failonerror="true" use="true"
+            author="false" version="false"
+            packagenames="${javadoc.packagenames}">
+            <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
+            <arg line="${javadoc.options}"/>
+            <bootclasspath>
+                <path location="${java.home}/lib/rt.jar"/>
+                <path location="${build.classes.dir}"/>
+            </bootclasspath>
+            <sourcepath>
+                <pathelement location="${jaxp.src.dir}"/>
+            </sourcepath>
+            <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
+            <!-- means that {@link some.package} will not work, which is no good. -->
+            <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
+            <!-- which also causes duplicates in the class index for included files.) -->
+            <packageset dir="${jaxp.src.dir}" includes="${includes}" excludes="${excludes}">
+                <or>
+                    <filename name="javax/"/>
+                    <filename name="org/w3c/"/>
+                    <filename name="org/xml/sax/"/>
+                </or>
+            </packageset>
+        </javadoc>
+    </target>
+    <target name="javadoc-nb" depends="javadoc" if="netbeans.home">
+        <property name="javadoc.dir=" value="${build.dir}/docs/api"/>
+        <nbbrowse file="${javadoc.dir}/index.html"/>
+    </target>
+
 </project>
--- a/nbproject/project.xml	Tue Aug 13 17:06:23 2013 +0100
+++ b/nbproject/project.xml	Fri Sep 27 15:40:15 2013 +0100
@@ -15,6 +15,12 @@
                     <location>.</location>
                     <encoding>UTF-8</encoding>
                 </source-folder>
+                <source-folder>
+                    <label>src</label>
+                    <type>java</type>
+                    <location>src</location>
+                    <encoding>UTF-8</encoding>
+                </source-folder>
             </folders>
             <ide-actions>
                 <action name="build">
@@ -27,9 +33,16 @@
                     <target>clean</target>
                     <target>build</target>
                 </action>
+                <action name="javadoc">
+                    <target>javadoc-nb</target>
+                </action>
             </ide-actions>
             <view>
                 <items>
+                    <source-folder style="packages">
+                        <label>src</label>
+                        <location>src</location>
+                    </source-folder>
                     <source-file>
                         <location>build.xml</location>
                     </source-file>
@@ -38,11 +51,16 @@
                     <ide-action name="build"/>
                     <ide-action name="rebuild"/>
                     <ide-action name="clean"/>
+                    <ide-action name="javadoc"/>
                 </context-menu>
             </view>
             <subprojects/>
         </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1"/>
+        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
+            <compilation-unit>
+                <package-root>src</package-root>
+            </compilation-unit>
+        </java-data>
         <preferences xmlns="http://www.netbeans.org/ns/auxiliary-configuration-preferences/1">
             <module name="org-netbeans-modules-editor-indent"/>
         </preferences>
--- a/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java	Fri Sep 27 15:40:15 2013 +0100
@@ -63,6 +63,7 @@
 import  com.sun.org.apache.bcel.internal.util.ClassVector;
 import  com.sun.org.apache.bcel.internal.util.ClassQueue;
 import  com.sun.org.apache.bcel.internal.generic.Type;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 import  java.io.*;
 import  java.util.StringTokenizer;
@@ -77,6 +78,7 @@
  * class file.  Those interested in programatically generating classes
  * should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
 
+ * @version $Id: JavaClass.java,v 1.4 2007-07-19 04:34:42 ofung Exp $
  * @see com.sun.org.apache.bcel.internal.generic.ClassGen
  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
@@ -451,9 +453,9 @@
     String debug = null, sep = null;
 
     try {
-      debug = System.getProperty("JavaClass.debug");
+      debug = SecuritySupport.getSystemProperty("JavaClass.debug");
       // Get path separator either / or \ usually
-      sep = System.getProperty("file.separator");
+      sep = SecuritySupport.getSystemProperty("file.separator");
     }
     catch (SecurityException e) {
         // falls through
--- a/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java	Fri Sep 27 15:40:15 2013 +0100
@@ -82,6 +82,7 @@
  * method in the Method's frame will jump to the appropiate method in
  * the Code frame.
  *
+ * @version $Id: Class2HTML.java,v 1.3 2007-07-19 04:34:52 ofung Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
 */
 public class Class2HTML implements Constants
@@ -137,7 +138,7 @@
     ClassParser parser=null;
     JavaClass   java_class=null;
     String      zip_file = null;
-    char        sep = System.getProperty("file.separator").toCharArray()[0];
+    char        sep = SecuritySupport.getSystemProperty("file.separator").toCharArray()[0];
     String      dir = "." + sep; // Where to store HTML files
 
     try {
--- a/src/com/sun/org/apache/bcel/internal/util/ClassPath.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/bcel/internal/util/ClassPath.java	Fri Sep 27 15:40:15 2013 +0100
@@ -66,6 +66,7 @@
  * Responsible for loading (class) files from the CLASSPATH. Inspired by
  * sun.tools.ClassPath.
  *
+ * @version $Id: ClassPath.java,v 1.4 2007-07-19 04:34:52 ofung Exp $
  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public class ClassPath implements Serializable {
@@ -83,7 +84,7 @@
     ArrayList vec = new ArrayList();
 
     for(StringTokenizer tok=new StringTokenizer(class_path,
-                                                System.getProperty("path.separator"));
+                            SecuritySupport.getSystemProperty("path.separator"));
         tok.hasMoreTokens();)
     {
       String path = tok.nextToken();
@@ -92,7 +93,7 @@
         File file = new File(path);
 
         try {
-          if(file.exists()) {
+          if(SecuritySupport.getFileExists(file)) {
             if(file.isDirectory())
               vec.add(new Dir(path));
             else
@@ -143,8 +144,9 @@
         String name = tok.nextToken();
         File   file = new File(name);
 
-        if(file.exists())
+        if(SecuritySupport.getFileExists(file)) {
           list.add(name);
+        }
       }
     }
   }
@@ -159,9 +161,9 @@
     String class_path, boot_path, ext_path;
 
     try {
-      class_path = System.getProperty("java.class.path");
-      boot_path  = System.getProperty("sun.boot.class.path");
-      ext_path   = System.getProperty("java.ext.dirs");
+      class_path = SecuritySupport.getSystemProperty("java.class.path");
+      boot_path  = SecuritySupport.getSystemProperty("sun.boot.class.path");
+      ext_path   = SecuritySupport.getSystemProperty("java.ext.dirs");
     }
     catch (SecurityException e) {
         return "";
@@ -176,8 +178,8 @@
     getPathComponents(ext_path, dirs);
 
     for(Iterator e = dirs.iterator(); e.hasNext(); ) {
-      File     ext_dir    = new File((String)e.next());
-      String[] extensions = ext_dir.list(new FilenameFilter() {
+      File ext_dir = new File((String)e.next());
+      String[] extensions = SecuritySupport.getFileList(ext_dir, new FilenameFilter() {
         public boolean accept(File dir, String name) {
           name = name.toLowerCase();
           return name.endsWith(".zip") || name.endsWith(".jar");
@@ -342,7 +344,7 @@
       final File file = new File(dir + File.separatorChar +
                                  name.replace('.', File.separatorChar) + suffix);
 
-      return file.exists()? new ClassFile() {
+      return SecuritySupport.getFileExists(file)? new ClassFile() {
         public InputStream getInputStream() throws IOException { return new FileInputStream(file); }
 
         public String      getPath()        { try {
--- a/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java	Fri Sep 27 15:40:15 2013 +0100
@@ -72,6 +72,7 @@
  * <pre>java com.sun.org.apache.bcel.internal.util.JavaWrapper -Dbcel.classloader=foo.MyLoader &lt;real.class.name&gt; [arguments]</pre>
  * </p>
  *
+ * @version $Id: JavaWrapper.java,v 1.3 2007-07-19 04:34:52 ofung Exp $
  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @see ClassLoader
  */
@@ -79,7 +80,7 @@
   private java.lang.ClassLoader loader;
 
   private static java.lang.ClassLoader getClassLoader() {
-    String s = System.getProperty("bcel.classloader");
+    String s = SecuritySupport.getSystemProperty("bcel.classloader");
 
     if((s == null) || "".equals(s))
       s = "com.sun.org.apache.bcel.internal.util.ClassLoader";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/sun/org/apache/bcel/internal/util/SecuritySupport.java	Fri Sep 27 15:40:15 2013 +0100
@@ -0,0 +1,223 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Copyright 2002-2004 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.bcel.internal.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.InputStream;
+import java.lang.ClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ListResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class is duplicated for each subpackage so keep it in sync. It is
+ * package private and therefore is not exposed as part of any API.
+ *
+ * @xerces.internal
+ */
+public final class SecuritySupport {
+
+    private static final SecuritySupport securitySupport = new SecuritySupport();
+
+    /**
+     * Return an instance of this class.
+     */
+    public static SecuritySupport getInstance() {
+        return securitySupport;
+    }
+
+    static ClassLoader getContextClassLoader() {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                ClassLoader cl = null;
+                try {
+                    cl = Thread.currentThread().getContextClassLoader();
+                } catch (SecurityException ex) {
+                }
+                return cl;
+            }
+        });
+    }
+
+    static ClassLoader getSystemClassLoader() {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                ClassLoader cl = null;
+                try {
+                    cl = ClassLoader.getSystemClassLoader();
+                } catch (SecurityException ex) {
+                }
+                return cl;
+            }
+        });
+    }
+
+    static ClassLoader getParentClassLoader(final ClassLoader cl) {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                ClassLoader parent = null;
+                try {
+                    parent = cl.getParent();
+                } catch (SecurityException ex) {
+                }
+
+                // eliminate loops in case of the boot
+                // ClassLoader returning itself as a parent
+                return (parent == cl) ? null : parent;
+            }
+        });
+    }
+
+    public static String getSystemProperty(final String propName) {
+        return (String) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return System.getProperty(propName);
+            }
+        });
+    }
+
+    static FileInputStream getFileInputStream(final File file)
+            throws FileNotFoundException {
+        try {
+            return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                public Object run() throws FileNotFoundException {
+                    return new FileInputStream(file);
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            throw (FileNotFoundException) e.getException();
+        }
+    }
+
+    /**
+     * Return resource using the same classloader for the ObjectFactory by
+     * default or bootclassloader when Security Manager is in place
+     */
+    public static InputStream getResourceAsStream(final String name) {
+        if (System.getSecurityManager() != null) {
+            return getResourceAsStream(null, name);
+        } else {
+            return getResourceAsStream(findClassLoader(), name);
+        }
+    }
+
+    public static InputStream getResourceAsStream(final ClassLoader cl,
+            final String name) {
+        return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                InputStream ris;
+                if (cl == null) {
+                    ris = Object.class.getResourceAsStream("/" + name);
+                } else {
+                    ris = cl.getResourceAsStream(name);
+                }
+                return ris;
+            }
+        });
+    }
+
+    /**
+     * Gets a resource bundle using the specified base name, the default locale,
+     * and the caller's class loader.
+     *
+     * @param bundle the base name of the resource bundle, a fully qualified
+     * class name
+     * @return a resource bundle for the given base name and the default locale
+     */
+    public static ListResourceBundle getResourceBundle(String bundle) {
+        return getResourceBundle(bundle, Locale.getDefault());
+    }
+
+    /**
+     * Gets a resource bundle using the specified base name and locale, and the
+     * caller's class loader.
+     *
+     * @param bundle the base name of the resource bundle, a fully qualified
+     * class name
+     * @param locale the locale for which a resource bundle is desired
+     * @return a resource bundle for the given base name and locale
+     */
+    public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
+        return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
+            public ListResourceBundle run() {
+                try {
+                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
+                } catch (MissingResourceException e) {
+                    try {
+                        return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
+                    } catch (MissingResourceException e2) {
+                        throw new MissingResourceException(
+                                "Could not load any resource bundle by " + bundle, bundle, "");
+                    }
+                }
+            }
+        });
+    }
+
+    public static String[] getFileList(final File f, final FilenameFilter filter) {
+        return ((String[]) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return f.list(filter);
+            }
+        }));
+    }
+
+    public static boolean getFileExists(final File f) {
+        return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return f.exists() ? Boolean.TRUE : Boolean.FALSE;
+            }
+        })).booleanValue();
+    }
+
+    static long getLastModified(final File f) {
+        return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return new Long(f.lastModified());
+            }
+        })).longValue();
+    }
+
+
+    /**
+     * Figure out which ClassLoader to use.
+     */
+    public static ClassLoader findClassLoader()
+    {
+        if (System.getSecurityManager()!=null) {
+            //this will ensure bootclassloader is used
+            return null;
+        } else {
+            return SecuritySupport.class.getClassLoader();
+        }
+    } // findClassLoader():ClassLoader
+
+    private SecuritySupport() {
+    }
+}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLMessages.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLMessages.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,68 +22,72 @@
  */
 package com.sun.org.apache.xalan.internal.res;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.util.ListResourceBundle;
 
 import com.sun.org.apache.xpath.internal.res.XPATHMessages;
 
 /**
- * Sets things up for issuing error messages.  This class is misnamed, and
- * should be called XalanMessages, or some such.
+ * Sets things up for issuing error messages. This class is misnamed, and should
+ * be called XalanMessages, or some such.
+ *
  * @xsl.usage internal
  */
-public class XSLMessages extends XPATHMessages
-{
+public class XSLMessages extends XPATHMessages {
 
-  /** The language specific resource object for Xalan messages.  */
-  private static ListResourceBundle XSLTBundle = null;
-
-  /** The class name of the Xalan error message string table.    */
-  private static final String XSLT_ERROR_RESOURCES =
-    "com.sun.org.apache.xalan.internal.res.XSLTErrorResources";
+    /**
+     * The language specific resource object for Xalan messages.
+     */
+    private static ListResourceBundle XSLTBundle = null;
+    /**
+     * The class name of the Xalan error message string table.
+     */
+    private static final String XSLT_ERROR_RESOURCES =
+            "com.sun.org.apache.xalan.internal.res.XSLTErrorResources";
 
-  /**
-   * Creates a message from the specified key and replacement
-   * arguments, localized to the given locale.
-   *
-   * @param msgKey    The key for the message text.
-   * @param args      The arguments to be used as replacement text
-   *                  in the message created.
-   *
-   * @return The formatted message string.
-   */
-  public static final String createMessage(String msgKey, Object args[])  //throws Exception
-  {
-    if (XSLTBundle == null)
-      XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
-
-    if (XSLTBundle != null)
+    /**
+     * Creates a message from the specified key and replacement arguments,
+     * localized to the given locale.
+     *
+     * @param msgKey The key for the message text.
+     * @param args The arguments to be used as replacement text in the message
+     * created.
+     *
+     * @return The formatted message string.
+     */
+    public static String createMessage(String msgKey, Object args[]) //throws Exception
     {
-      return createMsg(XSLTBundle, msgKey, args);
+        if (XSLTBundle == null) {
+            XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
+        }
+
+        if (XSLTBundle != null) {
+            return createMsg(XSLTBundle, msgKey, args);
+        } else {
+            return "Could not load any resource bundles.";
+        }
     }
-    else
-      return "Could not load any resource bundles.";
-  }
 
-  /**
-   * Creates a message from the specified key and replacement
-   * arguments, localized to the given locale.
-   *
-   * @param msgKey    The key for the message text.
-   * @param args      The arguments to be used as replacement text
-   *                  in the message created.
-   *
-   * @return The formatted warning string.
-   */
-  public static final String createWarning(String msgKey, Object args[])  //throws Exception
-  {
-    if (XSLTBundle == null)
-      XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
+    /**
+     * Creates a message from the specified key and replacement arguments,
+     * localized to the given locale.
+     *
+     * @param msgKey The key for the message text.
+     * @param args The arguments to be used as replacement text in the message
+     * created.
+     *
+     * @return The formatted warning string.
+     */
+    public static String createWarning(String msgKey, Object args[]) //throws Exception
+    {
+        if (XSLTBundle == null) {
+            XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
+        }
 
-    if (XSLTBundle != null)
-    {
-      return createMsg(XSLTBundle, msgKey, args);
+        if (XSLTBundle != null) {
+            return createMsg(XSLTBundle, msgKey, args);
+        } else {
+            return "Could not load any resource bundles.";
+        }
     }
-    else
-      return "Could not load any resource bundles.";
-  }
 }
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1449,68 +1449,5 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 
 }
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1448,68 +1448,4 @@
   public static final String QUERY_HEADER = "PATTERN ";
 
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XSLTErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XSLTErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
     }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XSLTErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
-
-}
--- a/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -54,6 +54,8 @@
     //
     // Constants
     //
+     private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal";
+     private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal";
 
     // name of default properties file to look for in JDK's jre/lib directory
     private static final String DEFAULT_PROPERTIES_FILENAME =
@@ -514,12 +516,17 @@
         //class. Restrict the access to the package classes as specified in java.security policy.
         SecurityManager security = System.getSecurityManager();
         try{
-                if (security != null){
+            if (security != null){
+                if (className.startsWith(XALAN_INTERNAL) ||
+                    className.startsWith(XERCES_INTERNAL)) {
+                    cl = null;
+                } else {
                     final int lastDot = className.lastIndexOf(".");
                     String packageName = className;
                     if (lastDot != -1) packageName = className.substring(0, lastDot);
                     security.checkPackageAccess(packageName);
-                 }
+                }
+             }
         }catch(SecurityException e){
             throw e;
         }
--- a/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java	Fri Sep 27 15:40:15 2013 +0100
@@ -32,10 +32,14 @@
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.ListResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 
 /**
- * This class is duplicated for each subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of any API.
+ * This class is duplicated for each subpackage so keep it in sync. It is
+ * package private and therefore is not exposed as part of any API.
  *
  * @xerces.internal
  */
@@ -51,39 +55,39 @@
     }
 
     static ClassLoader getContextClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 ClassLoader cl = null;
                 try {
                     cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) { }
+                } catch (SecurityException ex) {
+                }
                 return cl;
             }
         });
     }
 
     static ClassLoader getSystemClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 ClassLoader cl = null;
                 try {
                     cl = ClassLoader.getSystemClassLoader();
-                } catch (SecurityException ex) {}
+                } catch (SecurityException ex) {
+                }
                 return cl;
             }
         });
     }
 
     static ClassLoader getParentClassLoader(final ClassLoader cl) {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
+        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 ClassLoader parent = null;
                 try {
                     parent = cl.getParent();
-                } catch (SecurityException ex) {}
+                } catch (SecurityException ex) {
+                }
 
                 // eliminate loops in case of the boot
                 // ClassLoader returning itself as a parent
@@ -93,20 +97,25 @@
     }
 
     public static String getSystemProperty(final String propName) {
-        return (String)
-        AccessController.doPrivileged(new PrivilegedAction() {
+        return (String) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 return System.getProperty(propName);
             }
         });
     }
 
+    public static String getSystemProperty(final String propName, final String def) {
+        return (String) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return System.getProperty(propName, def);
+            }
+        });
+    }
+
     static FileInputStream getFileInputStream(final File file)
-    throws FileNotFoundException
-    {
+            throws FileNotFoundException {
         try {
-            return (FileInputStream)
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
+            return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                 public Object run() throws FileNotFoundException {
                     return new FileInputStream(file);
                 }
@@ -115,9 +124,10 @@
             throw (FileNotFoundException)e.getException();
         }
     }
+
     /**
-     * Return resource using the same classloader for the ObjectFactory by default
-     * or bootclassloader when Security Manager is in place
+     * Return resource using the same classloader for the ObjectFactory by
+     * default or bootclassloader when Security Manager is in place
      */
     public static InputStream getResourceAsStream(final String name) {
         if (System.getSecurityManager()!=null) {
@@ -128,10 +138,8 @@
     }
 
     public static InputStream getResourceAsStream(final ClassLoader cl,
-            final String name)
-    {
-        return (InputStream)
-        AccessController.doPrivileged(new PrivilegedAction() {
+            final String name) {
+        return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 InputStream ris;
                 if (cl == null) {
@@ -144,9 +152,40 @@
         });
     }
 
-    static boolean getFileExists(final File f) {
-        return ((Boolean)
-                AccessController.doPrivileged(new PrivilegedAction() {
+    /**
+     * Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
+     * @param bundle the base name of the resource bundle, a fully qualified class name
+     * @return a resource bundle for the given base name and the default locale
+     */
+    public static ListResourceBundle getResourceBundle(String bundle) {
+        return getResourceBundle(bundle, Locale.getDefault());
+    }
+
+    /**
+     * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
+     * @param bundle the base name of the resource bundle, a fully qualified class name
+     * @param locale the locale for which a resource bundle is desired
+     * @return a resource bundle for the given base name and locale
+     */
+    public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
+        return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
+            public ListResourceBundle run() {
+                try {
+                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
+                } catch (MissingResourceException e) {
+                    try {
+                        return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
+                    } catch (MissingResourceException e2) {
+                        throw new MissingResourceException(
+                                "Could not load any resource bundle by " + bundle, bundle, "");
+                    }
+                }
+            }
+        });
+    }
+
+    public static boolean getFileExists(final File f) {
+        return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
                     public Object run() {
                         return f.exists() ? Boolean.TRUE : Boolean.FALSE;
                     }
@@ -154,13 +193,14 @@
     }
 
     static long getLastModified(final File f) {
-        return ((Long)
-                AccessController.doPrivileged(new PrivilegedAction() {
+        return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
                     public Object run() {
                         return new Long(f.lastModified());
                     }
                 })).longValue();
     }
 
-    private SecuritySupport () {}
+
+    private SecuritySupport() {
+    }
 }
--- a/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,6 +23,7 @@
 package com.sun.org.apache.xalan.internal.xslt;
 
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -574,7 +575,7 @@
     // Grab java version for later use
     try
     {
-      String javaVersion = System.getProperty("java.version");
+      String javaVersion = SecuritySupport.getSystemProperty("java.version");
 
       h.put("java.version", javaVersion);
     }
@@ -593,7 +594,7 @@
     {
 
       // This is present in all JVM's
-      String cp = System.getProperty("java.class.path");
+      String cp = SecuritySupport.getSystemProperty("java.class.path");
 
       h.put("java.class.path", cp);
 
@@ -603,7 +604,7 @@
         h.put(FOUNDCLASSES + "java.class.path", classpathJars);
 
       // Also check for JDK 1.2+ type classpaths
-      String othercp = System.getProperty("sun.boot.class.path");
+      String othercp = SecuritySupport.getSystemProperty("sun.boot.class.path");
 
       if (null != othercp)
       {
@@ -617,7 +618,7 @@
 
       //@todo NOTE: We don't actually search java.ext.dirs for
       //  *.jar files therein! This should be updated
-      othercp = System.getProperty("java.ext.dirs");
+      othercp = SecuritySupport.getSystemProperty("java.ext.dirs");
 
       if (null != othercp)
       {
--- a/src/com/sun/org/apache/xalan/internal/xslt/Process.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xslt/Process.java	Fri Sep 27 15:40:15 2013 +0100
@@ -57,6 +57,7 @@
 import com.sun.org.apache.xalan.internal.res.XSLTErrorResources;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
 import com.sun.org.apache.xalan.internal.utils.ConfigurationError;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 //J2SE does not support Xalan interpretive
 /*
@@ -180,7 +181,7 @@
     java.io.PrintWriter diagnosticsWriter = new PrintWriter(System.err, true);
     java.io.PrintWriter dumpWriter = diagnosticsWriter;
     ResourceBundle resbundle =
-      (XSLMessages.loadResourceBundle(
+      (SecuritySupport.getResourceBundle(
         com.sun.org.apache.xml.internal.utils.res.XResourceBundle.ERROR_RESOURCES));
     String flavor = "s2s";
 
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Fri Sep 27 15:40:15 2013 +0100
@@ -410,7 +410,7 @@
             }
         }
         catch (TypeCheckError e) {
-            reportError(ERROR, new ErrorMsg(e));
+            reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
     }
 
@@ -430,7 +430,7 @@
         }
         catch (IOException e) {
             if (_xsltc.debug()) e.printStackTrace();
-            reportError(ERROR,new ErrorMsg(e));
+            reportError(ERROR,new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         catch (SAXException e) {
             Throwable ex = e.getException();
@@ -438,15 +438,15 @@
                 e.printStackTrace();
                 if (ex != null) ex.printStackTrace();
             }
-            reportError(ERROR, new ErrorMsg(e));
+            reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         catch (CompilerException e) {
             if (_xsltc.debug()) e.printStackTrace();
-            reportError(ERROR, new ErrorMsg(e));
+            reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         catch (Exception e) {
             if (_xsltc.debug()) e.printStackTrace();
-            reportError(ERROR, new ErrorMsg(e));
+            reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         return null;
     }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Fri Sep 27 15:40:15 2013 +0100
@@ -41,10 +41,12 @@
 import java.util.jar.Manifest;
 
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
@@ -278,7 +280,7 @@
             return compile(input, _className);
         }
         catch (IOException e) {
-            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
+            _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
             return false;
         }
     }
@@ -297,7 +299,7 @@
             return compile(input, name);
         }
         catch (IOException e) {
-            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
+            _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
             return false;
         }
     }
@@ -382,11 +384,11 @@
         }
         catch (Exception e) {
             /*if (_debug)*/ e.printStackTrace();
-            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
+            _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         catch (Error e) {
             if (_debug) e.printStackTrace();
-            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
+            _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
         }
         finally {
             _reader = null; // reset this here to be sure it is not re-used
@@ -594,7 +596,7 @@
      */
     public boolean setDestDirectory(String dstDirName) {
         final File dir = new File(dstDirName);
-        if (dir.exists() || dir.mkdirs()) {
+        if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
             _destDir = dir;
             return true;
         }
@@ -767,7 +769,7 @@
             String parentDir = outFile.getParent();
             if (parentDir != null) {
                 File parentFile = new File(parentDir);
-                if (!parentFile.exists())
+                if (!SecuritySupport.getFileExists(parentFile))
                     parentFile.mkdirs();
             }
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java	Fri Sep 27 15:40:15 2013 +0100
@@ -997,7 +997,12 @@
          "kilobytes.  This is usually caused by templates in a stylesheet " +
          "that are very large.  Try restructuring your stylesheet to use " +
          "smaller templates."
-        }
+        },
+
+         {ErrorMsg.DESERIALIZE_TRANSLET_ERR, "When Java security is enabled, " +
+                        "support for deserializing TemplatesImpl is disabled." +
+                        "This can be overridden by setting the jdk.xml.enableTemplatesImplDeserialization" +
+                        " system property to true."}
 
     };
 
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,6 +23,7 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -46,6 +47,8 @@
     Object[] _params = null;
     private boolean _isWarningError;
 
+    Throwable _cause;
+
     // Compiler error messages
     public static final String MULTIPLE_STYLESHEET_ERR = "MULTIPLE_STYLESHEET_ERR";
     public static final String TEMPLATE_REDEF_ERR = "TEMPLATE_REDEF_ERR";
@@ -165,6 +168,8 @@
     public static final String OUTLINE_ERR_METHOD_TOO_BIG =
                                             "OUTLINE_ERR_METHOD_TOO_BIG";
 
+    public static final String DESERIALIZE_TRANSLET_ERR = "DESERIALIZE_TEMPLATES_ERR";
+
     // All error messages are localized and are stored in resource bundles.
     // This array and the following 4 strings are read from that bundle.
     private static ResourceBundle _bundle;
@@ -175,7 +180,7 @@
     public final static String RUNTIME_ERROR_KEY    = "RUNTIME_ERROR_KEY";
 
     static {
-        _bundle = ResourceBundle.getBundle(
+        _bundle = SecuritySupport.getResourceBundle(
                           "com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMessages",
                           Locale.getDefault());
     }
@@ -185,10 +190,11 @@
         _line = 0;
     }
 
-    public ErrorMsg(Throwable e) {
-        _code = null;
+    public ErrorMsg(String code, Throwable e) {
+        _code = code;
         _message = e.getMessage();
         _line = 0;
+        _cause = e;
     }
 
     public ErrorMsg(String message, int line) {
@@ -240,6 +246,10 @@
         _params[1] = param2;
     }
 
+    public Throwable getCause() {
+        return _cause;
+    }
+
     private String getFileName(SyntaxTreeNode node) {
         Stylesheet stylesheet = node.getStylesheet();
         if (stylesheet != null)
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.StringTokenizer;
 
 import com.sun.org.apache.bcel.internal.generic.Type;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
 
@@ -37,7 +38,7 @@
     private static char filesep;
 
     static {
-        String temp = System.getProperty("file.separator", "/");
+        String temp = SecuritySupport.getSystemProperty("file.separator", "/");
         filesep = temp.charAt(0);
     }
 
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java	Fri Sep 27 15:40:15 2013 +0100
@@ -33,6 +33,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
 import com.sun.org.apache.xml.internal.utils.StringComparable;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 /**
  * Base class for sort records containing application specific sort keys
@@ -112,7 +113,7 @@
         try {
             // -- W. Eliot Kimber (eliot@isogen.com)
             colFactClassname =
-                System.getProperty("com.sun.org.apache.xalan.internal.xsltc.COLLATOR_FACTORY");
+                SecuritySupport.getSystemProperty("com.sun.org.apache.xalan.internal.xsltc.COLLATOR_FACTORY");
         }
         catch (SecurityException e) {
             // If we can't read the propery, just use default collator
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,6 +23,7 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.runtime;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.FieldPosition;
@@ -1583,7 +1584,7 @@
 
     static {
         String resource = "com.sun.org.apache.xalan.internal.xsltc.runtime.ErrorMessages";
-        m_bundle = ResourceBundle.getBundle(resource);
+        m_bundle = SecuritySupport.getResourceBundle(resource);
     }
 
     /**
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,6 +23,7 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.runtime.output;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.Writer;
@@ -36,7 +37,7 @@
 
     static {
         // Set a larger buffer size for Solaris
-        final String osName = System.getProperty("os.name");
+        final String osName = SecuritySupport.getSystemProperty("os.name");
         if (osName.equalsIgnoreCase("solaris")) {
             BUFFER_SIZE = 32 * KB;
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Fri Sep 27 15:40:15 2013 +0100
@@ -43,6 +43,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 /**
  * @author Morten Jorgensen
@@ -52,6 +53,8 @@
  */
 public final class TemplatesImpl implements Templates, Serializable {
     static final long serialVersionUID = 673094361519270707L;
+    public final static String DESERIALIZE_TRANSLET = "jdk.xml.enableTemplatesImplDeserialization";
+
     /**
      * Name of the superclass of all translets. This is needed to
      * determine which, among all classes comprising a translet,
@@ -186,6 +189,15 @@
     private void  readObject(ObjectInputStream is)
       throws IOException, ClassNotFoundException
     {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null){
+            String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
+            if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
+                ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
+                throw new UnsupportedOperationException(err.toString());
+            }
+        }
+
         is.defaultReadObject();
         if (is.readBoolean()) {
             _uriResolver = (URIResolver) is.readObject();
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Fri Sep 27 15:40:15 2013 +0100
@@ -73,7 +73,7 @@
 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;
@@ -881,8 +881,14 @@
         // Check that the transformation went well before returning
     if (bytecodes == null) {
 
-        ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
-        TransformerConfigurationException exc =  new TransformerConfigurationException(err.toString());
+        Vector errs = xsltc.getErrors();
+        ErrorMsg err = null;
+        if (errs != null) {
+            err = (ErrorMsg)errs.get(errs.size()-1);
+        } else {
+            err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
+        }
+        TransformerConfigurationException exc =  new TransformerConfigurationException(err.toString(), err.getCause());
 
         // Pass compiler errors to the error listener
         if (_errorListener != null) {
@@ -1229,7 +1235,7 @@
         // Find the parent directory of the translet.
         String transletParentDir = transletFile.getParent();
         if (transletParentDir == null)
-            transletParentDir = System.getProperty("user.dir");
+            transletParentDir = SecuritySupport.getSystemProperty("user.dir");
 
         File transletParentFile = new File(transletParentDir);
 
--- a/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,10 +20,10 @@
 
 
 package com.sun.org.apache.xerces.internal.dom;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
 
 /**
  * Used to format DOM error messages, using the system locale.
@@ -31,6 +31,7 @@
  * @xerces.internal
  *
  * @author Sandy Gao, IBM
+ * @version $Id: DOMMessageFormatter.java,v 1.6 2010-11-01 04:39:38 joehw Exp $
  */
 public class DOMMessageFormatter {
     public static final String DOM_DOMAIN = "http://www.w3.org/dom/DOMTR";
@@ -122,13 +123,13 @@
      */
     public static void init(){
         if (locale != null) {
-            domResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
-            serResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
-            xmlResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+            domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
+            serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
+            xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
         }else{
-            domResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
-            serResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
-            xmlResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+            domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
+            serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
+            xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
     }
 
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Fri Sep 27 15:40:15 2013 +0100
@@ -51,6 +51,7 @@
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.parser.*;
 import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.xml.internal.stream.Entity;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 
@@ -1727,7 +1728,7 @@
         // get the user.dir property
         String userDir = "";
         try {
-            userDir = System.getProperty("user.dir");
+            userDir = SecuritySupport.getSystemProperty("user.dir");
         }
         catch (SecurityException se) {
         }
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,6 +20,7 @@
 
 package com.sun.org.apache.xerces.internal.impl.dv;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.ResourceBundle;
 import java.util.PropertyResourceBundle;
 import java.util.MissingResourceException;
@@ -34,6 +35,7 @@
  *
  * @author Sandy Gao, IBM
  *
+ * @version $Id: DatatypeException.java,v 1.6 2010-11-01 04:39:43 joehw Exp $
  */
 public class DatatypeException extends Exception {
 
@@ -84,7 +86,7 @@
      */
     public String getMessage() {
         ResourceBundle resourceBundle = null;
-        resourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
+        resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
         if (resourceBundle == null)
             throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,12 +20,11 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +33,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter.java 3020 2011-02-28 23:51:33Z joehw $
+ * @version $Id: XMLMessageFormatter.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter implements MessageFormatter {
@@ -72,12 +71,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_de.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_de.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_de implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_es.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_es.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_es implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_fr.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_fr.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_fr implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_it.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_it.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_it implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_ja.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_ja.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_ja implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_ko.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_ko.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_ko implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_pt_BR.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_pt_BR.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_pt_BR implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_sv.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_sv.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_sv implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_zh_CN.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_zh_CN.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_zh_CN implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java	Fri Sep 27 15:40:15 2013 +0100
@@ -26,6 +26,7 @@
 import java.util.PropertyResourceBundle;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@@ -34,7 +35,7 @@
  * @xerces.internal
  *
  * @author Eric Ye, IBM
- * @version $Id: XMLMessageFormatter_zh_TW.java 3021 2011-03-01 00:12:28Z joehw $
+ * @version $Id: XMLMessageFormatter_zh_TW.java 3094 2012-03-21 05:50:01Z joehw $
  *
  */
 public class XMLMessageFormatter_zh_TW implements MessageFormatter {
@@ -72,12 +73,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,6 +20,7 @@
 
 package com.sun.org.apache.xerces.internal.impl.xpath.regex;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -95,10 +96,10 @@
     public void setLocale(Locale locale) {
         try {
             if (locale != null) {
-                this.resources = ResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
+                this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
             }
             else {
-                this.resources = ResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
+                this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
             }
         }
         catch (MissingResourceException mre) {
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,11 +20,11 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 
 
 /**
@@ -34,6 +34,7 @@
  * @xerces.internal
  *
  * @author Elena Litani, IBM
+ * @version $Id: XSMessageFormatter.java,v 1.6 2010-11-01 04:39:55 joehw Exp $
  */
 public class XSMessageFormatter implements MessageFormatter {
     /**
@@ -66,12 +67,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
         }
 
         String msg = fResourceBundle.getString(key);
--- a/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,15 +20,16 @@
 
 package com.sun.org.apache.xerces.internal.jaxp.validation;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
 
 /**
  * <p>Used to format JAXP Validation API error messages using a specified locale.</p>
  *
  * @author Michael Glavassevich, IBM
+ * @version $Id: JAXPValidationMessageFormatter.java,v 1.5 2010-11-01 04:40:08 joehw Exp $
  */
 final class JAXPValidationMessageFormatter {
 
@@ -54,11 +55,11 @@
         ResourceBundle resourceBundle = null;
         if (locale != null) {
             resourceBundle =
-                PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages", locale);
+                SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages", locale);
         }
         else {
             resourceBundle =
-                PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages");
+                SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,15 +20,16 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 
 /**
  * <p>Used to format JAXP 1.3 Datatype API error messages using a specified locale.</p>
  *
  * @author  Neeraj Bajaj, Sun Microsystems
+ * @version $Id: DatatypeMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $
  */
 public class DatatypeMessageFormatter {
 
@@ -56,11 +57,11 @@
         ResourceBundle resourceBundle = null;
         if (locale != null) {
             resourceBundle =
-                PropertyResourceBundle.getBundle(BASE_NAME, locale);
+                SecuritySupport.getResourceBundle(BASE_NAME, locale);
         }
         else {
             resourceBundle =
-                PropertyResourceBundle.getBundle(BASE_NAME);
+                SecuritySupport.getResourceBundle(BASE_NAME);
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -19,16 +19,17 @@
  */
 package com.sun.org.apache.xerces.internal.util;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
 
 /**
  * Used to format SAX error messages using a specified locale.
  *
  * @author Michael Glavassevich, IBM
  *
+ * @version $Id: SAXMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $
  */
 public class SAXMessageFormatter {
 
@@ -54,11 +55,11 @@
         ResourceBundle resourceBundle = null;
         if (locale != null) {
             resourceBundle =
-                PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages", locale);
+                SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages", locale);
         }
         else {
             resourceBundle =
-                PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages");
+                SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages");
         }
 
         // format message
--- a/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java	Fri Sep 27 15:40:15 2013 +0100
@@ -61,6 +61,8 @@
 
 package com.sun.org.apache.xerces.internal.util;
 import com.sun.org.apache.xerces.internal.impl.Constants;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 /**
  * This class is a container for parser settings that relate to
  * security, or more specifically, it is intended to be used to prevent denial-of-service
@@ -77,6 +79,7 @@
  *
  * @author  Neil Graham, IBM
  *
+ * @version $Id: SecurityManager.java,v 1.5 2010-11-01 04:40:14 joehw Exp $
  */
 public final class SecurityManager {
 
@@ -176,41 +179,48 @@
 
         private void readSystemProperties(){
 
-                //TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
-                try {
-                        String value = System.getProperty(Constants.ENTITY_EXPANSION_LIMIT);
-                        if(value != null && !value.equals("")){
-                                entityExpansionLimit = Integer.parseInt(value);
-                                if (entityExpansionLimit < 0)
-                                        entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
-                        }
-                        else
-                                entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
-                }catch(Exception ex){}
+            //TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
+            try {
+                    String value = getSystemProperty(Constants.ENTITY_EXPANSION_LIMIT);
+                    if(value != null && !value.equals("")){
+                            entityExpansionLimit = Integer.parseInt(value);
+                            if (entityExpansionLimit < 0)
+                                    entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
+                    }
+                    else
+                            entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
+            }catch(Exception ex){}
 
-                try {
-                        String value = System.getProperty(Constants.MAX_OCCUR_LIMIT);
-                        if(value != null && !value.equals("")){
-                                maxOccurLimit = Integer.parseInt(value);
-                                if (maxOccurLimit < 0)
-                                        maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
-                        }
-                        else
-                                maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
-                }catch(Exception ex){}
+            try {
+                    String value = getSystemProperty(Constants.MAX_OCCUR_LIMIT);
+                    if(value != null && !value.equals("")){
+                            maxOccurLimit = Integer.parseInt(value);
+                            if (maxOccurLimit < 0)
+                                    maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
+                    }
+                    else
+                            maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
+            }catch(Exception ex){}
 
-                try {
-                        String value = System.getProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
-                        if(value != null && !value.equals("")){
-                                fElementAttributeLimit = Integer.parseInt(value);
-                                if ( fElementAttributeLimit < 0)
-                                        fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
-                        }
-                        else
-                                fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
+            try {
+                    String value = getSystemProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
+                    if(value != null && !value.equals("")){
+                            fElementAttributeLimit = Integer.parseInt(value);
+                            if ( fElementAttributeLimit < 0)
+                                    fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
+                    }
+                    else
+                            fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
 
                 }catch(Exception ex){}
 
         }
 
+    private String getSystemProperty(final String propName) {
+        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+            public String run() {
+                return System.getProperty(propName);
+            }
+        });
+    }
 } // class SecurityManager
--- a/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -48,6 +48,7 @@
     //
     // Constants
     //
+    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";
@@ -305,10 +306,14 @@
         //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);
+            if (className.startsWith(DEFAULT_INTERNAL_CLASSES)) {
+                cl = null;
+            } else {
+                final int lastDot = className.lastIndexOf(".");
+                String packageName = className;
+                if (lastDot != -1) packageName = className.substring(0, lastDot);
+                security.checkPackageAccess(packageName);
+            }
         }
         Class providerClass;
         if (cl == null) {
--- a/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java	Fri Sep 27 15:40:15 2013 +0100
@@ -29,6 +29,10 @@
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
 
 /**
  * This class is duplicated for each subpackage so keep it in sync.
@@ -141,6 +145,38 @@
         });
     }
 
+    /**
+     * Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
+     * @param bundle the base name of the resource bundle, a fully qualified class name
+     * @return a resource bundle for the given base name and the default locale
+     */
+    public static ResourceBundle getResourceBundle(String bundle) {
+        return getResourceBundle(bundle, Locale.getDefault());
+    }
+
+    /**
+     * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
+     * @param bundle the base name of the resource bundle, a fully qualified class name
+     * @param locale the locale for which a resource bundle is desired
+     * @return a resource bundle for the given base name and locale
+     */
+    public static ResourceBundle getResourceBundle(final String bundle, final Locale locale) {
+        return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
+            public ResourceBundle run() {
+                try {
+                    return PropertyResourceBundle.getBundle(bundle, locale);
+                } catch (MissingResourceException e) {
+                    try {
+                        return PropertyResourceBundle.getBundle(bundle, new Locale("en", "US"));
+                    } catch (MissingResourceException e2) {
+                        throw new MissingResourceException(
+                                "Could not load any resource bundle by " + bundle, bundle, "");
+                    }
+                }
+            }
+        });
+    }
+
     static boolean getFileExists(final File f) {
         return ((Boolean)
                 AccessController.doPrivileged(new PrivilegedAction() {
--- a/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -20,11 +20,11 @@
 
 package com.sun.org.apache.xerces.internal.xinclude;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 
 // TODO: fix error messages in XIncludeMessages.properties
 /**
@@ -32,6 +32,7 @@
  *
  * @author Peter McCracken, IBM
  *
+ * @version $Id: XIncludeMessageFormatter.java,v 1.7 2010-11-01 04:40:18 joehw Exp $
  */
 public class XIncludeMessageFormatter implements MessageFormatter {
 
@@ -61,12 +62,12 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
         }
 
         String msg = fResourceBundle.getString(key);
--- a/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,6 +24,7 @@
 import java.util.ResourceBundle;
 import java.util.PropertyResourceBundle;
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * XPointerMessageFormatter provides error messages for the XPointer Framework
@@ -31,6 +32,7 @@
  *
  * @xerces.internal
  *
+ * @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $
  */
 class XPointerMessageFormatter implements MessageFormatter {
 
@@ -64,14 +66,14 @@
 
         if (fResourceBundle == null || locale != fLocale) {
             if (locale != null) {
-                fResourceBundle = PropertyResourceBundle.getBundle(
+                fResourceBundle = SecuritySupport.getResourceBundle(
                         "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
                 // memorize the most-recent locale
                 fLocale = locale;
             }
             if (fResourceBundle == null)
-                fResourceBundle = PropertyResourceBundle
-                        .getBundle("com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
+                fResourceBundle = SecuritySupport.getResourceBundle(
+                        "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
         }
 
         String msg = fResourceBundle.getString(key);
--- a/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java	Fri Sep 27 15:40:15 2013 +0100
@@ -27,6 +27,7 @@
 import com.sun.org.apache.xml.internal.utils.PrefixResolver;
 import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 
 /**
  * A DTMManager instance can be used to create DTM and
@@ -383,7 +384,7 @@
   {
     try
     {
-      debug = System.getProperty("dtm.debug") != null;
+      debug = SecuritySupport.getSystemProperty("dtm.debug") != null;
     }
     catch (SecurityException ex){}
   }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ca.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ca.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -443,67 +440,4 @@
     return _contents;
   }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("ca", "ES"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_cs.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_cs.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -443,67 +440,4 @@
     return _contents;
   }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("cs", "CZ"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_de.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_de.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_es.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_es.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_fr.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_fr.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_it.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_it.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ja.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ja.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_pt_BR.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_pt_BR.java	Fri Sep 27 15:40:15 2013 +0100
@@ -25,9 +25,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -463,67 +460,4 @@
         return msgCopy;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_sk.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_sk.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -443,67 +440,4 @@
     return _contents;
   }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_sv.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_sv.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -452,68 +449,4 @@
     protected Object[][] getContents() {
         return _contents;
     }
-
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_tr.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_tr.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -443,67 +440,4 @@
     return _contents;
   }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("tr", "TR"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_CN.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_CN.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_TW.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_zh_TW.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -453,67 +450,4 @@
         return _contents;
     }
 
-  /**
-   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   *   of ResourceBundle.getBundle().
-   *
-   *   @param className the name of the class that implements the resource bundle.
-   *   @return the ResourceBundle
-   *   @throws MissingResourceException
-   */
-  public static final XMLErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XMLErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XMLErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xml/internal/res/XMLMessages.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLMessages.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,10 +22,9 @@
  */
 package com.sun.org.apache.xml.internal.res;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.util.ListResourceBundle;
 import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * A utility class for issuing XML error messages.
@@ -82,8 +81,9 @@
    */
   public static final String createXMLMessage(String msgKey, Object args[])
   {
-    if (XMLBundle == null)
-      XMLBundle = loadResourceBundle(XML_ERROR_RESOURCES);
+    if (XMLBundle == null) {
+        XMLBundle = SecuritySupport.getResourceBundle(XML_ERROR_RESOURCES);
+    }
 
     if (XMLBundle != null)
     {
@@ -156,61 +156,4 @@
     return fmsg;
   }
 
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className The class name of the resource bundle.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static ListResourceBundle loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-    Locale locale = Locale.getDefault();
-
-    try
-    {
-      return (ListResourceBundle)ResourceBundle.getBundle(className, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (ListResourceBundle)ResourceBundle.getBundle(
-          className, new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles." + className, className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which can be appended to a resource name
-   */
-  protected static String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
 }
--- a/src/com/sun/org/apache/xml/internal/resolver/Catalog.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/Catalog.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,6 +24,7 @@
 package com.sun.org.apache.xml.internal.resolver;
 
 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
@@ -821,7 +822,7 @@
       // tack on a basename because URLs point to files not dirs
       catalogCwd = FileURL.makeURL("basename");
     } catch (MalformedURLException e) {
-      String userdir = System.getProperty("user.dir");
+      String userdir = SecuritySupport.getSystemProperty("user.dir");
       userdir.replace('\\', '/');
       catalogManager.debug.message(1, "Malformed URL on cwd", userdir);
       catalogCwd = null;
@@ -1717,7 +1718,7 @@
   protected String resolveLocalSystem(String systemId)
     throws MalformedURLException, IOException {
 
-    String osname = System.getProperty("os.name");
+    String osname = SecuritySupport.getSystemProperty("os.name");
     boolean windows = (osname.indexOf("Windows") >= 0);
     Enumeration en = catalogEntries.elements();
     while (en.hasMoreElements()) {
--- a/src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/CatalogManager.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,6 +23,7 @@
 
 package com.sun.org.apache.xml.internal.resolver;
 
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.InputStream;
 
 import java.net.URL;
@@ -142,8 +143,8 @@
 
   /** Flag to ignore missing property files and/or properties */
   private boolean ignoreMissingProperties
-    = (System.getProperty(pIgnoreMissing) != null
-       || System.getProperty(pFiles) != null);
+    = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
+       || SecuritySupport.getSystemProperty(pFiles) != null);
 
   /** Holds the resources after they are loaded from the file. */
   private ResourceBundle resources;
@@ -338,7 +339,7 @@
   private int queryVerbosity () {
     String defaultVerbStr = Integer.toString(defaultVerbosity);
 
-    String verbStr = System.getProperty(pVerbosity);
+    String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
 
     if (verbStr == null) {
       if (resources==null) readProperties();
@@ -473,7 +474,7 @@
    * @return A semicolon delimited list of catlog file URIs
    */
   private String queryCatalogFiles () {
-    String catalogList = System.getProperty(pFiles);
+    String catalogList = SecuritySupport.getSystemProperty(pFiles);
     fromPropertiesFile = false;
 
     if (catalogList == null) {
@@ -558,7 +559,7 @@
    * defaultPreferSetting.
    */
   private boolean queryPreferPublic () {
-    String prefer = System.getProperty(pPrefer);
+    String prefer = SecuritySupport.getSystemProperty(pPrefer);
 
     if (prefer == null) {
       if (resources==null) readProperties();
@@ -617,7 +618,7 @@
    * defaultUseStaticCatalog.
    */
   private boolean queryUseStaticCatalog () {
-    String staticCatalog = System.getProperty(pStatic);
+    String staticCatalog = SecuritySupport.getSystemProperty(pStatic);
 
     if (staticCatalog == null) {
       if (resources==null) readProperties();
@@ -748,7 +749,7 @@
    * defaultOasisXMLCatalogPI.
    */
   public boolean queryAllowOasisXMLCatalogPI () {
-    String allow = System.getProperty(pAllowPI);
+    String allow = SecuritySupport.getSystemProperty(pAllowPI);
 
     if (allow == null) {
       if (resources==null) readProperties();
@@ -804,7 +805,7 @@
    *
    */
   public String queryCatalogClassName () {
-    String className = System.getProperty(pClassname);
+    String className = SecuritySupport.getSystemProperty(pClassname);
 
     if (className == null) {
       if (resources==null) readProperties();
--- a/src/com/sun/org/apache/xml/internal/resolver/Resolver.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/Resolver.java	Fri Sep 27 15:40:15 2013 +0100
@@ -33,6 +33,7 @@
 import java.net.MalformedURLException;
 import javax.xml.parsers.SAXParserFactory;
 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
 import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
 import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
@@ -524,7 +525,7 @@
      */
     private Vector resolveAllLocalSystem(String systemId) {
         Vector map = new Vector();
-        String osname = System.getProperty("os.name");
+        String osname = SecuritySupport.getSystemProperty("os.name");
         boolean windows = (osname.indexOf("Windows") >= 0);
         Enumeration en = catalogEntries.elements();
         while (en.hasMoreElements()) {
@@ -552,7 +553,7 @@
      */
     private Vector resolveLocalSystemReverse(String systemId) {
         Vector map = new Vector();
-        String osname = System.getProperty("os.name");
+        String osname = SecuritySupport.getSystemProperty("os.name");
         boolean windows = (osname.indexOf("Windows") >= 0);
         Enumeration en = catalogEntries.elements();
         while (en.hasMoreElements()) {
--- a/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.OutputStream;
 import java.io.Writer;
 import java.io.UnsupportedEncodingException;
@@ -64,7 +65,7 @@
         factory =  new SerializerFactoryImpl( Method.TEXT );
         registerSerializerFactory( factory );
 
-        list = System.getProperty( FactoriesProperty );
+        list = SecuritySupport.getSystemProperty( FactoriesProperty );
         if ( list != null ) {
             token = new StringTokenizer( list, " ;,:" );
             while ( token.hasMoreTokens() ) {
--- a/src/com/sun/org/apache/xml/internal/serializer/Encodings.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/Encodings.java	Fri Sep 27 15:40:15 2013 +0100
@@ -219,7 +219,7 @@
                 // Get the default system character encoding.  This may be
                 // incorrect if they passed in a writer, but right now there
                 // seems to be no way to get the encoding from a writer.
-                encoding = System.getProperty("file.encoding", "UTF8");
+                encoding = SecuritySupport.getSystemProperty("file.encoding", "UTF8");
 
                 if (null != encoding)
                 {
@@ -313,7 +313,7 @@
 
             try
             {
-                urlString = System.getProperty(ENCODINGS_PROP, "");
+                urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
             }
             catch (SecurityException e)
             {
--- a/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -471,7 +472,7 @@
             String value = null;
             try
             {
-                value = System.getProperty(key);
+                value = SecuritySupport.getSystemProperty(key);
             }
             catch (SecurityException se)
             {
@@ -484,7 +485,7 @@
             String newValue = null;
             try
             {
-                newValue = System.getProperty(newKey);
+                newValue = SecuritySupport.getSystemProperty(newKey);
             }
             catch (SecurityException se)
             {
--- a/src/com/sun/org/apache/xml/internal/serializer/ToStream.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/ToStream.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
@@ -140,7 +141,7 @@
      * extension attribute xalan:line-separator.
      */
     protected char[] m_lineSep =
-        System.getProperty("line.separator").toCharArray();
+        SecuritySupport.getSystemProperty("line.separator").toCharArray();
 
     /**
      * True if the the system line separator is to be used.
--- a/src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.File;
 
 import com.sun.org.apache.xml.internal.serializer.utils.AttList;
@@ -104,7 +105,7 @@
       else {
           try {
             // Bug see Bugzilla  26741
-            m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
+            m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
            }
            catch (SecurityException se) {// user.dir not accessible from applet
            }
@@ -115,7 +116,7 @@
                         m_contentHandler.setDocumentLocator(m_locator);
                 try {
                    // Bug see Bugzilla  26741
-                  m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
+                  m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
                 }
                 catch (SecurityException se){// user.dir not accessible from applet
 
--- a/src/com/sun/org/apache/xml/internal/serializer/utils/Messages.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/utils/Messages.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer.utils;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.util.ListResourceBundle;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -87,9 +88,6 @@
  * can have the Message strings translated in an alternate language
  * in a errorResourceClass with a language suffix.
  *
- * More sophisticated use of this class would be to pass null
- * when contructing it, but then call loadResourceBundle()
- * before creating any messages.
  *
  * This class is not a public API, it is only public because it is
  * used in com.sun.org.apache.xml.internal.serializer.
@@ -126,18 +124,6 @@
         m_resourceBundleName = resourceBundle;
     }
 
-    /*
-     * Set the Locale object to use. If this method is not called the
-     * default locale is used. This method needs to be called before
-     * loadResourceBundle().
-     *
-     * @param locale non-null reference to Locale object.
-     * @xsl.usage internal
-     */
-//    public void setLocale(Locale locale)
-//    {
-//        m_locale = locale;
-//    }
 
     /**
      * Get the Locale object that is being used.
@@ -151,16 +137,6 @@
     }
 
     /**
-     * Get the ListResourceBundle being used by this Messages instance which was
-     * previously set by a call to loadResourceBundle(className)
-     * @xsl.usage internal
-     */
-    private ListResourceBundle getResourceBundle()
-    {
-        return m_resourceBundle;
-    }
-
-    /**
      * Creates a message from the specified key and replacement
      * arguments, localized to the given locale.
      *
@@ -174,7 +150,7 @@
     public final String createMessage(String msgKey, Object args[])
     {
         if (m_resourceBundle == null)
-            m_resourceBundle = loadResourceBundle(m_resourceBundleName);
+            m_resourceBundle = SecuritySupport.getResourceBundle(m_resourceBundleName);
 
         if (m_resourceBundle != null)
         {
@@ -293,76 +269,4 @@
         return fmsg;
     }
 
-    /**
-     * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-     * of ResourceBundle.getBundle().
-     *
-     * @param className the name of the class that implements ListResourceBundle,
-     * without language suffix.
-     * @return the ResourceBundle
-     * @throws MissingResourceException
-     * @xsl.usage internal
-     */
-    private ListResourceBundle loadResourceBundle(String resourceBundle)
-        throws MissingResourceException
-    {
-        m_resourceBundleName = resourceBundle;
-        Locale locale = getLocale();
-
-        ListResourceBundle lrb;
-
-        try
-        {
-
-            ResourceBundle rb =
-                ResourceBundle.getBundle(m_resourceBundleName, locale);
-            lrb = (ListResourceBundle) rb;
-        }
-        catch (MissingResourceException e)
-        {
-            try // try to fall back to en_US if we can't load
-                {
-
-                // Since we can't find the localized property file,
-                // fall back to en_US.
-                lrb =
-                    (ListResourceBundle) ResourceBundle.getBundle(
-                        m_resourceBundleName,
-                        new Locale("en", "US"));
-            }
-            catch (MissingResourceException e2)
-            {
-
-                // Now we are really in trouble.
-                // very bad, definitely very bad...not going to get very far
-                throw new MissingResourceException(
-                    "Could not load any resource bundles." + m_resourceBundleName,
-                    m_resourceBundleName,
-                    "");
-            }
-        }
-        m_resourceBundle = lrb;
-        return lrb;
-    }
-
-    /**
-     * Return the resource file suffic for the indicated locale
-     * For most locales, this will be based the language code.  However
-     * for Chinese, we do distinguish between Taiwan and PRC
-     *
-     * @param locale the locale
-     * @return an String suffix which can be appended to a resource name
-     * @xsl.usage internal
-     */
-    private static String getResourceSuffix(Locale locale)
-    {
-
-        String suffix = "_" + locale.getLanguage();
-        String country = locale.getCountry();
-
-        if (country.equals("TW"))
-            suffix += "_" + country;
-
-        return suffix;
-    }
 }
--- a/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.utils;
 
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.File;
 
 import org.w3c.dom.Comment;
@@ -93,7 +94,7 @@
     else {
         try {
           // Bug see Bugzilla  26741
-          m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
+          m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
          }
          catch (SecurityException se) {// user.dir not accessible from applet
          }
@@ -112,7 +113,7 @@
     m_contentHandler.setDocumentLocator(m_locator);
     try {
        // Bug see Bugzilla  26741
-      m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
+      m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
     }
     catch (SecurityException se){// user.dir not accessible from applet
     }
@@ -131,7 +132,7 @@
                         m_contentHandler.setDocumentLocator(m_locator);
                 try {
                    // Bug see Bugzilla  26741
-                  m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
+                  m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
                 }
                 catch (SecurityException se){// user.dir not accessible from applet
 
--- a/src/com/sun/org/apache/xml/internal/utils/res/XResourceBundle.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xml/internal/utils/res/XResourceBundle.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,6 +22,8 @@
  */
 package com.sun.org.apache.xml.internal.utils.res;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ListResourceBundle;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -29,114 +31,45 @@
 
 /**
  * The default (english) resource bundle.
+ *
  * @xsl.usage internal
  */
-public class XResourceBundle extends ListResourceBundle
-{
-
-  /** Error resource constants */
-  public static final String ERROR_RESOURCES =
-    "com.sun.org.apache.xalan.internal.res.XSLTErrorResources", XSLT_RESOURCE =
-    "com.sun.org.apache.xml.internal.utils.res.XResourceBundle", LANG_BUNDLE_NAME =
-    "com.sun.org.apache.xml.internal.utils.res.XResources", MULT_ORDER =
-    "multiplierOrder", MULT_PRECEDES = "precedes", MULT_FOLLOWS =
-    "follows", LANG_ORIENTATION = "orientation", LANG_RIGHTTOLEFT =
-    "rightToLeft", LANG_LEFTTORIGHT = "leftToRight", LANG_NUMBERING =
-    "numbering", LANG_ADDITIVE = "additive", LANG_MULT_ADD =
-    "multiplicative-additive", LANG_MULTIPLIER =
-    "multiplier", LANG_MULTIPLIER_CHAR =
-    "multiplierChar", LANG_NUMBERGROUPS = "numberGroups", LANG_NUM_TABLES =
-    "tables", LANG_ALPHABET = "alphabet", LANG_TRAD_ALPHABET = "tradAlphabet";
+public class XResourceBundle extends ListResourceBundle {
 
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @param locale the locale to prefer when searching for the bundle
-   */
-  public static final XResourceBundle loadResourceBundle(
-          String className, Locale locale) throws MissingResourceException
-  {
-
-    String suffix = getResourceSuffix(locale);
-
-    //System.out.println("resource " + className + suffix);
-    try
-    {
+    /**
+     * Error resource constants
+     */
+    public static final String ERROR_RESOURCES =
+            "com.sun.org.apache.xalan.internal.res.XSLTErrorResources", XSLT_RESOURCE =
+            "com.sun.org.apache.xml.internal.utils.res.XResourceBundle", LANG_BUNDLE_NAME =
+            "com.sun.org.apache.xml.internal.utils.res.XResources", MULT_ORDER =
+            "multiplierOrder", MULT_PRECEDES = "precedes", MULT_FOLLOWS =
+            "follows", LANG_ORIENTATION = "orientation", LANG_RIGHTTOLEFT =
+            "rightToLeft", LANG_LEFTTORIGHT = "leftToRight", LANG_NUMBERING =
+            "numbering", LANG_ADDITIVE = "additive", LANG_MULT_ADD =
+            "multiplicative-additive", LANG_MULTIPLIER =
+            "multiplier", LANG_MULTIPLIER_CHAR =
+            "multiplierChar", LANG_NUMBERGROUPS = "numberGroups", LANG_NUM_TABLES =
+            "tables", LANG_ALPHABET = "alphabet", LANG_TRAD_ALPHABET = "tradAlphabet";
 
-      // first try with the given locale
-      String resourceName = className + suffix;
-      return (XResourceBundle) ResourceBundle.getBundle(resourceName, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XResourceBundle) ResourceBundle.getBundle(
-          XSLT_RESOURCE, new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
 
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
+    /**
+     * Get the association list.
+     *
+     * @return The association list.
+     */
+    public Object[][] getContents() {
+        return new Object[][]{
+                    {"ui_language", "en"}, {"help_language", "en"}, {"language", "en"},
+                    {"alphabet", new CharArrayWrapper(new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G',
+                            'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
+                            'V', 'W', 'X', 'Y', 'Z'})},
+                    {"tradAlphabet", new CharArrayWrapper(new char[]{'A', 'B', 'C', 'D', 'E', 'F',
+                            'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+                            'U', 'V', 'W', 'X', 'Y', 'Z'})},
+                    //language orientation
+                    {"orientation", "LeftToRight"},
+                    //language numbering
+                    {"numbering", "additive"},};
     }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String lang = locale.getLanguage();
-    String country = locale.getCountry();
-    String variant = locale.getVariant();
-    String suffix = "_" + locale.getLanguage();
-
-    if (lang.equals("zh"))
-      suffix += "_" + country;
-
-    if (country.equals("JP"))
-      suffix += "_" + country + "_" + variant;
-
-    return suffix;
-  }
-
-  /**
-   * Get the association list.
-   *
-   * @return The association list.
-   */
-  public Object[][] getContents()
-  {
-    return new Object[][]
-  {
-    { "ui_language", "en" }, { "help_language", "en" }, { "language", "en" },
-    { "alphabet", new CharArrayWrapper(new char[]{ 'A', 'B', 'C', 'D', 'E', 'F', 'G',
-         'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
-         'V', 'W', 'X', 'Y', 'Z' })},
-    { "tradAlphabet", new CharArrayWrapper(new char[]{ 'A', 'B', 'C', 'D', 'E', 'F',
-         'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
-         'U', 'V', 'W', 'X', 'Y', 'Z' }) },
-
-    //language orientation
-    { "orientation", "LeftToRight" },
-
-    //language numbering
-    { "numbering", "additive" },
-  };
-  }
 }
--- a/src/com/sun/org/apache/xpath/internal/functions/FuncSystemProperty.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/functions/FuncSystemProperty.java	Fri Sep 27 15:40:15 2013 +0100
@@ -102,7 +102,7 @@
 
         try
         {
-          result = System.getProperty(propName);
+          result = SecuritySupport.getSystemProperty(propName);
 
           if (null == result)
           {
@@ -124,7 +124,7 @@
     {
       try
       {
-        result = System.getProperty(fullName);
+        result = SecuritySupport.getSystemProperty(fullName);
 
         if (null == result)
         {
@@ -165,12 +165,11 @@
    * should already be fully qualified as path/filename
    * @param target The target property bag the file will be placed into.
    */
-  private void loadPropertyFile(String file, Properties target)
+  public void loadPropertyFile(String file, Properties target)
   {
     try
     {
       // Use SecuritySupport class to provide priveleged access to property file
-
       InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                               file);
 
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_es.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_es.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_fr.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_fr.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_it.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_it.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ja.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ja.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_pt_BR.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_pt_BR.java	Fri Sep 27 15:40:15 2013 +0100
@@ -24,9 +24,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -940,68 +937,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_sv.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_sv.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_CN.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_CN.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_TW.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_zh_TW.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,9 +23,6 @@
 package com.sun.org.apache.xpath.internal.res;
 
 import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * Set up error messages.
@@ -939,68 +936,4 @@
   /** Field QUERY_HEADER          */
   public static final String QUERY_HEADER = "PATTERN ";
 
-
-  /**
-   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
-   * of ResourceBundle.getBundle().
-   *
-   * @param className Name of local-specific subclass.
-   * @return the ResourceBundle
-   * @throws MissingResourceException
-   */
-  public static final XPATHErrorResources loadResourceBundle(String className)
-          throws MissingResourceException
-  {
-
-    Locale locale = Locale.getDefault();
-    String suffix = getResourceSuffix(locale);
-
-    try
-    {
-
-      // first try with the given locale
-      return (XPATHErrorResources) ResourceBundle.getBundle(className
-              + suffix, locale);
-    }
-    catch (MissingResourceException e)
-    {
-      try  // try to fall back to en_US if we can't load
-      {
-
-        // Since we can't find the localized property file,
-        // fall back to en_US.
-        return (XPATHErrorResources) ResourceBundle.getBundle(className,
-                new Locale("en", "US"));
-      }
-      catch (MissingResourceException e2)
-      {
-
-        // Now we are really in trouble.
-        // very bad, definitely very bad...not going to get very far
-        throw new MissingResourceException(
-          "Could not load any resource bundles.", className, "");
-      }
-    }
-  }
-
-  /**
-   * Return the resource file suffic for the indicated locale
-   * For most locales, this will be based the language code.  However
-   * for Chinese, we do distinguish between Taiwan and PRC
-   *
-   * @param locale the locale
-   * @return an String suffix which canbe appended to a resource name
-   */
-  private static final String getResourceSuffix(Locale locale)
-  {
-
-    String suffix = "_" + locale.getLanguage();
-    String country = locale.getCountry();
-
-    if (country.equals("TW"))
-      suffix += "_" + country;
-
-    return suffix;
-  }
-
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHMessages.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHMessages.java	Fri Sep 27 15:40:15 2013 +0100
@@ -22,130 +22,128 @@
  */
 package com.sun.org.apache.xpath.internal.res;
 
+import com.sun.org.apache.bcel.internal.util.SecuritySupport;
+import com.sun.org.apache.xml.internal.res.XMLMessages;
 import java.util.ListResourceBundle;
 
-import com.sun.org.apache.xml.internal.res.XMLMessages;
-
 /**
  * A utility class for issuing XPath error messages.
+ *
  * @xsl.usage internal
  */
-public class XPATHMessages extends XMLMessages
-{
-  /** The language specific resource object for XPath messages.  */
-  private static ListResourceBundle XPATHBundle = null;
+public class XPATHMessages extends XMLMessages {
 
-  /** The class name of the XPath error message string table.     */
-  private static final String XPATH_ERROR_RESOURCES =
-    "com.sun.org.apache.xpath.internal.res.XPATHErrorResources";
+    /**
+     * The language specific resource object for XPath messages.
+     */
+    private static ListResourceBundle XPATHBundle = null;
+    /**
+     * The class name of the XPath error message string table.
+     */
+    private static final String XPATH_ERROR_RESOURCES =
+            "com.sun.org.apache.xpath.internal.res.XPATHErrorResources";
 
-  /**
-   * Creates a message from the specified key and replacement
-   * arguments, localized to the given locale.
-   *
-   * @param msgKey    The key for the message text.
-   * @param args      The arguments to be used as replacement text
-   *                  in the message created.
-   *
-   * @return The formatted message string.
-   */
-  public static final String createXPATHMessage(String msgKey, Object args[])  //throws Exception
-  {
-    if (XPATHBundle == null)
-      XPATHBundle = loadResourceBundle(XPATH_ERROR_RESOURCES);
-
-    if (XPATHBundle != null)
+    /**
+     * Creates a message from the specified key and replacement arguments,
+     * localized to the given locale.
+     *
+     * @param msgKey The key for the message text.
+     * @param args The arguments to be used as replacement text in the message
+     * created.
+     *
+     * @return The formatted message string.
+     */
+    public static final String createXPATHMessage(String msgKey, Object args[]) //throws Exception
     {
-      return createXPATHMsg(XPATHBundle, msgKey, args);
-    }
-    else
-      return "Could not load any resource bundles.";
-  }
+        if (XPATHBundle == null) {
+            XPATHBundle = SecuritySupport.getResourceBundle(XPATH_ERROR_RESOURCES);
+        }
 
-  /**
-   * Creates a message from the specified key and replacement
-   * arguments, localized to the given locale.
-   *
-   * @param msgKey The key for the message text.
-   * @param args      The arguments to be used as replacement text
-   *                  in the message created.
-   *
-   * @return The formatted warning string.
-   */
-  public static final String createXPATHWarning(String msgKey, Object args[])  //throws Exception
-  {
-    if (XPATHBundle == null)
-      XPATHBundle = loadResourceBundle(XPATH_ERROR_RESOURCES);
-
-    if (XPATHBundle != null)
-    {
-      return createXPATHMsg(XPATHBundle, msgKey, args);
+        if (XPATHBundle != null) {
+            return createXPATHMsg(XPATHBundle, msgKey, args);
+        } else {
+            return "Could not load any resource bundles.";
+        }
     }
-    else
-      return "Could not load any resource bundles.";
-  }
 
-  /**
-   * Creates a message from the specified key and replacement
-   * arguments, localized to the given locale.
-   *
-   * @param fResourceBundle The resource bundle to use.
-   * @param msgKey  The message key to use.
-   * @param args      The arguments to be used as replacement text
-   *                  in the message created.
-   *
-   * @return The formatted message string.
-   */
-  public static final String createXPATHMsg(ListResourceBundle fResourceBundle,
-                                            String msgKey, Object args[])  //throws Exception
-  {
+    /**
+     * Creates a message from the specified key and replacement arguments,
+     * localized to the given locale.
+     *
+     * @param msgKey The key for the message text.
+     * @param args The arguments to be used as replacement text in the message
+     * created.
+     *
+     * @return The formatted warning string.
+     */
+    public static final String createXPATHWarning(String msgKey, Object args[]) //throws Exception
+    {
+        if (XPATHBundle == null) {
+            XPATHBundle = SecuritySupport.getResourceBundle(XPATH_ERROR_RESOURCES);
+        }
 
-    String fmsg = null;
-    boolean throwex = false;
-    String msg = null;
-
-    if (msgKey != null)
-      msg = fResourceBundle.getString(msgKey);
-
-    if (msg == null)
-    {
-      msg = fResourceBundle.getString(XPATHErrorResources.BAD_CODE);
-      throwex = true;
+        if (XPATHBundle != null) {
+            return createXPATHMsg(XPATHBundle, msgKey, args);
+        } else {
+            return "Could not load any resource bundles.";
+        }
     }
 
-    if (args != null)
+    /**
+     * Creates a message from the specified key and replacement arguments,
+     * localized to the given locale.
+     *
+     * @param fResourceBundle The resource bundle to use.
+     * @param msgKey The message key to use.
+     * @param args The arguments to be used as replacement text in the message
+     * created.
+     *
+     * @return The formatted message string.
+     */
+    public static final String createXPATHMsg(ListResourceBundle fResourceBundle,
+            String msgKey, Object args[]) //throws Exception
     {
-      try
-      {
 
-        // Do this to keep format from crying.
-        // This is better than making a bunch of conditional
-        // code all over the place.
-        int n = args.length;
+        String fmsg = null;
+        boolean throwex = false;
+        String msg = null;
 
-        for (int i = 0; i < n; i++)
-        {
-          if (null == args[i])
-            args[i] = "";
+        if (msgKey != null) {
+            msg = fResourceBundle.getString(msgKey);
+        }
+
+        if (msg == null) {
+            msg = fResourceBundle.getString(XPATHErrorResources.BAD_CODE);
+            throwex = true;
         }
 
-        fmsg = java.text.MessageFormat.format(msg, args);
-      }
-      catch (Exception e)
-      {
-        fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED);
-        fmsg += " " + msg;
-      }
+        if (args != null) {
+            try {
+
+                // Do this to keep format from crying.
+                // This is better than making a bunch of conditional
+                // code all over the place.
+                int n = args.length;
+
+                for (int i = 0; i < n; i++) {
+                    if (null == args[i]) {
+                        args[i] = "";
+                    }
+                }
+
+                fmsg = java.text.MessageFormat.format(msg, args);
+            } catch (Exception e) {
+                fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED);
+                fmsg += " " + msg;
+            }
+        } else {
+            fmsg = msg;
+        }
+
+        if (throwex) {
+            throw new RuntimeException(fmsg);
+        }
+
+        return fmsg;
     }
-    else
-      fmsg = msg;
-
-    if (throwex)
-    {
-      throw new RuntimeException(fmsg);
-    }
-
-    return fmsg;
-  }
-
 }
--- a/src/com/sun/xml/internal/stream/XMLEntityStorage.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/xml/internal/stream/XMLEntityStorage.java	Fri Sep 27 15:40:15 2013 +0100
@@ -36,6 +36,7 @@
 import com.sun.org.apache.xerces.internal.impl.PropertyManager;
 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
 import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Enumeration;
 
 /**
@@ -414,7 +415,7 @@
         // get the user.dir property
         String userDir = "";
         try {
-            userDir = System.getProperty("user.dir");
+            userDir = SecuritySupport.getSystemProperty("user.dir");
         }
         catch (SecurityException se) {
         }
--- a/src/com/sun/xml/internal/stream/writers/WriterUtility.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/xml/internal/stream/writers/WriterUtility.java	Fri Sep 27 15:40:15 2013 +0100
@@ -32,6 +32,7 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 
 /**
  * Implements common xml writer functions.
@@ -240,7 +241,7 @@
 
     private CharsetEncoder getDefaultEncoder(){
         try{
-            String encoding = System.getProperty("file.encoding");
+            String encoding = SecuritySupport.getSystemProperty("file.encoding");
             if(encoding != null){
                 return Charset.forName(encoding).newEncoder();
             }
--- a/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Fri Sep 27 15:40:15 2013 +0100
@@ -53,6 +53,7 @@
 import com.sun.org.apache.xerces.internal.impl.PropertyManager;
 import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.xni.QName;
 
 import com.sun.xml.internal.stream.util.ReadOnlyIterator;
@@ -340,7 +341,7 @@
                 fEncoder = Charset.forName(encoding).newEncoder();
             }
         } else {
-            encoding = System.getProperty("file.encoding");
+            encoding = SecuritySupport.getSystemProperty("file.encoding");
             if (encoding != null && encoding.equalsIgnoreCase("utf-8")) {
                 fWriter = new UTF8OutputStreamWriter(os);
             } else {
--- a/src/javax/xml/datatype/DatatypeFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/datatype/DatatypeFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
 
 package javax.xml.datatype;
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.math.BigDecimal;
 import java.util.GregorianCalendar;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -34,12 +34,12 @@
 /**
  * <p>Factory that creates new <code>javax.xml.datatype</code> <code>Object</code>s that map XML to/from Java <code>Object</code>s.</p>
  *
- * <p><a name="DatatypeFactory.newInstance"/>{@link #newInstance()} is used to create a new <code>DatatypeFactory</code>.
- * The following implementation resolution mechanisms are used in the following order:</p>
+ * <p>A new instance of the <code>DatatypeFactory</code> is created through the {@link #newInstance()} method
+ * that uses the following implementation resolution mechanisms to determine an implementation:</p>
  * <ol>
  *    <li>
  *      If the system property specified by {@link #DATATYPEFACTORY_PROPERTY}, "<code>javax.xml.datatype.DatatypeFactory</code>",
- *      exists, a class with the name of the property's value is instantiated.
+ *      exists, a class with the name of the property value is instantiated.
  *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
  *    </li>
  *    <li>
@@ -48,8 +48,12 @@
  *      and processed as documented in the prior step.
  *    </li>
  *    <li>
- *      The services resolution mechanism is used, e.g. <code>META-INF/services/java.xml.datatype.DatatypeFactory</code>.
- *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
+ *     Uses the service-provider loading facilities, defined by the {@link java.util.ServiceLoader} class, to attempt
+ *     to locate and load an implementation of the service.
+ *     <br>
+ *     In case of {@link java.util.ServiceConfigurationError service
+ *     configuration error} a {@link javax.xml.datatype.DatatypeConfigurationException}
+ *     will be thrown.
  *    </li>
  *    <li>
  *      The final mechanism is to attempt to instantiate the <code>Class</code> specified by
@@ -67,26 +71,33 @@
  */
 public abstract class DatatypeFactory {
 
-        /**
-         * <p>Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.</p>
-         *
-         * <p>Default value is <code>javax.xml.datatype.DatatypeFactory</code>.</p>
-         */
-        public static final String DATATYPEFACTORY_PROPERTY = "javax.xml.datatype.DatatypeFactory";
+    /**
+     * <p>Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.</p>
+     *
+     * <p>Default value is <code>javax.xml.datatype.DatatypeFactory</code>.</p>
+     */
+    public static final String DATATYPEFACTORY_PROPERTY =
+            // We use a String constant here, rather than calling
+            // DatatypeFactory.class.getName() - in order to make javadoc
+            // generate a See Also: Constant Field Value link.
+            "javax.xml.datatype.DatatypeFactory";
 
-        /**
-         * <p>Default implementation class name as defined in
-         * <em>JSR 206: Java(TM) API for XML Processing (JAXP) 1.3</em>.</p>
-         *
-         * <p>Implementers should specify the name of an appropriate class
-         * to be instantiated if no other implementation resolution mechanism
-         * succeeds.</p>
-         *
-         * <p>Users should not refer to this field; it is intended only to
-         * document a factory implementation detail.
-         * </p>
-         */
-        public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS = new String("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
+    /**
+     * <p>Default implementation class name as defined in
+     * <em>JSR 206: Java(TM) API for XML Processing (JAXP) 1.3</em>.</p>
+     *
+     * <p>Implementers should specify the name of an appropriate class
+     * to be instantiated if no other implementation resolution mechanism
+     * succeeds.</p>
+     *
+     * <p>Users should not refer to this field; it is intended only to
+     * document a factory implementation detail.
+     * </p>
+     */
+    public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS =
+        // We use new String() here to prevent javadoc from generating
+        // a See Also: Constant Field Value link.
+        new String("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
 
     /**
      * http://www.w3.org/TR/xpath-datamodel/#xdtschema defines two regexps
@@ -101,40 +112,36 @@
     private static final Pattern XDTSCHEMA_DTD =
         Pattern.compile("[^YM]*[DT].*");
 
-        /**
-         * <p>Protected constructor to prevent instaniation outside of package.</p>
-         *
-         * <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p>
-         */
-        protected DatatypeFactory() {
-        }
+    /**
+     * <p>Protected constructor to prevent instaniation outside of package.</p>
+     *
+     * <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p>
+     */
+    protected DatatypeFactory() {
+    }
 
-        /**
-         * <p>Obtain a new instance of a <code>DatatypeFactory</code>.</p>
-         *
+    /**
+     * <p>Obtain a new instance of a <code>DatatypeFactory</code>.</p>
+     *
      * <p>The implementation resolution mechanisms are <a href="#DatatypeFactory.newInstance">defined</a> in this
      * <code>Class</code>'s documentation.</p>
-         *
-         * @return New instance of a <code>DatatypeFactory</code>
-         *
-         * @throws DatatypeConfigurationException If the implementation is not
-         *   available or cannot be instantiated.
+     *
+     * @return New instance of a <code>DatatypeFactory</code>
+     *
+     * @throws DatatypeConfigurationException If the implementation is not
+     *   available or cannot be instantiated.
      *
      * @see #newInstance(String factoryClassName, ClassLoader classLoader)
-         */
-        public static DatatypeFactory newInstance()
-                throws DatatypeConfigurationException {
+     */
+    public static DatatypeFactory newInstance()
+            throws DatatypeConfigurationException {
 
-                try {
-                        return (DatatypeFactory) FactoryFinder.find(
-                                /* The default property name according to the JAXP spec */
-                                 DATATYPEFACTORY_PROPERTY,
-                                /* The fallback implementation class name */
-                                DATATYPEFACTORY_IMPLEMENTATION_CLASS);
-                } catch (FactoryFinder.ConfigurationError e) {
-                        throw new DatatypeConfigurationException(e.getMessage(), e.getException());
-                }
-        }
+            return FactoryFinder.find(
+                    /* The default property name according to the JAXP spec */
+                    DatatypeFactory.class,
+                    /* The fallback implementation class name */
+                    DATATYPEFACTORY_IMPLEMENTATION_CLASS);
+    }
 
     /**
      * <p>Obtain a new instance of a <code>DatatypeFactory</code> from class name.
@@ -172,57 +179,54 @@
      */
     public static DatatypeFactory newInstance(String factoryClassName, ClassLoader classLoader)
         throws DatatypeConfigurationException {
-        try {
-            return (DatatypeFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new DatatypeConfigurationException(e.getMessage(), e.getException());
-        }
-    }
+        return FactoryFinder.newInstance(DatatypeFactory.class,
+                    factoryClassName, classLoader, false);
+     }
 
-        /**
-         * <p>Obtain a new instance of a <code>Duration</code>
-         * specifying the <code>Duration</code> as its string representation, "PnYnMnDTnHnMnS",
-         * as defined in XML Schema 1.0 section 3.2.6.1.</p>
-         *
-         * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
-         * <blockquote>
-         * duration represents a duration of time.
-         * The value space of duration is a six-dimensional space where the coordinates designate the
-         * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
-         * These components are ordered in their significance by their order of appearance i.e. as
-         * year, month, day, hour, minute, and second.
-         * </blockquote>
-     * <p>All six values are set and availabe from the created {@link Duration}</p>
+    /**
+     * <p>Obtain a new instance of a <code>Duration</code>
+     * specifying the <code>Duration</code> as its string representation, "PnYnMnDTnHnMnS",
+     * as defined in XML Schema 1.0 section 3.2.6.1.</p>
+     *
+     * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
+     * <blockquote>
+     * duration represents a duration of time.
+     * The value space of duration is a six-dimensional space where the coordinates designate the
+     * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
+     * These components are ordered in their significance by their order of appearance i.e. as
+     * year, month, day, hour, minute, and second.
+     * </blockquote>
+     * <p>All six values are set and available from the created {@link Duration}</p>
      *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
      * if implementation capacities are exceeded.</p>
-         *
-         * @param lexicalRepresentation <code>String</code> representation of a <code>Duration</code>.
-         *
-         * @return New <code>Duration</code> created from parsing the <code>lexicalRepresentation</code>.
-         *
-         * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code>.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         * @throws NullPointerException if <code>lexicalRepresentation</code> is <code>null</code>.
-         */
-        public abstract Duration newDuration(final String lexicalRepresentation);
+     *
+     * @param lexicalRepresentation <code>String</code> representation of a <code>Duration</code>.
+     *
+     * @return New <code>Duration</code> created from parsing the <code>lexicalRepresentation</code>.
+     *
+     * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code>.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     * @throws NullPointerException if <code>lexicalRepresentation</code> is <code>null</code>.
+     */
+    public abstract Duration newDuration(final String lexicalRepresentation);
 
-        /**
-         * <p>Obtain a new instance of a <code>Duration</code>
-         * specifying the <code>Duration</code> as milliseconds.</p>
-         *
-         * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
-         * <blockquote>
-         * duration represents a duration of time.
-         * The value space of duration is a six-dimensional space where the coordinates designate the
-         * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
-         * These components are ordered in their significance by their order of appearance i.e. as
-         * year, month, day, hour, minute, and second.
-         * </blockquote>
+    /**
+     * <p>Obtain a new instance of a <code>Duration</code>
+     * specifying the <code>Duration</code> as milliseconds.</p>
+     *
+     * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
+     * <blockquote>
+     * duration represents a duration of time.
+     * The value space of duration is a six-dimensional space where the coordinates designate the
+     * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
+     * These components are ordered in their significance by their order of appearance i.e. as
+     * year, month, day, hour, minute, and second.
+     * </blockquote>
      * <p>All six values are set by computing their values from the specified milliseconds
-     * and are availabe using the <code>get</code> methods of  the created {@link Duration}.
+     * and are available using the <code>get</code> methods of  the created {@link Duration}.
      * The values conform to and are defined by:</p>
      * <ul>
      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
@@ -231,25 +235,25 @@
      *   </li>
      *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
      * </ul>
-         *
-         * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
-         * {@link java.util.Calendar#YEAR} = 1970,
-         * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
-         * {@link java.util.Calendar#DATE} = 1, etc.
-         * This is important as there are variations in the Gregorian Calendar,
-         * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
-         * so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced.</p>
-         *
-         * @param durationInMilliSeconds Duration in milliseconds to create.
-         *
-         * @return New <code>Duration</code> representing <code>durationInMilliSeconds</code>.
-         */
-        public abstract Duration newDuration(final long durationInMilliSeconds);
+     *
+     * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+     * {@link java.util.Calendar#YEAR} = 1970,
+     * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+     * {@link java.util.Calendar#DATE} = 1, etc.
+     * This is important as there are variations in the Gregorian Calendar,
+     * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+     * so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced.</p>
+     *
+     * @param durationInMilliSeconds Duration in milliseconds to create.
+     *
+     * @return New <code>Duration</code> representing <code>durationInMilliSeconds</code>.
+     */
+    public abstract Duration newDuration(final long durationInMilliSeconds);
 
-        /**
-         * <p>Obtain a new instance of a <code>Duration</code>
-         * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
-         *
+    /**
+     * <p>Obtain a new instance of a <code>Duration</code>
+     * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
+     *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
@@ -257,35 +261,35 @@
      *
      * <p>A <code>null</code> value indicates that field is not set.</p>
      *
-         * @param isPositive Set to <code>false</code> to create a negative duration. When the length
-         *   of the duration is zero, this parameter will be ignored.
-         * @param years of this <code>Duration</code>
-         * @param months of this <code>Duration</code>
-         * @param days of this <code>Duration</code>
-         * @param hours of this <code>Duration</code>
-         * @param minutes of this <code>Duration</code>
-         * @param seconds of this <code>Duration</code>
-         *
-         * @return New <code>Duration</code> created from the specified values.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if all the fields (years, months, ...) are null or
-         * if any of the fields is negative.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         */
-        public abstract Duration newDuration(
-                final boolean isPositive,
-                final BigInteger years,
-                final BigInteger months,
-                final BigInteger days,
-                final BigInteger hours,
-                final BigInteger minutes,
-                final BigDecimal seconds);
+     * @param isPositive Set to <code>false</code> to create a negative duration. When the length
+     *   of the duration is zero, this parameter will be ignored.
+     * @param years of this <code>Duration</code>
+     * @param months of this <code>Duration</code>
+     * @param days of this <code>Duration</code>
+     * @param hours of this <code>Duration</code>
+     * @param minutes of this <code>Duration</code>
+     * @param seconds of this <code>Duration</code>
+     *
+     * @return New <code>Duration</code> created from the specified values.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if all the fields (years, months, ...) are null or
+     * if any of the fields is negative.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     */
+    public abstract Duration newDuration(
+            final boolean isPositive,
+            final BigInteger years,
+            final BigInteger months,
+            final BigInteger days,
+            final BigInteger hours,
+            final BigInteger minutes,
+            final BigDecimal seconds);
 
-        /**
-         * <p>Obtain a new instance of a <code>Duration</code>
-         * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
-         *
+    /**
+     * <p>Obtain a new instance of a <code>Duration</code>
+     * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
@@ -297,113 +301,113 @@
      * @param minutes of this <code>Duration</code>
      * @param seconds of this <code>Duration</code>
      *
-         * @return New <code>Duration</code> created from the specified values.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if any of the fields is negative.
-         *
-         * @see #newDuration(
-         *   boolean isPositive,
-         *   BigInteger years,
-         *   BigInteger months,
-         *   BigInteger days,
-         *   BigInteger hours,
-         *   BigInteger minutes,
-         *   BigDecimal seconds)
-         */
-        public Duration newDuration(
-                final boolean isPositive,
-                final int years,
-                final int months,
-                final int days,
-                final int hours,
-                final int minutes,
-                final int seconds) {
+     * @return New <code>Duration</code> created from the specified values.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if any of the fields is negative.
+     *
+     * @see #newDuration(
+     *   boolean isPositive,
+     *   BigInteger years,
+     *   BigInteger months,
+     *   BigInteger days,
+     *   BigInteger hours,
+     *   BigInteger minutes,
+     *   BigDecimal seconds)
+     */
+    public Duration newDuration(
+            final boolean isPositive,
+            final int years,
+            final int months,
+            final int days,
+            final int hours,
+            final int minutes,
+            final int seconds) {
 
-                // years may not be set
-                BigInteger realYears = (years != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) years) : null;
+            // years may not be set
+            BigInteger realYears = (years != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) years) : null;
 
-                // months may not be set
-                BigInteger realMonths = (months != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) months) : null;
+            // months may not be set
+            BigInteger realMonths = (months != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) months) : null;
 
-                // days may not be set
-                BigInteger realDays = (days != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) days) : null;
+            // days may not be set
+            BigInteger realDays = (days != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) days) : null;
 
-                // hours may not be set
-                BigInteger realHours = (hours != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) hours) : null;
+            // hours may not be set
+            BigInteger realHours = (hours != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) hours) : null;
 
-                // minutes may not be set
-                BigInteger realMinutes = (minutes != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) minutes) : null;
+            // minutes may not be set
+            BigInteger realMinutes = (minutes != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) minutes) : null;
 
-                // seconds may not be set
-                BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long) seconds) : null;
+            // seconds may not be set
+            BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long) seconds) : null;
 
-                        return newDuration(
-                                isPositive,
-                                realYears,
-                                realMonths,
-                                realDays,
-                                realHours,
-                                realMinutes,
-                                realSeconds
-                        );
-                }
+                    return newDuration(
+                            isPositive,
+                            realYears,
+                            realMonths,
+                            realDays,
+                            realHours,
+                            realMinutes,
+                            realSeconds
+                    );
+            }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> by parsing its <code>String</code> representation,
-         * "<em>PnDTnHnMnS</em>", <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only day, hour, minute, and second components.
-         * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
-         *
-     * <p>All four values are set and availabe from the created {@link Duration}</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> by parsing its <code>String</code> representation,
+     * "<em>PnDTnHnMnS</em>", <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only day, hour, minute, and second components.
+     * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
+     *
+     * <p>All four values are set and available from the created {@link Duration}</p>
+     *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
      * if implementation capacities are exceeded.</p>
      *
-         * @param lexicalRepresentation Lexical representation of a duration.
-         *
-         * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
-         *
-         * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of days and time.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
-         */
-        public Duration newDurationDayTime(final String lexicalRepresentation) {
-            // lexicalRepresentation must be non-null
-            if (lexicalRepresentation == null) {
-                throw new NullPointerException(
-                    "Trying to create an xdt:dayTimeDuration with an invalid"
-                    + " lexical representation of \"null\"");
-            }
-
-            // test lexicalRepresentation against spec regex
-            Matcher matcher = XDTSCHEMA_DTD.matcher(lexicalRepresentation);
-            if (!matcher.matches()) {
-                throw new IllegalArgumentException(
-                    "Trying to create an xdt:dayTimeDuration with an invalid"
-                    + " lexical representation of \"" + lexicalRepresentation
-                    + "\", data model requires years and months only.");
-            }
-
-            return newDuration(lexicalRepresentation);
+     * @param lexicalRepresentation Lexical representation of a duration.
+     *
+     * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
+     *
+     * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of days and time.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
+     */
+    public Duration newDurationDayTime(final String lexicalRepresentation) {
+        // lexicalRepresentation must be non-null
+        if (lexicalRepresentation == null) {
+            throw new NullPointerException(
+                "Trying to create an xdt:dayTimeDuration with an invalid"
+                + " lexical representation of \"null\"");
         }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified milliseconds as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only day, hour, minute, and second components.
-         * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
-         *
+        // test lexicalRepresentation against spec regex
+        Matcher matcher = XDTSCHEMA_DTD.matcher(lexicalRepresentation);
+        if (!matcher.matches()) {
+            throw new IllegalArgumentException(
+                "Trying to create an xdt:dayTimeDuration with an invalid"
+                + " lexical representation of \"" + lexicalRepresentation
+                + "\", data model requires years and months only.");
+        }
+
+        return newDuration(lexicalRepresentation);
+    }
+
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified milliseconds as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only day, hour, minute, and second components.
+     * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
+     *
      * <p>All four values are set by computing their values from the specified milliseconds
-     * and are availabe using the <code>get</code> methods of  the created {@link Duration}.
+     * and are available using the <code>get</code> methods of  the created {@link Duration}.
      * The values conform to and are defined by:</p>
      * <ul>
      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
@@ -412,39 +416,39 @@
      *   </li>
      *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
      * </ul>
-         *
-         * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
-         * {@link java.util.Calendar#YEAR} = 1970,
-         * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
-         * {@link java.util.Calendar#DATE} = 1, etc.
-         * This is important as there are variations in the Gregorian Calendar,
-         * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
-         * so the result of {@link Duration#getDays()} can be influenced.</p>
-         *
+     *
+     * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+     * {@link java.util.Calendar#YEAR} = 1970,
+     * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+     * {@link java.util.Calendar#DATE} = 1, etc.
+     * This is important as there are variations in the Gregorian Calendar,
+     * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+     * so the result of {@link Duration#getDays()} can be influenced.</p>
+     *
      * <p>Any remaining milliseconds after determining the day, hour, minute and second are discarded.</p>
      *
-         * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
-         *
-         * @return New <code>Duration</code> created with the specified <code>durationInMilliseconds</code>.
-         *
-         * @see <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>
-         */
-        public Duration newDurationDayTime(final long durationInMilliseconds) {
+     * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
+     *
+     * @return New <code>Duration</code> created with the specified <code>durationInMilliseconds</code>.
+     *
+     * @see <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>
+     */
+    public Duration newDurationDayTime(final long durationInMilliseconds) {
 
-                return newDuration(durationInMilliseconds);
-        }
+            return newDuration(durationInMilliseconds);
+    }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
-         * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only day, hour, minute, and second components.
-         * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
+     * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only day, hour, minute, and second components.
+     * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
+     *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
@@ -454,102 +458,102 @@
      *
      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
      *   of the duration is zero, this parameter will be ignored.
-         * @param day Day of <code>Duration</code>.
-         * @param hour Hour of <code>Duration</code>.
-         * @param minute Minute of <code>Duration</code>.
-         * @param second Second of <code>Duration</code>.
-         *
-         * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
-         * and <code>second</code>.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if all the fields (day, hour, ...) are null or
-         * if any of the fields is negative.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         */
-        public Duration newDurationDayTime(
-                final boolean isPositive,
-                final BigInteger day,
-                final BigInteger hour,
-                final BigInteger minute,
-                final BigInteger second) {
+     * @param day Day of <code>Duration</code>.
+     * @param hour Hour of <code>Duration</code>.
+     * @param minute Minute of <code>Duration</code>.
+     * @param second Second of <code>Duration</code>.
+     *
+     * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
+     * and <code>second</code>.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if all the fields (day, hour, ...) are null or
+     * if any of the fields is negative.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     */
+    public Duration newDurationDayTime(
+            final boolean isPositive,
+            final BigInteger day,
+            final BigInteger hour,
+            final BigInteger minute,
+            final BigInteger second) {
 
-                return newDuration(
-                        isPositive,
-                        null,  // years
-                        null, // months
-                        day,
-                        hour,
-                        minute,
-                        (second != null)? new BigDecimal(second):null
-                );
-        }
+            return newDuration(
+                    isPositive,
+                    null,  // years
+                    null, // months
+                    day,
+                    hour,
+                    minute,
+                    (second != null)? new BigDecimal(second):null
+            );
+    }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
-         * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only day, hour, minute, and second components.
-         * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
+     * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only day, hour, minute, and second components.
+     * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
      *   of the duration is zero, this parameter will be ignored.
-         * @param day Day of <code>Duration</code>.
-         * @param hour Hour of <code>Duration</code>.
-         * @param minute Minute of <code>Duration</code>.
-         * @param second Second of <code>Duration</code>.
-         *
-         * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
-         * and <code>second</code>.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if any of the fields (day, hour, ...) is negative.
-         */
-        public Duration newDurationDayTime(
-                final boolean isPositive,
-                final int day,
-                final int hour,
-                final int minute,
-                final int second) {
+     * @param day Day of <code>Duration</code>.
+     * @param hour Hour of <code>Duration</code>.
+     * @param minute Minute of <code>Duration</code>.
+     * @param second Second of <code>Duration</code>.
+     *
+     * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
+     * and <code>second</code>.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if any of the fields (day, hour, ...) is negative.
+     */
+    public Duration newDurationDayTime(
+            final boolean isPositive,
+            final int day,
+            final int hour,
+            final int minute,
+            final int second) {
 
-                        return newDurationDayTime(
-                                isPositive,
-                                BigInteger.valueOf((long) day),
-                                BigInteger.valueOf((long) hour),
-                                BigInteger.valueOf((long) minute),
-                                BigInteger.valueOf((long) second)
-                                );
-                }
+                    return newDurationDayTime(
+                            isPositive,
+                            BigInteger.valueOf((long) day),
+                            BigInteger.valueOf((long) hour),
+                            BigInteger.valueOf((long) minute),
+                            BigInteger.valueOf((long) second)
+                            );
+            }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> by parsing its <code>String</code> representation,
-         * "<em>PnYnM</em>", <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only year and month components.
-         * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
-         *
-     * <p>Both values are set and availabe from the created {@link Duration}</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> by parsing its <code>String</code> representation,
+     * "<em>PnYnM</em>", <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only year and month components.
+     * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
+     *
+     * <p>Both values are set and available from the created {@link Duration}</p>
+     *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
      * if implementation capacities are exceeded.</p>
      *
-         * @param lexicalRepresentation Lexical representation of a duration.
-         *
-         * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
-         *
-         * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of years and months.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
-         */
+     * @param lexicalRepresentation Lexical representation of a duration.
+     *
+     * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
+     *
+     * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of years and months.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
+     */
     public Duration newDurationYearMonth(
             final String lexicalRepresentation) {
 
@@ -572,17 +576,17 @@
         return newDuration(lexicalRepresentation);
     }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified milliseconds as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
-         *
-         * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
-         * whose lexical representation contains only year and month components.
-         * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified milliseconds as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
+     *
+     * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
+     * whose lexical representation contains only year and month components.
+     * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
+     *
      * <p>Both values are set by computing their values from the specified milliseconds
-     * and are availabe using the <code>get</code> methods of  the created {@link Duration}.
+     * and are available using the <code>get</code> methods of  the created {@link Duration}.
      * The values conform to and are defined by:</p>
      * <ul>
      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
@@ -592,20 +596,20 @@
      *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
      * </ul>
      *
-         * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
-         * {@link java.util.Calendar#YEAR} = 1970,
-         * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
-         * {@link java.util.Calendar#DATE} = 1, etc.
-         * This is important as there are variations in the Gregorian Calendar,
-         * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
-         * so the result of {@link Duration#getMonths()} can be influenced.</p>
-         *
+     * <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+     * {@link java.util.Calendar#YEAR} = 1970,
+     * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+     * {@link java.util.Calendar#DATE} = 1, etc.
+     * This is important as there are variations in the Gregorian Calendar,
+     * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+     * so the result of {@link Duration#getMonths()} can be influenced.</p>
+     *
      * <p>Any remaining milliseconds after determining the year and month are discarded.</p>
-         *
-         * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
-         *
-         * @return New <code>Duration</code> created using the specified <code>durationInMilliseconds</code>.
-         */
+     *
+     * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
+     *
+     * @return New <code>Duration</code> created using the specified <code>durationInMilliseconds</code>.
+     */
     public Duration newDurationYearMonth(
             final long durationInMilliseconds) {
 
@@ -624,12 +628,12 @@
         return newDurationYearMonth(isPositive, years, months);
     }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
-         * <code>year</code> and <code>month</code> as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
+     * <code>year</code> and <code>month</code> as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
+     *
      * <p>The XML Schema specification states that values can be of an arbitrary size.
      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
@@ -639,74 +643,74 @@
      *
      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
      *   of the duration is zero, this parameter will be ignored.
-         * @param year Year of <code>Duration</code>.
-         * @param month Month of <code>Duration</code>.
-         *
-         * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if all of the fields (year, month) are null or
-         * if any of the fields is negative.
-         * @throws UnsupportedOperationException If implementation cannot support requested values.
-         */
-        public Duration newDurationYearMonth(
-                final boolean isPositive,
-                final BigInteger year,
-                final BigInteger month) {
+     * @param year Year of <code>Duration</code>.
+     * @param month Month of <code>Duration</code>.
+     *
+     * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if all of the fields (year, month) are null or
+     * if any of the fields is negative.
+     * @throws UnsupportedOperationException If implementation cannot support requested values.
+     */
+    public Duration newDurationYearMonth(
+            final boolean isPositive,
+            final BigInteger year,
+            final BigInteger month) {
 
-                return newDuration(
-                        isPositive,
-                        year,
-                        month,
-                        null, // days
-                        null, // hours
-                        null, // minutes
-                        null  // seconds
-                );
-        }
+            return newDuration(
+                    isPositive,
+                    year,
+                    month,
+                    null, // days
+                    null, // hours
+                    null, // minutes
+                    null  // seconds
+            );
+    }
 
-        /**
-         * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
-         * <code>year</code> and <code>month</code> as defined in
-         * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
-         *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
-         *
+    /**
+     * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
+     * <code>year</code> and <code>month</code> as defined in
+     * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
+     *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
      *   of the duration is zero, this parameter will be ignored.
-         * @param year Year of <code>Duration</code>.
-         * @param month Month of <code>Duration</code>.
-         *
-         * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
-         *
-         * @throws IllegalArgumentException If the values are not a valid representation of a
-         * <code>Duration</code>: if any of the fields (year, month) is negative.
-         */
-        public Duration newDurationYearMonth(
-                final boolean isPositive,
-                final int year,
-                final int month) {
+     * @param year Year of <code>Duration</code>.
+     * @param month Month of <code>Duration</code>.
+     *
+     * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
+     *
+     * @throws IllegalArgumentException If the values are not a valid representation of a
+     * <code>Duration</code>: if any of the fields (year, month) is negative.
+     */
+    public Duration newDurationYearMonth(
+            final boolean isPositive,
+            final int year,
+            final int month) {
 
-                return newDurationYearMonth(
-                        isPositive,
-                        BigInteger.valueOf((long) year),
-                        BigInteger.valueOf((long) month));
-                }
+            return newDurationYearMonth(
+                    isPositive,
+                    BigInteger.valueOf((long) year),
+                    BigInteger.valueOf((long) month));
+            }
 
-        /**
-         * <p>Create a new instance of an <code>XMLGregorianCalendar</code>.</p>
-         *
+    /**
+     * <p>Create a new instance of an <code>XMLGregorianCalendar</code>.</p>
+     *
      * <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null.</p>
      *
      * @return New <code>XMLGregorianCalendar</code> with all date/time datatype fields set to
      *   {@link DatatypeConstants#FIELD_UNDEFINED} or null.
-         */
-        public abstract XMLGregorianCalendar newXMLGregorianCalendar();
+     */
+    public abstract XMLGregorianCalendar newXMLGregorianCalendar();
 
-        /**
-         * <p>Create a new XMLGregorianCalendar by parsing the String as a lexical representation.</p>
-         *
+    /**
+     * <p>Create a new XMLGregorianCalendar by parsing the String as a lexical representation.</p>
+     *
      * <p>Parsing the lexical string representation is defined in
      * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
      * <em>Lexical Representation</em>.</a></p>
@@ -721,344 +725,344 @@
      * <p>Except for the noted lexical/canonical representation mismatches
      * listed in <a href="http://www.w3.org/2001/05/xmlschema-errata#e2-45">
      * XML Schema 1.0 errata, Section 3.2.7.2</a>.</p>
-         *
-         * @param lexicalRepresentation Lexical representation of one the eight XML Schema date/time datatypes.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from the <code>lexicalRepresentation</code>.
-         *
-         * @throws IllegalArgumentException If the <code>lexicalRepresentation</code> is not a valid <code>XMLGregorianCalendar</code>.
-         * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
-         */
-        public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
+     *
+     * @param lexicalRepresentation Lexical representation of one the eight XML Schema date/time datatypes.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from the <code>lexicalRepresentation</code>.
+     *
+     * @throws IllegalArgumentException If the <code>lexicalRepresentation</code> is not a valid <code>XMLGregorianCalendar</code>.
+     * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
+     */
+    public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
 
-        /**
-         * <p>Create an <code>XMLGregorianCalendar</code> from a {@link GregorianCalendar}.</p>
-         *
-         * <table border="2" rules="all" cellpadding="2">
-         *   <thead>
-         *     <tr>
-         *       <th align="center" colspan="2">
-         *          Field by Field Conversion from
-         *          {@link GregorianCalendar} to an {@link XMLGregorianCalendar}
-         *       </th>
-         *     </tr>
-         *     <tr>
-         *        <th><code>java.util.GregorianCalendar</code> field</th>
-         *        <th><code>javax.xml.datatype.XMLGregorianCalendar</code> field</th>
-         *     </tr>
-         *   </thead>
-         *   <tbody>
-         *     <tr>
-         *       <td><code>ERA == GregorianCalendar.BC ? -YEAR : YEAR</code></td>
-         *       <td>{@link XMLGregorianCalendar#setYear(int year)}</td>
-         *     </tr>
-         *     <tr>
-         *       <td><code>MONTH + 1</code></td>
-         *       <td>{@link XMLGregorianCalendar#setMonth(int month)}</td>
-         *     </tr>
-         *     <tr>
-         *       <td><code>DAY_OF_MONTH</code></td>
-         *       <td>{@link XMLGregorianCalendar#setDay(int day)}</td>
-         *     </tr>
-         *     <tr>
-         *       <td><code>HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND</code></td>
-         *       <td>{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}</td>
-         *     </tr>
-         *     <tr>
-         *       <td>
-         *         <code>(ZONE_OFFSET + DST_OFFSET) / (60*1000)</code><br/>
-         *         <em>(in minutes)</em>
-         *       </td>
-         *       <td>{@link XMLGregorianCalendar#setTimezone(int offset)}<sup><em>*</em></sup>
-         *       </td>
-         *     </tr>
-         *   </tbody>
-         * </table>
-         * <p><em>*</em>conversion loss of information. It is not possible to represent
-         * a <code>java.util.GregorianCalendar</code> daylight savings timezone id in the
-         * XML Schema 1.0 date/time datatype representation.</p>
-         *
-         * <p>To compute the return value's <code>TimeZone</code> field,
-         * <ul>
-         * <li>when <code>this.getTimezone() != FIELD_UNDEFINED</code>,
-         * create a <code>java.util.TimeZone</code> with a custom timezone id
-         * using the <code>this.getTimezone()</code>.</li>
-         * <li>else use the <code>GregorianCalendar</code> default timezone value
-         * for the host is defined as specified by
-         * <code>java.util.TimeZone.getDefault()</code>.</li></p>
-         *
-         * @param cal <code>java.util.GregorianCalendar</code> used to create <code>XMLGregorianCalendar</code>
-         *
-         * @return <code>XMLGregorianCalendar</code> created from <code>java.util.GregorianCalendar</code>
-         *
-         * @throws NullPointerException If <code>cal</code> is <code>null</code>.
-         */
-        public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
+    /**
+     * <p>Create an <code>XMLGregorianCalendar</code> from a {@link GregorianCalendar}.</p>
+     *
+     * <table border="2" rules="all" cellpadding="2">
+     *   <thead>
+     *     <tr>
+     *       <th align="center" colspan="2">
+     *          Field by Field Conversion from
+     *          {@link GregorianCalendar} to an {@link XMLGregorianCalendar}
+     *       </th>
+     *     </tr>
+     *     <tr>
+     *        <th><code>java.util.GregorianCalendar</code> field</th>
+     *        <th><code>javax.xml.datatype.XMLGregorianCalendar</code> field</th>
+     *     </tr>
+     *   </thead>
+     *   <tbody>
+     *     <tr>
+     *       <td><code>ERA == GregorianCalendar.BC ? -YEAR : YEAR</code></td>
+     *       <td>{@link XMLGregorianCalendar#setYear(int year)}</td>
+     *     </tr>
+     *     <tr>
+     *       <td><code>MONTH + 1</code></td>
+     *       <td>{@link XMLGregorianCalendar#setMonth(int month)}</td>
+     *     </tr>
+     *     <tr>
+     *       <td><code>DAY_OF_MONTH</code></td>
+     *       <td>{@link XMLGregorianCalendar#setDay(int day)}</td>
+     *     </tr>
+     *     <tr>
+     *       <td><code>HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND</code></td>
+     *       <td>{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}</td>
+     *     </tr>
+     *     <tr>
+     *       <td>
+     *         <code>(ZONE_OFFSET + DST_OFFSET) / (60*1000)</code><br/>
+     *         <em>(in minutes)</em>
+     *       </td>
+     *       <td>{@link XMLGregorianCalendar#setTimezone(int offset)}<sup><em>*</em></sup>
+     *       </td>
+     *     </tr>
+     *   </tbody>
+     * </table>
+     * <p><em>*</em>conversion loss of information. It is not possible to represent
+     * a <code>java.util.GregorianCalendar</code> daylight savings timezone id in the
+     * XML Schema 1.0 date/time datatype representation.</p>
+     *
+     * <p>To compute the return value's <code>TimeZone</code> field,
+     * <ul>
+     * <li>when <code>this.getTimezone() != FIELD_UNDEFINED</code>,
+     * create a <code>java.util.TimeZone</code> with a custom timezone id
+     * using the <code>this.getTimezone()</code>.</li>
+     * <li>else use the <code>GregorianCalendar</code> default timezone value
+     * for the host is defined as specified by
+     * <code>java.util.TimeZone.getDefault()</code>.</li></p>
+     *
+     * @param cal <code>java.util.GregorianCalendar</code> used to create <code>XMLGregorianCalendar</code>
+     *
+     * @return <code>XMLGregorianCalendar</code> created from <code>java.util.GregorianCalendar</code>
+     *
+     * @throws NullPointerException If <code>cal</code> is <code>null</code>.
+     */
+    public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
 
-        /**
-         * <p>Constructor allowing for complete value spaces allowed by
-         * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
-         * builtin datatypes. Note that <code>year</code> parameter supports
-         * arbitrarily large numbers and fractionalSecond has infinite
-         * precision.</p>
-         *
+    /**
+     * <p>Constructor allowing for complete value spaces allowed by
+     * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
+     * builtin datatypes. Note that <code>year</code> parameter supports
+     * arbitrarily large numbers and fractionalSecond has infinite
+     * precision.</p>
+     *
      * <p>A <code>null</code> value indicates that field is not set.</p>
      *
-         * @param year of <code>XMLGregorianCalendar</code> to be created.
-         * @param month of <code>XMLGregorianCalendar</code> to be created.
-         * @param day of <code>XMLGregorianCalendar</code> to be created.
-         * @param hour of <code>XMLGregorianCalendar</code> to be created.
-         * @param minute of <code>XMLGregorianCalendar</code> to be created.
-         * @param second of <code>XMLGregorianCalendar</code> to be created.
-         * @param fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
-         * @param timezone of <code>XMLGregorianCalendar</code> to be created.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from specified values.
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         */
-        public abstract XMLGregorianCalendar newXMLGregorianCalendar(
-                final BigInteger year,
-                final int month,
-                final int day,
-                final int hour,
-                final int minute,
-                final int second,
-                final BigDecimal fractionalSecond,
-                final int timezone);
+     * @param year of <code>XMLGregorianCalendar</code> to be created.
+     * @param month of <code>XMLGregorianCalendar</code> to be created.
+     * @param day of <code>XMLGregorianCalendar</code> to be created.
+     * @param hour of <code>XMLGregorianCalendar</code> to be created.
+     * @param minute of <code>XMLGregorianCalendar</code> to be created.
+     * @param second of <code>XMLGregorianCalendar</code> to be created.
+     * @param fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
+     * @param timezone of <code>XMLGregorianCalendar</code> to be created.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from specified values.
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     */
+    public abstract XMLGregorianCalendar newXMLGregorianCalendar(
+            final BigInteger year,
+            final int month,
+            final int day,
+            final int hour,
+            final int minute,
+            final int second,
+            final BigDecimal fractionalSecond,
+            final int timezone);
 
-        /**
-         * <p>Constructor of value spaces that a
-         * <code>java.util.GregorianCalendar</code> instance would need to convert to an
-         * <code>XMLGregorianCalendar</code> instance.</p>
-         *
-         * <p><code>XMLGregorianCalendar eon</code> and
-         * <code>fractionalSecond</code> are set to <code>null</code></p>
-         *
+    /**
+     * <p>Constructor of value spaces that a
+     * <code>java.util.GregorianCalendar</code> instance would need to convert to an
+     * <code>XMLGregorianCalendar</code> instance.</p>
+     *
+     * <p><code>XMLGregorianCalendar eon</code> and
+     * <code>fractionalSecond</code> are set to <code>null</code></p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
-         * @param year of <code>XMLGregorianCalendar</code> to be created.
-         * @param month of <code>XMLGregorianCalendar</code> to be created.
-         * @param day of <code>XMLGregorianCalendar</code> to be created.
-         * @param hour of <code>XMLGregorianCalendar</code> to be created.
-         * @param minute of <code>XMLGregorianCalendar</code> to be created.
-         * @param second of <code>XMLGregorianCalendar</code> to be created.
-         * @param millisecond of <code>XMLGregorianCalendar</code> to be created.
-         * @param timezone of <code>XMLGregorianCalendar</code> to be created.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from specified values.
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         */
-        public XMLGregorianCalendar newXMLGregorianCalendar(
-                final int year,
-                final int month,
-                final int day,
-                final int hour,
-                final int minute,
-                final int second,
-                final int millisecond,
-                final int timezone) {
+     * @param year of <code>XMLGregorianCalendar</code> to be created.
+     * @param month of <code>XMLGregorianCalendar</code> to be created.
+     * @param day of <code>XMLGregorianCalendar</code> to be created.
+     * @param hour of <code>XMLGregorianCalendar</code> to be created.
+     * @param minute of <code>XMLGregorianCalendar</code> to be created.
+     * @param second of <code>XMLGregorianCalendar</code> to be created.
+     * @param millisecond of <code>XMLGregorianCalendar</code> to be created.
+     * @param timezone of <code>XMLGregorianCalendar</code> to be created.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from specified values.
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     */
+    public XMLGregorianCalendar newXMLGregorianCalendar(
+            final int year,
+            final int month,
+            final int day,
+            final int hour,
+            final int minute,
+            final int second,
+            final int millisecond,
+            final int timezone) {
 
-                // year may be undefined
-                BigInteger realYear = (year != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) year) : null;
+            // year may be undefined
+            BigInteger realYear = (year != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) year) : null;
 
-                // millisecond may be undefined
-                // millisecond must be >= 0 millisecond <= 1000
-                BigDecimal realMillisecond = null; // undefined value
-                if (millisecond != DatatypeConstants.FIELD_UNDEFINED) {
-                        if (millisecond < 0 || millisecond > 1000) {
-                                throw new IllegalArgumentException(
-                                                        "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar("
-                                                        + "int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)"
-                                                        + "with invalid millisecond: " + millisecond
-                                                        );
-                        }
+            // millisecond may be undefined
+            // millisecond must be >= 0 millisecond <= 1000
+            BigDecimal realMillisecond = null; // undefined value
+            if (millisecond != DatatypeConstants.FIELD_UNDEFINED) {
+                    if (millisecond < 0 || millisecond > 1000) {
+                            throw new IllegalArgumentException(
+                                                    "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar("
+                                                    + "int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)"
+                                                    + "with invalid millisecond: " + millisecond
+                                                    );
+                    }
 
-                        realMillisecond = BigDecimal.valueOf((long) millisecond).movePointLeft(3);
-                }
+                    realMillisecond = BigDecimal.valueOf((long) millisecond).movePointLeft(3);
+            }
 
-                return newXMLGregorianCalendar(
-                        realYear,
-                        month,
-                        day,
-                        hour,
-                        minute,
-                        second,
-                        realMillisecond,
-                        timezone
-                );
-        }
+            return newXMLGregorianCalendar(
+                    realYear,
+                    month,
+                    day,
+                    hour,
+                    minute,
+                    second,
+                    realMillisecond,
+                    timezone
+            );
+    }
 
-        /**
-         * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p>
-         *
-         * <p>For example, an instance of <code>gYear</code> can be created invoking this factory
-         * with <code>month</code> and <code>day</code> parameters set to
-         * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
-         *
+    /**
+     * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p>
+     *
+     * <p>For example, an instance of <code>gYear</code> can be created invoking this factory
+     * with <code>month</code> and <code>day</code> parameters set to
+     * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
-         * @param year of <code>XMLGregorianCalendar</code> to be created.
-         * @param month of <code>XMLGregorianCalendar</code> to be created.
-         * @param day of <code>XMLGregorianCalendar</code> to be created.
-         * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from parameter values.
-         *
-         * @see DatatypeConstants#FIELD_UNDEFINED
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         */
-        public XMLGregorianCalendar newXMLGregorianCalendarDate(
-                final int year,
-                final int month,
-                final int day,
-                final int timezone) {
+     * @param year of <code>XMLGregorianCalendar</code> to be created.
+     * @param month of <code>XMLGregorianCalendar</code> to be created.
+     * @param day of <code>XMLGregorianCalendar</code> to be created.
+     * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from parameter values.
+     *
+     * @see DatatypeConstants#FIELD_UNDEFINED
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     */
+    public XMLGregorianCalendar newXMLGregorianCalendarDate(
+            final int year,
+            final int month,
+            final int day,
+            final int timezone) {
 
-                return newXMLGregorianCalendar(
-                        year,
-                        month,
-                        day,
-                        DatatypeConstants.FIELD_UNDEFINED, // hour
-                        DatatypeConstants.FIELD_UNDEFINED, // minute
-                        DatatypeConstants.FIELD_UNDEFINED, // second
-                        DatatypeConstants.FIELD_UNDEFINED, // millisecond
-                        timezone);
-                }
+            return newXMLGregorianCalendar(
+                    year,
+                    month,
+                    day,
+                    DatatypeConstants.FIELD_UNDEFINED, // hour
+                    DatatypeConstants.FIELD_UNDEFINED, // minute
+                    DatatypeConstants.FIELD_UNDEFINED, // second
+                    DatatypeConstants.FIELD_UNDEFINED, // millisecond
+                    timezone);
+            }
 
-        /**
-         * <p>Create a Java instance of XML Schema builtin datatype <code>time</code>.</p>
-         *
+    /**
+     * <p>Create a Java instance of XML Schema builtin datatype <code>time</code>.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
-         * @param hours number of hours
-         * @param minutes number of minutes
-         * @param seconds number of seconds
-         * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from parameter values.
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         *
-         * @see DatatypeConstants#FIELD_UNDEFINED
-         */
-        public XMLGregorianCalendar newXMLGregorianCalendarTime(
-                final int hours,
-                final int minutes,
-                final int seconds,
-                final int timezone) {
+     * @param hours number of hours
+     * @param minutes number of minutes
+     * @param seconds number of seconds
+     * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from parameter values.
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     *
+     * @see DatatypeConstants#FIELD_UNDEFINED
+     */
+    public XMLGregorianCalendar newXMLGregorianCalendarTime(
+            final int hours,
+            final int minutes,
+            final int seconds,
+            final int timezone) {
 
-                return newXMLGregorianCalendar(
-                        DatatypeConstants.FIELD_UNDEFINED, // Year
-                        DatatypeConstants.FIELD_UNDEFINED, // Month
-                        DatatypeConstants.FIELD_UNDEFINED, // Day
-                        hours,
-                        minutes,
-                        seconds,
-                        DatatypeConstants.FIELD_UNDEFINED, //Millisecond
-                        timezone);
-        }
+            return newXMLGregorianCalendar(
+                    DatatypeConstants.FIELD_UNDEFINED, // Year
+                    DatatypeConstants.FIELD_UNDEFINED, // Month
+                    DatatypeConstants.FIELD_UNDEFINED, // Day
+                    hours,
+                    minutes,
+                    seconds,
+                    DatatypeConstants.FIELD_UNDEFINED, //Millisecond
+                    timezone);
+    }
 
-        /**
-         * <p>Create a Java instance of XML Schema builtin datatype time.</p>
-         *
+    /**
+     * <p>Create a Java instance of XML Schema builtin datatype time.</p>
+     *
      * <p>A <code>null</code> value indicates that field is not set.</p>
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
-         * @param hours number of hours
-         * @param minutes number of minutes
-         * @param seconds number of seconds
-         * @param fractionalSecond value of <code>null</code> indicates that this optional field is not set.
-         * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from parameter values.
-         *
-         * @see DatatypeConstants#FIELD_UNDEFINED
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         */
-        public XMLGregorianCalendar newXMLGregorianCalendarTime(
-                final int hours,
-                final int minutes,
-                final int seconds,
-                final BigDecimal fractionalSecond,
-                final int timezone) {
+     * @param hours number of hours
+     * @param minutes number of minutes
+     * @param seconds number of seconds
+     * @param fractionalSecond value of <code>null</code> indicates that this optional field is not set.
+     * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from parameter values.
+     *
+     * @see DatatypeConstants#FIELD_UNDEFINED
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     */
+    public XMLGregorianCalendar newXMLGregorianCalendarTime(
+            final int hours,
+            final int minutes,
+            final int seconds,
+            final BigDecimal fractionalSecond,
+            final int timezone) {
 
-                return newXMLGregorianCalendar(
-                        null, // year
-                        DatatypeConstants.FIELD_UNDEFINED, // month
-                        DatatypeConstants.FIELD_UNDEFINED, // day
-                        hours,
-                        minutes,
-                        seconds,
-                        fractionalSecond,
-                        timezone);
-                }
+            return newXMLGregorianCalendar(
+                    null, // year
+                    DatatypeConstants.FIELD_UNDEFINED, // month
+                    DatatypeConstants.FIELD_UNDEFINED, // day
+                    hours,
+                    minutes,
+                    seconds,
+                    fractionalSecond,
+                    timezone);
+            }
 
-        /**
-         * <p>Create a Java instance of XML Schema builtin datatype time.</p>
-         *
+    /**
+     * <p>Create a Java instance of XML Schema builtin datatype time.</p>
+     *
      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
      *
-         * @param hours number of hours
-         * @param minutes number of minutes
-         * @param seconds number of seconds
-         * @param milliseconds number of milliseconds
-         * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
-         *
-         * @return <code>XMLGregorianCalendar</code> created from parameter values.
-         *
-         * @see DatatypeConstants#FIELD_UNDEFINED
-         *
-         * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
-         *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
-         *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
-         *   as determined by {@link XMLGregorianCalendar#isValid()}.
-         */
-        public XMLGregorianCalendar newXMLGregorianCalendarTime(
-                final int hours,
-                final int minutes,
-                final int seconds,
-                final int milliseconds,
-                final int timezone) {
+     * @param hours number of hours
+     * @param minutes number of minutes
+     * @param seconds number of seconds
+     * @param milliseconds number of milliseconds
+     * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+     *
+     * @return <code>XMLGregorianCalendar</code> created from parameter values.
+     *
+     * @see DatatypeConstants#FIELD_UNDEFINED
+     *
+     * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+     *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+     *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
+     *   as determined by {@link XMLGregorianCalendar#isValid()}.
+     */
+    public XMLGregorianCalendar newXMLGregorianCalendarTime(
+            final int hours,
+            final int minutes,
+            final int seconds,
+            final int milliseconds,
+            final int timezone) {
 
-                // millisecond may be undefined
-                // millisecond must be >= 0 millisecond <= 1000
-                BigDecimal realMilliseconds = null; // undefined value
-                if (milliseconds != DatatypeConstants.FIELD_UNDEFINED) {
-                        if (milliseconds < 0 || milliseconds > 1000) {
-                                throw new IllegalArgumentException(
-                                                        "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendarTime("
-                                                        + "int hours, int minutes, int seconds, int milliseconds, int timezone)"
-                                                        + "with invalid milliseconds: " + milliseconds
-                                                        );
-                        }
+            // millisecond may be undefined
+            // millisecond must be >= 0 millisecond <= 1000
+            BigDecimal realMilliseconds = null; // undefined value
+            if (milliseconds != DatatypeConstants.FIELD_UNDEFINED) {
+                    if (milliseconds < 0 || milliseconds > 1000) {
+                            throw new IllegalArgumentException(
+                                                    "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendarTime("
+                                                    + "int hours, int minutes, int seconds, int milliseconds, int timezone)"
+                                                    + "with invalid milliseconds: " + milliseconds
+                                                    );
+                    }
 
-                        realMilliseconds = BigDecimal.valueOf((long) milliseconds).movePointLeft(3);
-                }
+                    realMilliseconds = BigDecimal.valueOf((long) milliseconds).movePointLeft(3);
+            }
 
-                return newXMLGregorianCalendarTime(
-                        hours,
-                        minutes,
-                        seconds,
-                        realMilliseconds,
-                        timezone
-                );
-        }
+            return newXMLGregorianCalendarTime(
+                    hours,
+                    minutes,
+                    seconds,
+                    realMilliseconds,
+                    timezone
+            );
+    }
 }
--- a/src/javax/xml/datatype/FactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/datatype/FactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,12 @@
 package javax.xml.datatype;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
 import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
  * <p>Implements pluggable Datatypes.</p>
@@ -44,6 +42,7 @@
  * @author Santiago.PericasGeertsen@sun.com
  */
 class FactoryFinder {
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
 
     /**
      * Internal debug flag.
@@ -53,19 +52,19 @@
     /**
      * Cache for properties in java.home/lib/jaxp.properties
      */
-    static Properties cacheProps = new Properties();
+    private final static Properties cacheProps = new Properties();
 
     /**
      * Flag indicating if properties from java.home/lib/jaxp.properties
      * have been cached.
      */
-    static volatile boolean firstTime = true;
+    private static volatile boolean firstTime = true;
 
     /**
      * Security support class use to check access control before
      * getting certain system resources.
      */
-    static SecuritySupport ss = new SecuritySupport();
+    private final static SecuritySupport ss = new SecuritySupport();
 
     // Define system property "jaxp.debug" to get output
     static {
@@ -95,28 +94,34 @@
      * If the class loader supplied is <code>null</code>, first try using the
      * context class loader followed by the current (i.e. bootstrap) class
      * loader.
+     *
+     * Use bootstrap classLoader if cl = null and useBSClsLoader is true
      */
-    static private Class getProviderClass(String className, ClassLoader cl,
-            boolean doFallback) throws ClassNotFoundException
+    static private Class<?> getProviderClass(String className, ClassLoader cl,
+            boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException
     {
         try {
             if (cl == null) {
-                cl = ss.getContextClassLoader();
-                if (cl == null) {
-                    throw new ClassNotFoundException();
-                }
-                else {
-                    return cl.loadClass(className);
+                if (useBSClsLoader) {
+                    return Class.forName(className, false, FactoryFinder.class.getClassLoader());
+                } else {
+                    cl = ss.getContextClassLoader();
+                    if (cl == null) {
+                        throw new ClassNotFoundException();
+                    }
+                    else {
+                        return Class.forName(className, false, cl);
+                    }
                 }
             }
             else {
-                return cl.loadClass(className);
+                return Class.forName(className, false, cl);
             }
         }
         catch (ClassNotFoundException e1) {
             if (doFallback) {
                 // Use current class loader - should always be bootstrap CL
-                return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                return Class.forName(className, false, FactoryFinder.class.getClassLoader());
             }
             else {
                 throw e1;
@@ -128,6 +133,31 @@
      * Create an instance of a class. Delegates to method
      * <code>getProviderClass()</code> in order to load the class.
      *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
+     * @param className Name of the concrete class corresponding to the
+     * service provider
+     *
+     * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code>
+     * current <code>Thread</code>'s context classLoader is used to load the factory class.
+     *
+     * @param doFallback True if the current ClassLoader should be tried as
+     * a fallback if the class is not found using cl
+     */
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl, boolean doFallback)
+        throws  DatatypeConfigurationException
+    {
+        return newInstance(type, className, cl, doFallback, false);
+    }
+
+    /**
+     * Create an instance of a class. Delegates to method
+     * <code>getProviderClass()</code> in order to load the class.
+     *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
      * @param className Name of the concrete class corresponding to the
      * service provider
      *
@@ -136,25 +166,42 @@
      *
      * @param doFallback True if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
+     *
+     * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter
+     * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader.
      */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback)
-        throws ConfigurationError
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl,
+            boolean doFallback, boolean useBSClsLoader)
+        throws DatatypeConfigurationException
     {
+        assert type != null;
+
+        // make sure we have access to restricted packages
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                cl = null;
+                useBSClsLoader = true;
+            }
+        }
+
         try {
-            Class providerClass = getProviderClass(className, cl, doFallback);
+            Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            if (!type.isAssignableFrom(providerClass)) {
+                throw new ClassCastException(className + " cannot be cast to " + type.getName());
+            }
             Object instance = providerClass.newInstance();
             if (debug) {    // Extra check to avoid computing cl strings
                 dPrint("created new instance of " + providerClass +
                        " using ClassLoader: " + cl);
             }
-            return instance;
+            return type.cast(instance);
         }
         catch (ClassNotFoundException x) {
-            throw new ConfigurationError(
+            throw new DatatypeConfigurationException(
                 "Provider " + className + " not found", x);
         }
         catch (Exception x) {
-            throw new ConfigurationError(
+            throw new DatatypeConfigurationException(
                 "Provider " + className + " could not be instantiated: " + x,
                 x);
         }
@@ -165,16 +212,17 @@
      * entry point.
      * @return Class object of factory, never null
      *
-     * @param factoryId             Name of the factory to find, same as
-     *                              a property name
+     * @param type                  Base class / Service interface  of the
+     *                              factory to find.
      * @param fallbackClassName     Implementation class name, if nothing else
      *                              is found.  Use null to mean no fallback.
      *
      * Package private so this code can be shared.
      */
-    static Object find(String factoryId, String fallbackClassName)
-        throws ConfigurationError
+    static <T> T find(Class<T> type, String fallbackClassName)
+        throws DatatypeConfigurationException
     {
+        final String factoryId = type.getName();
         dPrint("find factoryId =" + factoryId);
 
         // Use the system property first
@@ -182,7 +230,7 @@
             String systemProp = ss.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint("found system property, value=" + systemProp);
-                return newInstance(systemProp, null, true);
+                return newInstance(type, systemProp, null, true);
             }
         }
         catch (SecurityException se) {
@@ -191,7 +239,6 @@
 
         // try to read from $java.home/lib/jaxp.properties
         try {
-            String factoryClassName = null;
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
@@ -206,11 +253,11 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(factoryId);
+            final String factoryClassName = cacheProps.getProperty(factoryId);
 
             if (factoryClassName != null) {
                 dPrint("found in $java.home/jaxp.properties, value=" + factoryClassName);
-                return newInstance(factoryClassName, null, true);
+                return newInstance(type, factoryClassName, null, true);
             }
         }
         catch (Exception ex) {
@@ -218,109 +265,46 @@
         }
 
         // Try Jar Service Provider Mechanism
-        Object provider = findJarServiceProvider(factoryId);
+        final T provider = findServiceProvider(type);
         if (provider != null) {
             return provider;
         }
         if (fallbackClassName == null) {
-            throw new ConfigurationError(
-                "Provider for " + factoryId + " cannot be found", null);
+            throw new DatatypeConfigurationException(
+                "Provider for " + factoryId + " cannot be found");
         }
 
         dPrint("loaded from fallback value: " + fallbackClassName);
-        return newInstance(fallbackClassName, null, true);
+        return newInstance(type, fallbackClassName, null, true);
     }
 
     /*
-     * Try to find provider using Jar Service Provider Mechanism
+     * Try to find provider using the ServiceLoader API
+     *
+     * @param type Base class / Service interface  of the factory to find.
      *
      * @return instance of provider class if found or null
      */
-    private static Object findJarServiceProvider(String factoryId)
-        throws ConfigurationError
+    private static <T> T findServiceProvider(final Class<T> type)
+            throws DatatypeConfigurationException
     {
-        String serviceId = "META-INF/services/" + factoryId;
-        InputStream is = null;
-
-        // First try the Context ClassLoader
-        ClassLoader cl = ss.getContextClassLoader();
-        if (cl != null) {
-            is = ss.getResourceAsStream(cl, serviceId);
-
-            // If no provider found then try the current ClassLoader
-            if (is == null) {
-                cl = FactoryFinder.class.getClassLoader();
-                is = ss.getResourceAsStream(cl, serviceId);
-            }
-        } else {
-            // No Context ClassLoader, try the current ClassLoader
-            cl = FactoryFinder.class.getClassLoader();
-            is = ss.getResourceAsStream(cl, serviceId);
-        }
-
-        if (is == null) {
-            // No provider found
-            return null;
-        }
-
-        if (debug) {    // Extra check to avoid computing cl strings
-            dPrint("found jar resource=" + serviceId + " using ClassLoader: " + cl);
-        }
-
-        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();
-            rd.close();
-        } catch (IOException x) {
-            // No provider found
-            return null;
-        }
-
-        if (factoryClassName != null && !"".equals(factoryClassName)) {
-            dPrint("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;
-    }
-
-    static class ConfigurationError extends Error {
-        private Exception exception;
-
-        /**
-         * Construct a new instance with the specified detail string and
-         * exception.
-         */
-        ConfigurationError(String msg, Exception x) {
-            super(msg);
-            this.exception = x;
-        }
-
-        Exception getException() {
-            return exception;
-        }
-        /**
-        * use the exception chaining mechanism of JDK1.4
-        */
-        @Override
-        public Throwable getCause() {
-            return exception;
+            return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                public T run() {
+                    final ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
+                    final Iterator<T> iterator = serviceLoader.iterator();
+                    if (iterator.hasNext()) {
+                        return iterator.next();
+                    } else {
+                        return null;
+                    }
+                }
+            });
+        } catch(ServiceConfigurationError e) {
+            final DatatypeConfigurationException error =
+                    new DatatypeConfigurationException(
+                        "Provider for " + type + " cannot be found", e);
+            throw error;
         }
     }
 
--- a/src/javax/xml/parsers/DocumentBuilderFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/parsers/DocumentBuilderFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,9 +40,6 @@
 
 public abstract class DocumentBuilderFactory {
 
-    /** The default property name according to the JAXP spec */
-    private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.DocumentBuilderFactory";
-
     private boolean validating = false;
     private boolean namespaceAware = false;
     private boolean whitespace = false;
@@ -50,8 +47,6 @@
     private boolean ignoreComments = false;
     private boolean coalescing = false;
 
-    private boolean canonicalState = false;
-
     /**
      * <p>Protected constructor to prevent instantiation.
      * Use {@link #newInstance()}.</p>
@@ -85,14 +80,12 @@
      * of any property in jaxp.properties after it has been read for the first time.
      * </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/javax.xml.parsers.DocumentBuilderFactory</code>
-     * in jars available to the runtime.
+     * Uses the service-provider loading facilities, defined by the
+     * {@link java.util.ServiceLoader} class, to attempt to locate and load an
+     * implementation of the service.
      * </li>
      * <li>
-     * Platform default <code>DocumentBuilderFactory</code> instance.
+     * Otherwise, the system-default implementation is returned.
      * </li>
      * </ul>
      *
@@ -113,21 +106,16 @@
      *
      * @return New instance of a <code>DocumentBuilderFactory</code>
      *
-     * @throws FactoryConfigurationError if the implementation is not
-     *   available or cannot be instantiated.
+     * @throws FactoryConfigurationError in case of {@linkplain
+     * java.util.ServiceConfigurationError service configuration error} or if
+     * the implementation is not available or cannot be instantiated.
      */
     public static DocumentBuilderFactory newInstance() {
-        try {
-            return (DocumentBuilderFactory) FactoryFinder.find(
+        return FactoryFinder.find(
                 /* The default property name according to the JAXP spec */
-                "javax.xml.parsers.DocumentBuilderFactory",
+                DocumentBuilderFactory.class, // "javax.xml.parsers.DocumentBuilderFactory"
                 /* The fallback implementation class name */
                 "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
-
     }
 
     /**
@@ -165,13 +153,9 @@
      * @since 1.6
      */
     public static DocumentBuilderFactory newInstance(String factoryClassName, ClassLoader classLoader){
-        try {
             //do not fallback if given classloader can't find the class, throw exception
-            return (DocumentBuilderFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
+            return FactoryFinder.newInstance(DocumentBuilderFactory.class,
+                        factoryClassName, classLoader, false);
     }
 
     /**
@@ -391,75 +375,64 @@
     public abstract Object getAttribute(String name)
                 throws IllegalArgumentException;
 
-        /**
-         * <p>Set a feature for this <code>DocumentBuilderFactory</code> and <code>DocumentBuilder</code>s created by this factory.</p>
-         *
-         * <p>
-         * Feature names are fully qualified {@link java.net.URI}s.
-         * Implementations may define their own features.
-         * A {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
-         * <code>DocumentBuilder</code>s it creates cannot support the feature.
-         * It is possible for a <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
-         * </p>
-         *
-         * <p>
-         * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
-         * When the feature is:</p>
-         * <ul>
-         *   <li>
-         *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-         *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
-         *     If XML processing is limited for security reasons, it will be reported via a call to the registered
-         *    {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
-         *     See {@link  DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
-         *   </li>
-         *   <li>
-         *     <code>false</code>: the implementation will processing XML according to the XML specifications without
-         *     regard to possible implementation limits.
-         *   </li>
-         * </ul>
-         *
-         * @param name Feature name.
-         * @param value Is feature state <code>true</code> or <code>false</code>.
-         *
-         * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code> or the <code>DocumentBuilder</code>s
-         *   it creates cannot support this feature.
+    /**
+     * <p>Set a feature for this <code>DocumentBuilderFactory</code> and <code>DocumentBuilder</code>s created by this factory.</p>
+     *
+     * <p>
+     * Feature names are fully qualified {@link java.net.URI}s.
+     * Implementations may define their own features.
+     * A {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
+     * <code>DocumentBuilder</code>s it creates cannot support the feature.
+     * It is possible for a <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
+     * </p>
+     *
+     * <p>
+     * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
+     * When the feature is:</p>
+     * <ul>
+     *   <li>
+     *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
+     *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+     *     If XML processing is limited for security reasons, it will be reported via a call to the registered
+     *    {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
+     *     See {@link  DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
+     *   </li>
+     *   <li>
+     *     <code>false</code>: the implementation will processing XML according to the XML specifications without
+     *     regard to possible implementation limits.
+     *   </li>
+     * </ul>
+     *
+     * @param name Feature name.
+     * @param value Is feature state <code>true</code> or <code>false</code>.
+     *
+     * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code> or the <code>DocumentBuilder</code>s
+     *   it creates cannot support this feature.
      * @throws NullPointerException If the <code>name</code> parameter is null.
-         */
-        public abstract void setFeature(String name, boolean value)
-                throws ParserConfigurationException;
+     */
+    public abstract void setFeature(String name, boolean value)
+            throws ParserConfigurationException;
 
-        /**
-         * <p>Get the state of the named feature.</p>
-         *
-         * <p>
-         * Feature names are fully qualified {@link java.net.URI}s.
-         * Implementations may define their own features.
-         * An {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
-         * <code>DocumentBuilder</code>s it creates cannot support the feature.
-         * It is possible for an <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
-         * </p>
-         *
-         * @param name Feature name.
-         *
-         * @return State of the named feature.
-         *
-         * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code>
-         *   or the <code>DocumentBuilder</code>s it creates cannot support this feature.
-         */
-        public abstract boolean getFeature(String name)
-                throws ParserConfigurationException;
-
-
-    /** <p>Get current state of canonicalization.</p>
+    /**
+     * <p>Get the state of the named feature.</p>
      *
-     * @return current state canonicalization control
+     * <p>
+     * Feature names are fully qualified {@link java.net.URI}s.
+     * Implementations may define their own features.
+     * An {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
+     * <code>DocumentBuilder</code>s it creates cannot support the feature.
+     * It is possible for an <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
+     * </p>
+     *
+     * @param name Feature name.
+     *
+     * @return State of the named feature.
+     *
+     * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code>
+     *   or the <code>DocumentBuilder</code>s it creates cannot support this feature.
      */
-    /*
-    public boolean getCanonicalization() {
-        return canonicalState;
-    }
-    */
+    public abstract boolean getFeature(String name)
+            throws ParserConfigurationException;
 
 
     /**
@@ -488,17 +461,6 @@
 
     }
 
-    /* <p>Set canonicalization control to <code>true</code> or
-     * </code>false</code>.</p>
-     *
-     * @param state of canonicalization
-     */
-    /*
-    public void setCanonicalization(boolean state) {
-        canonicalState = state;
-    }
-    */
-
     /**
      * <p>Set the {@link Schema} to be used by parsers created
      * from this factory.
--- a/src/javax/xml/parsers/FactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/parsers/FactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,16 @@
 
 package javax.xml.parsers;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
 import java.util.Properties;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
- * <p>Implements pluggable Datatypes.</p>
+ * <p>Implements pluggable Parsers.</p>
  *
  * <p>This class is duplicated for each JAXP subpackage so keep it in
  * sync.  It is package private for secure class loading.</p>
@@ -42,7 +43,7 @@
  * @author Huizhe.Wang@oracle.com
  */
 class FactoryFinder {
-
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
     /**
      * Internal debug flag.
      */
@@ -51,7 +52,7 @@
     /**
      * Cache for properties in java.home/lib/jaxp.properties
      */
-    static Properties cacheProps = new Properties();
+    private static final Properties cacheProps = new Properties();
 
     /**
      * Flag indicating if properties from java.home/lib/jaxp.properties
@@ -63,7 +64,7 @@
      * Security support class use to check access control before
      * getting certain system resources.
      */
-    static SecuritySupport ss = new SecuritySupport();
+    private static final SecuritySupport ss = new SecuritySupport();
 
     // Define system property "jaxp.debug" to get output
     static {
@@ -96,31 +97,31 @@
      *
      * Use bootstrap classLoader if cl = null and useBSClsLoader is true
      */
-    static private Class getProviderClass(String className, ClassLoader cl,
+    static private Class<?> getProviderClass(String className, ClassLoader cl,
             boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException
     {
         try {
             if (cl == null) {
                 if (useBSClsLoader) {
-                    return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                    return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
                     cl = ss.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
                     else {
-                        return cl.loadClass(className);
+                        return Class.forName(className, false, cl);
                     }
                 }
             }
             else {
-                return cl.loadClass(className);
+                return Class.forName(className, false, cl);
             }
         }
         catch (ClassNotFoundException e1) {
             if (doFallback) {
                 // Use current class loader - should always be bootstrap CL
-                return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                return Class.forName(className, false, FactoryFinder.class.getClassLoader());
             }
             else {
                 throw e1;
@@ -132,6 +133,9 @@
      * Create an instance of a class. Delegates to method
      * <code>getProviderClass()</code> in order to load the class.
      *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
      * @param className Name of the concrete class corresponding to the
      * service provider
      *
@@ -141,16 +145,20 @@
      * @param doFallback True if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
      */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback)
-        throws ConfigurationError
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl,
+                             boolean doFallback)
+        throws FactoryConfigurationError
     {
-        return newInstance(className, cl, doFallback, false);
+        return newInstance(type, className, cl, doFallback, false);
     }
 
     /**
      * Create an instance of a class. Delegates to method
      * <code>getProviderClass()</code> in order to load the class.
      *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
      * @param className Name of the concrete class corresponding to the
      * service provider
      *
@@ -163,26 +171,38 @@
      * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter
      * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader.
      */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader)
-        throws ConfigurationError
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl,
+                             boolean doFallback, boolean useBSClsLoader)
+        throws FactoryConfigurationError
     {
+        assert type != null;
+        // make sure we have access to restricted packages
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                cl = null;
+                useBSClsLoader = true;
+            }
+        }
+
         try {
-            Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            if (!type.isAssignableFrom(providerClass)) {
+                throw new ClassCastException(className + " cannot be cast to " + type.getName());
+            }
             Object instance = providerClass.newInstance();
             if (debug) {    // Extra check to avoid computing cl strings
                 dPrint("created new instance of " + providerClass +
                        " using ClassLoader: " + cl);
             }
-            return instance;
+            return type.cast(instance);
         }
         catch (ClassNotFoundException x) {
-            throw new ConfigurationError(
-                "Provider " + className + " not found", x);
+            throw new FactoryConfigurationError(x,
+                "Provider " + className + " not found");
         }
         catch (Exception x) {
-            throw new ConfigurationError(
-                "Provider " + className + " could not be instantiated: " + x,
-                x);
+            throw new FactoryConfigurationError(x,
+                "Provider " + className + " could not be instantiated: " + x);
         }
     }
 
@@ -191,16 +211,17 @@
      * entry point.
      * @return Class object of factory, never null
      *
-     * @param factoryId             Name of the factory to find, same as
-     *                              a property name
+     * @param type                  Base class / Service interface  of the
+     *                              factory to find.
      * @param fallbackClassName     Implementation class name, if nothing else
      *                              is found.  Use null to mean no fallback.
      *
      * Package private so this code can be shared.
      */
-    static Object find(String factoryId, String fallbackClassName)
-        throws ConfigurationError
+    static <T> T find(Class<T> type, String fallbackClassName)
+        throws FactoryConfigurationError
     {
+        final String factoryId = type.getName();
         dPrint("find factoryId =" + factoryId);
 
         // Use the system property first
@@ -208,7 +229,7 @@
             String systemProp = ss.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint("found system property, value=" + systemProp);
-                return newInstance(systemProp, null, true);
+                return newInstance(type, systemProp, null, true);
             }
         }
         catch (SecurityException se) {
@@ -217,7 +238,6 @@
 
         // try to read from $java.home/lib/jaxp.properties
         try {
-            String factoryClassName = null;
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
@@ -232,11 +252,11 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(factoryId);
+            final String factoryClassName = cacheProps.getProperty(factoryId);
 
             if (factoryClassName != null) {
                 dPrint("found in $java.home/jaxp.properties, value=" + factoryClassName);
-                return newInstance(factoryClassName, null, true);
+                return newInstance(type, factoryClassName, null, true);
             }
         }
         catch (Exception ex) {
@@ -244,112 +264,52 @@
         }
 
         // Try Jar Service Provider Mechanism
-        Object provider = findJarServiceProvider(factoryId);
+        T provider = findServiceProvider(type);
         if (provider != null) {
             return provider;
         }
         if (fallbackClassName == null) {
-            throw new ConfigurationError(
-                "Provider for " + factoryId + " cannot be found", null);
+            throw new FactoryConfigurationError(
+                "Provider for " + factoryId + " cannot be found");
         }
 
         dPrint("loaded from fallback value: " + fallbackClassName);
-        return newInstance(fallbackClassName, null, true);
+        return newInstance(type, fallbackClassName, null, true);
     }
 
     /*
-     * Try to find provider using Jar Service Provider Mechanism
+     * Try to find provider using the ServiceLoader API
+     *
+     * @param type Base class / Service interface  of the factory to find.
      *
      * @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 = ss.getContextClassLoader();
-        boolean useBSClsLoader = false;
-        if (cl != null) {
-            is = ss.getResourceAsStream(cl, serviceId);
-
-            // If no provider found then try the current ClassLoader
-            if (is == null) {
-                cl = FactoryFinder.class.getClassLoader();
-                is = ss.getResourceAsStream(cl, serviceId);
-                useBSClsLoader = true;
-            }
-        } else {
-            // No Context ClassLoader, try the current ClassLoader
-            cl = FactoryFinder.class.getClassLoader();
-            is = ss.getResourceAsStream(cl, serviceId);
-            useBSClsLoader = true;
-        }
-
-        if (is == null) {
-            // No provider found
-            return null;
-        }
-
-        if (debug) {    // Extra check to avoid computing cl strings
-            dPrint("found jar resource=" + serviceId + " using ClassLoader: " + cl);
-        }
-
-        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;
+    private static <T> T findServiceProvider(final Class<T> type) {
         try {
-            // XXX Does not handle all possible input as specified by the
-            // Jar Service Provider specification
-            factoryClassName = rd.readLine();
-            rd.close();
-        } catch (IOException x) {
-            // No provider found
-            return null;
-        }
-
-        if (factoryClassName != null && !"".equals(factoryClassName)) {
-            dPrint("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, useBSClsLoader);
-        }
-
-        // No provider found
-        return null;
-    }
-
-    static class ConfigurationError extends Error {
-        private Exception exception;
-
-        /**
-         * Construct a new instance with the specified detail string and
-         * exception.
-         */
-        ConfigurationError(String msg, Exception x) {
-            super(msg);
-            this.exception = x;
-        }
-
-        Exception getException() {
-            return exception;
-        }
-        /**
-        * use the exception chaining mechanism of JDK1.4
-        */
-        @Override
-        public Throwable getCause() {
-            return exception;
+            return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                public T run() {
+                    final ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
+                    final Iterator<T> iterator = serviceLoader.iterator();
+                    if (iterator.hasNext()) {
+                        return iterator.next();
+                    } else {
+                        return null;
+                    }
+                 }
+            });
+        } catch(ServiceConfigurationError e) {
+            // It is not possible to wrap an error directly in
+            // FactoryConfigurationError - so we need to wrap the
+            // ServiceConfigurationError in a RuntimeException.
+            // The alternative would be to modify the logic in
+            // FactoryConfigurationError to allow setting a
+            // Throwable as the cause, but that could cause
+            // compatibility issues down the road.
+            final RuntimeException x = new RuntimeException(
+                    "Provider for " + type + " cannot be created", e);
+            final FactoryConfigurationError error =
+                    new FactoryConfigurationError(x, x.getMessage());
+            throw error;
         }
     }
 
--- a/src/javax/xml/parsers/SAXParserFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/parsers/SAXParserFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package javax.xml.parsers;
 
 import javax.xml.validation.Schema;
-
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
@@ -42,8 +41,6 @@
  *
  */
 public abstract class SAXParserFactory {
-    /** The default property name according to the JAXP spec */
-    private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.SAXParserFactory";
 
     /**
      * <p>Should Parsers be validating?</p>
@@ -87,14 +84,12 @@
      * of any property in jaxp.properties after it has been read for the first time.
      * </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/javax.xml.parsers.SAXParserFactory</code>
-     * in jars available to the runtime.
+     * Use the service-provider loading facilities, defined by the
+     * {@link java.util.ServiceLoader} class, to attempt to locate and load an
+     * implementation of the service.
      * </li>
      * <li>
-     * Platform default <code>SAXParserFactory</code> instance.
+     * Otherwise the system-default implementation is returned.
      * </li>
      * </ul>
      *
@@ -109,7 +104,7 @@
      * this method to print a lot of debug messages
      * to <code>System.err</code> about what it is doing and where it is looking at.</p>
      *
-     * <p> If you have problems loading {@link DocumentBuilder}s, try:</p>
+     * <p> If you have problems loading {@link SAXParser}s, try:</p>
      * <pre>
      * java -Djaxp.debug=1 YourProgram ....
      * </pre>
@@ -117,21 +112,17 @@
      *
      * @return A new instance of a SAXParserFactory.
      *
-     * @throws FactoryConfigurationError if the implementation is
-     *   not available or cannot be instantiated.
+     * @throws FactoryConfigurationError in case of {@linkplain
+     * java.util.ServiceConfigurationError service configuration error} or if
+     * the implementation is not available or cannot be instantiated.
      */
 
     public static SAXParserFactory newInstance() {
-        try {
-            return (SAXParserFactory) FactoryFinder.find(
+        return FactoryFinder.find(
                 /* The default property name according to the JAXP spec */
-                "javax.xml.parsers.SAXParserFactory",
+                SAXParserFactory.class,
                 /* The fallback implementation class name */
                 "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
     }
 
     /**
@@ -169,13 +160,9 @@
      * @since 1.6
      */
     public static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader){
-        try {
             //do not fallback if given classloader can't find the class, throw exception
-            return (SAXParserFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
+            return FactoryFinder.newInstance(SAXParserFactory.class,
+                    factoryClassName, classLoader, false);
     }
 
     /**
@@ -266,22 +253,22 @@
      * A list of the core features and properties can be found at
      * <a href="http://www.saxproject.org/">http://www.saxproject.org/</a></p>
      *
-         * <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
-         * When the feature is</p>
-         * <ul>
-         *   <li>
-         *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-         *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
-         *     If XML processing is limited for security reasons, it will be reported via a call to the registered
-         *     {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
-         *     See {@link SAXParser} <code>parse</code> methods for handler specification.
-         *   </li>
-         *   <li>
-         *     When the feature is <code>false</code>, the implementation will processing XML according to the XML specifications without
-         *     regard to possible implementation limits.
-         *   </li>
-         * </ul>
-         *
+     * <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
+     * When the feature is</p>
+     * <ul>
+     *   <li>
+     *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
+     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
+     *     If XML processing is limited for security reasons, it will be reported via a call to the registered
+     *     {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
+     *     See {@link SAXParser} <code>parse</code> methods for handler specification.
+     *   </li>
+     *   <li>
+     *     When the feature is <code>false</code>, the implementation will processing XML according to the XML specifications without
+     *     regard to possible implementation limits.
+     *   </li>
+     * </ul>
+     *
      * @param name The name of the feature to be set.
      * @param value The value of the feature to be set.
      *
@@ -320,17 +307,6 @@
                 SAXNotSupportedException;
 
 
-
-    /* <p>Get current state of canonicalization.</p>
-     *
-     * @return current state canonicalization control
-     */
-    /*
-    public boolean getCanonicalization() {
-        return canonicalState;
-    }
-    */
-
     /**
      * Gets the {@link Schema} object specified through
      * the {@link #setSchema(Schema schema)} method.
@@ -357,17 +333,6 @@
             );
     }
 
-    /** <p>Set canonicalization control to <code>true</code> or
-     * </code>false</code>.</p>
-     *
-     * @param state of canonicalization
-     */
-    /*
-    public void setCanonicalization(boolean state) {
-        canonicalState = state;
-    }
-    */
-
     /**
      * <p>Set the {@link Schema} to be used by parsers created
      * from this factory.</p>
@@ -400,7 +365,7 @@
      * Such configuration will cause a {@link SAXException}
      * exception when those properties are set on a {@link SAXParser}.</p>
      *
-     * <h4>Note for implmentors</h4>
+     * <h4>Note for implementors</h4>
      * <p>
      * A parser must be able to work with any {@link Schema}
      * implementation. However, parsers and schemas are allowed
--- a/src/javax/xml/stream/FactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/stream/FactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,16 @@
 
 package javax.xml.stream;
 
-import java.io.InputStream;
-import java.io.IOException;
 import java.io.File;
-import java.io.FileInputStream;
-
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
 import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
- * <p>Implements pluggable Datatypes.</p>
+ * <p>Implements pluggable streams.</p>
  *
  * <p>This class is duplicated for each JAXP subpackage so keep it in
  * sync.  It is package private for secure class loading.</p>
@@ -43,6 +42,8 @@
  * @author Santiago.PericasGeertsen@sun.com
  */
 class FactoryFinder {
+    // Check we have access to package.
+    private static final String DEFAULT_PACKAGE = "com.sun.xml.internal.";
 
     /**
      * Internal debug flag.
@@ -52,19 +53,19 @@
     /**
      * Cache for properties in java.home/lib/jaxp.properties
      */
-    static Properties cacheProps = new Properties();
+    final private static Properties cacheProps = new Properties();
 
     /**
      * Flag indicating if properties from java.home/lib/jaxp.properties
      * have been cached.
      */
-    static volatile boolean firstTime = true;
+    private static volatile boolean firstTime = true;
 
     /**
      * Security support class use to check access control before
      * getting certain system resources.
      */
-    static SecuritySupport ss = new SecuritySupport();
+    final private static SecuritySupport ss = new SecuritySupport();
 
     // Define system property "jaxp.debug" to get output
     static {
@@ -94,28 +95,34 @@
      * If the class loader supplied is <code>null</code>, first try using the
      * context class loader followed by the current (i.e. bootstrap) class
      * loader.
+     *
+     * Use bootstrap classLoader if cl = null and useBSClsLoader is true
      */
     static private Class getProviderClass(String className, ClassLoader cl,
-            boolean doFallback) throws ClassNotFoundException
+            boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException
     {
         try {
             if (cl == null) {
-                cl = ss.getContextClassLoader();
-                if (cl == null) {
-                    throw new ClassNotFoundException();
-                }
-                else {
-                    return cl.loadClass(className);
+                if (useBSClsLoader) {
+                    return Class.forName(className, false, FactoryFinder.class.getClassLoader());
+                } else {
+                    cl = ss.getContextClassLoader();
+                    if (cl == null) {
+                        throw new ClassNotFoundException();
+                    }
+                    else {
+                        return Class.forName(className, false, cl);
+                    }
                 }
             }
             else {
-                return cl.loadClass(className);
+                return Class.forName(className, false, cl);
             }
         }
         catch (ClassNotFoundException e1) {
             if (doFallback) {
                 // Use current class loader - should always be bootstrap CL
-                return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                return Class.forName(className, false, FactoryFinder.class.getClassLoader());
             }
             else {
                 throw e1;
@@ -127,33 +134,75 @@
      * Create an instance of a class. Delegates to method
      * <code>getProviderClass()</code> in order to load the class.
      *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
      * @param className Name of the concrete class corresponding to the
      * service provider
      *
-     * @param cl ClassLoader to use to load the class, null means to use
-     * the bootstrap ClassLoader
+     * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code>
+     * current <code>Thread</code>'s context classLoader is used to load the factory class.
      *
      * @param doFallback True if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
      */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback)
-        throws ConfigurationError
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl, boolean doFallback)
+        throws FactoryConfigurationError
     {
+        return newInstance(type, className, cl, doFallback, false);
+    }
+
+    /**
+     * Create an instance of a class. Delegates to method
+     * <code>getProviderClass()</code> in order to load the class.
+     *
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
+     *
+     * @param className Name of the concrete class corresponding to the
+     * service provider
+     *
+     * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code>
+     * current <code>Thread</code>'s context classLoader is used to load the factory class.
+     *
+     * @param doFallback True if the current ClassLoader should be tried as
+     * a fallback if the class is not found using cl
+     *
+     * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter
+     * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader.
+     */
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl,
+                              boolean doFallback, boolean useBSClsLoader)
+        throws FactoryConfigurationError
+    {
+        assert type != null;
+
+        // make sure we have access to restricted packages
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                cl = null;
+                useBSClsLoader = true;
+            }
+        }
+
         try {
-            Class providerClass = getProviderClass(className, cl, doFallback);
+            Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            if (!type.isAssignableFrom(providerClass)) {
+                throw new ClassCastException(className + " cannot be cast to " + type.getName());
+            }
             Object instance = providerClass.newInstance();
             if (debug) {    // Extra check to avoid computing cl strings
                 dPrint("created new instance of " + providerClass +
                        " using ClassLoader: " + cl);
             }
-            return instance;
+            return type.cast(instance);
         }
         catch (ClassNotFoundException x) {
-            throw new ConfigurationError(
+            throw new FactoryConfigurationError(
                 "Provider " + className + " not found", x);
         }
         catch (Exception x) {
-            throw new ConfigurationError(
+            throw new FactoryConfigurationError(
                 "Provider " + className + " could not be instantiated: " + x,
                 x);
         }
@@ -164,17 +213,18 @@
      *
      * @return Class object of factory, never null
      *
-     * @param factoryId             Name of the factory to find, same as
-     *                              a property name
+     * @param type                  Base class / Service interface  of the
+     *                              factory to find.
+     *
      * @param fallbackClassName     Implementation class name, if nothing else
      *                              is found.  Use null to mean no fallback.
      *
      * Package private so this code can be shared.
      */
-    static Object find(String factoryId, String fallbackClassName)
-        throws ConfigurationError
+    static <T> T find(Class<T> type, String fallbackClassName)
+        throws FactoryConfigurationError
     {
-        return find(factoryId, null, fallbackClassName);
+        return find(type, type.getName(), null, fallbackClassName);
     }
 
     /**
@@ -182,6 +232,9 @@
      * entry point.
      * @return Class object of factory, never null
      *
+     * @param type                  Base class / Service interface  of the
+     *                              factory to find.
+     *
      * @param factoryId             Name of the factory to find, same as
      *                              a property name
      *
@@ -193,8 +246,8 @@
      *
      * Package private so this code can be shared.
      */
-    static Object find(String factoryId, ClassLoader cl, String fallbackClassName)
-        throws ConfigurationError
+    static <T> T find(Class<T> type, String factoryId, ClassLoader cl, String fallbackClassName)
+        throws FactoryConfigurationError
     {
         dPrint("find factoryId =" + factoryId);
 
@@ -203,7 +256,9 @@
             String systemProp = ss.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint("found system property, value=" + systemProp);
-                return newInstance(systemProp, null, true);
+                // There's a bug here - because 'cl' is ignored.
+                // This will be handled separately.
+                return newInstance(type, systemProp, null, true);
             }
         }
         catch (SecurityException se) {
@@ -214,7 +269,6 @@
         // $java.home/lib/jaxp.properties if former not present
         String configFile = null;
         try {
-            String factoryClassName = null;
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
@@ -238,122 +292,75 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(factoryId);
+            final String factoryClassName = cacheProps.getProperty(factoryId);
 
             if (factoryClassName != null) {
                 dPrint("found in " + configFile + " value=" + factoryClassName);
-                return newInstance(factoryClassName, null, true);
+                // There's a bug here - because 'cl' is ignored.
+                // This will be handled separately.
+                return newInstance(type, factoryClassName, null, true);
             }
         }
         catch (Exception ex) {
             if (debug) ex.printStackTrace();
         }
 
-        // Try Jar Service Provider Mechanism
-        Object provider = findJarServiceProvider(factoryId);
-        if (provider != null) {
-            return provider;
+        if (type.getName().equals(factoryId)) {
+            // Try Jar Service Provider Mechanism
+            final T provider = findServiceProvider(type);
+            if (provider != null) {
+                return provider;
+            }
+        } else {
+            // We're in the case where a 'custom' factoryId was provided,
+            // and in every case where that happens, we expect that
+            // fallbackClassName will be null.
+            assert fallbackClassName == null;
         }
         if (fallbackClassName == null) {
-            throw new ConfigurationError(
+            throw new FactoryConfigurationError(
                 "Provider for " + factoryId + " cannot be found", null);
         }
 
         dPrint("loaded from fallback value: " + fallbackClassName);
-        return newInstance(fallbackClassName, cl, true);
+        return newInstance(type, fallbackClassName, cl, true);
     }
 
     /*
-     * Try to find provider using Jar Service Provider Mechanism
+     * Try to find provider using the ServiceLoader API
+     *
+     * @param type Base class / Service interface  of the factory to find.
      *
      * @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 = ss.getContextClassLoader();
-        if (cl != null) {
-            is = ss.getResourceAsStream(cl, serviceId);
-
-            // If no provider found then try the current ClassLoader
-            if (is == null) {
-                cl = FactoryFinder.class.getClassLoader();
-                is = ss.getResourceAsStream(cl, serviceId);
-            }
-        } else {
-            // No Context ClassLoader, try the current ClassLoader
-            cl = FactoryFinder.class.getClassLoader();
-            is = ss.getResourceAsStream(cl, serviceId);
-        }
-
-        if (is == null) {
-            // No provider found
-            return null;
-        }
-
-        if (debug) {    // Extra check to avoid computing cl strings
-            dPrint("found jar resource=" + serviceId + " using ClassLoader: " + cl);
-        }
-
-        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;
+    private static <T> T findServiceProvider(final Class<T> type) {
         try {
-            // XXX Does not handle all possible input as specified by the
-            // Jar Service Provider specification
-            factoryClassName = rd.readLine();
-            rd.close();
-        } catch (IOException x) {
-            // No provider found
-            return null;
-        }
-
-        if (factoryClassName != null && !"".equals(factoryClassName)) {
-            dPrint("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;
-    }
-
-    static class ConfigurationError extends Error {
-        private Exception exception;
-
-        /**
-         * Construct a new instance with the specified detail string and
-         * exception.
-         */
-        ConfigurationError(String msg, Exception x) {
-            super(msg);
-            this.exception = x;
-        }
-
-        Exception getException() {
-            return exception;
-        }
-        /**
-        * use the exception chaining mechanism of JDK1.4
-        */
-        @Override
-        public Throwable getCause() {
-            return exception;
-        }
-    }
+            return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                @Override
+                public T run() {
+                    final ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
+                    final Iterator<T> iterator = serviceLoader.iterator();
+                    if (iterator.hasNext()) {
+                        return iterator.next();
+                    } else {
+                        return null;
+                    }
+                }
+            });
+        } catch(ServiceConfigurationError e) {
+            // It is not possible to wrap an error directly in
+            // FactoryConfigurationError - so we need to wrap the
+            // ServiceConfigurationError in a RuntimeException.
+            // The alternative would be to modify the logic in
+            // FactoryConfigurationError to allow setting a
+            // Throwable as the cause, but that could cause
+            // compatibility issues down the road.
+            final RuntimeException x = new RuntimeException(
+                    "Provider for " + type + " cannot be created", e);
+            final FactoryConfigurationError error =
+                    new FactoryConfigurationError(x, x.getMessage());
+            throw error;
+          }
+      }
 
 }
--- a/src/javax/xml/stream/XMLEventFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/stream/XMLEventFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,14 +23,14 @@
  */
 
 /*
- * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
+ * Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
  */
 
 package javax.xml.stream;
-import javax.xml.stream.events.*;
+import java.util.Iterator;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import java.util.Iterator;
+import javax.xml.stream.events.*;
 /**
  * This interface defines a utility class for creating instances of
  * XMLEvents
@@ -54,48 +54,59 @@
 
 
   /**
-   * Create a new instance of the factory
+   * Creates a new instance of the factory in exactly the same manner as the
+   * {@link #newFactory()} method.
    * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
    */
   public static XMLEventFactory newInstance()
     throws FactoryConfigurationError
   {
-    return (XMLEventFactory) FactoryFinder.find(
-      JAXPFACTORYID,
-      DEFAULIMPL);
+    return FactoryFinder.find(XMLEventFactory.class, DEFAULIMPL);
   }
 
   /**
    * Create a new instance of the factory.
+   * <p>
    * This static method creates a new factory instance.
    * This method uses the following ordered lookup procedure to determine
    * the XMLEventFactory implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
    *   Use the javax.xml.stream.XMLEventFactory system property.
+   * </li>
+   * <li>
    *   Use the properties file "lib/stax.properties" in the JRE directory.
    *     This configuration file is in standard java.util.Properties format
    *     and contains the fully qualified name of the implementation class
    *     with the key being the system property defined above.
-   *   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 META-INF/services/javax.xml.stream.XMLEventFactory in jars
-   *     available to the runtime.
-   *   Platform default XMLEventFactory instance.
-   *
+   * </li>
+   * <li>
+   *   Use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   *   Otherwise, the system-default implementation is returned.
+   * </li>
+   * </ul>
+   * <p>
    *   Once an application has obtained a reference to a XMLEventFactory it
    *   can use the factory to configure and obtain stream instances.
-   *
+   * </p>
+   * <p>
    *   Note that this is a new method that replaces the deprecated newInstance() method.
    *     No changes in behavior are defined by this replacement method relative to
    *     the deprecated method.
-   *
-   * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
+   * </p>
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    */
   public static XMLEventFactory newFactory()
     throws FactoryConfigurationError
   {
-    return (XMLEventFactory) FactoryFinder.find(
-      JAXPFACTORYID,
-      DEFAULIMPL);
+    return FactoryFinder.find(XMLEventFactory.class, DEFAULIMPL);
   }
 
   /**
@@ -116,40 +127,59 @@
   public static XMLEventFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null);
   }
 
   /**
    * Create a new instance of the factory.
    * If the classLoader argument is null, then the ContextClassLoader is used.
+   * <p>
+   * This method uses the following ordered lookup procedure to determine
+   * the XMLEventFactory implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
+   *   Use the value of the system property identified by {@code factoryId}.
+   * </li>
+   * <li>
+   *   Use the properties file "lib/stax.properties" in the JRE directory.
+   *     This configuration file is in standard java.util.Properties format
+   *     and contains the fully qualified name of the implementation class
+   *     with the key being the given {@code factoryId}.
+   * </li>
+   * <li>
+   *   If {@code factoryId} is "javax.xml.stream.XMLEventFactory",
+   *   use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   *   Otherwise, throws a {@link FactoryConfigurationError}.
+   * </li>
+   * </ul>
    *
+   * <p>
    * Note that this is a new method that replaces the deprecated
-   *   newInstance(String factoryId, ClassLoader classLoader) method.
+   *   {@link #newInstance(java.lang.String, java.lang.ClassLoader)
+   *   newInstance(String factoryId, ClassLoader classLoader)} method.
    * No changes in behavior are defined by this replacement method relative
    * to the deprecated method.
+   * </p>
    *
    * @param factoryId             Name of the factory to find, same as
    *                              a property name
    * @param classLoader           classLoader to use
    * @return the factory implementation
-   * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    */
   public static XMLEventFactory newFactory(String factoryId,
-          ClassLoader classLoader)
+                                           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null);
   }
 
  /**
--- a/src/javax/xml/stream/XMLInputFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/stream/XMLInputFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,13 +23,13 @@
  */
 
 /*
- * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
+ * Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
  */
 
 package javax.xml.stream;
 
+import javax.xml.stream.util.XMLEventAllocator;
 import javax.xml.transform.Source;
-import javax.xml.stream.util.XMLEventAllocator;
 
 /**
  * Defines an abstract implementation of a factory for getting streams.
@@ -144,48 +144,59 @@
   protected XMLInputFactory(){}
 
   /**
-   * Create a new instance of the factory.
+   * Creates a new instance of the factory in exactly the same manner as the
+   * {@link #newFactory()} method.
    * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
    */
   public static XMLInputFactory newInstance()
     throws FactoryConfigurationError
   {
-    return (XMLInputFactory) FactoryFinder.find(
-      "javax.xml.stream.XMLInputFactory",
-      DEFAULIMPL);
+    return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL);
   }
 
   /**
    * Create a new instance of the factory.
+   * <p>
    * This static method creates a new factory instance.
    * This method uses the following ordered lookup procedure to determine
    * the XMLInputFactory implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
    *   Use the javax.xml.stream.XMLInputFactory system property.
+   * </li>
+   * <li>
    *   Use the properties file "lib/stax.properties" in the JRE directory.
    *     This configuration file is in standard java.util.Properties format
    *     and contains the fully qualified name of the implementation class
    *     with the key being the system property defined above.
-   *   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 META-INF/services/javax.xml.stream.XMLInputFactory in jars
-   *     available to the runtime.
-   *   Platform default XMLInputFactory instance.
-   *
+   * </li>
+   * <li>
+   *   Use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   * Otherwise, the system-default implementation is returned.
+   * </li>
+   * </ul>
+   * <p>
    *   Once an application has obtained a reference to a XMLInputFactory it
    *   can use the factory to configure and obtain stream instances.
-   *
+   * </p>
+   * <p>
    *   Note that this is a new method that replaces the deprecated newInstance() method.
    *     No changes in behavior are defined by this replacement method relative to
    *     the deprecated method.
-   *
-   * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
+   * </p>
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    */
   public static XMLInputFactory newFactory()
     throws FactoryConfigurationError
   {
-    return (XMLInputFactory) FactoryFinder.find(
-      "javax.xml.stream.XMLInputFactory",
-      DEFAULIMPL);
+    return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL);
   }
 
   /**
@@ -206,40 +217,60 @@
   public static XMLInputFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
   }
 
   /**
    * Create a new instance of the factory.
    * If the classLoader argument is null, then the ContextClassLoader is used.
+   * <p>
+   * This method uses the following ordered lookup procedure to determine
+   * the XMLInputFactory implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
+   *   Use the value of the system property identified by {@code factoryId}.
+   * </li>
+   * <li>
+   *   Use the properties file "lib/stax.properties" in the JRE directory.
+   *     This configuration file is in standard java.util.Properties format
+   *     and contains the fully qualified name of the implementation class
+   *     with the key being the given {@code factoryId}.
+   * </li>
+   * <li>
+   *   If {@code factoryId} is "javax.xml.stream.XMLInputFactory",
+   *   use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   *   Otherwise, throws a {@link FactoryConfigurationError}.
+   * </li>
+   * </ul>
    *
+   * <p>
    * Note that this is a new method that replaces the deprecated
-   *   newInstance(String factoryId, ClassLoader classLoader) method.
+   *   {@link #newInstance(java.lang.String, java.lang.ClassLoader)
+   *   newInstance(String factoryId, ClassLoader classLoader)} method.
    * No changes in behavior are defined by this replacement method relative
    * to the deprecated method.
+   * </p>
    *
    * @param factoryId             Name of the factory to find, same as
    *                              a property name
    * @param classLoader           classLoader to use
    * @return the factory implementation
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
    */
   public static XMLInputFactory newFactory(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
   }
 
   /**
--- a/src/javax/xml/stream/XMLOutputFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/stream/XMLOutputFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -23,7 +23,7 @@
  */
 
 /*
- * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
+ * Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
  */
 
 package javax.xml.stream;
@@ -120,46 +120,58 @@
   protected XMLOutputFactory(){}
 
   /**
-   * Create a new instance of the factory.
+   * Creates a new instance of the factory in exactly the same manner as the
+   * {@link #newFactory()} method.
    * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
    */
   public static XMLOutputFactory newInstance()
     throws FactoryConfigurationError
   {
-    return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
-                                                 DEFAULIMPL);
+    return FactoryFinder.find(XMLOutputFactory.class, DEFAULIMPL);
   }
 
   /**
    * Create a new instance of the factory.
+   * <p>
    * This static method creates a new factory instance. This method uses the
    * following ordered lookup procedure to determine the XMLOutputFactory
    * implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
    *   Use the javax.xml.stream.XMLOutputFactory system property.
+   * </li>
+   * <li>
    *   Use the properties file "lib/stax.properties" in the JRE directory.
    *     This configuration file is in standard java.util.Properties format
    *     and contains the fully qualified name of the implementation class
    *     with the key being the system property defined above.
-   *   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 META-INF/services/javax.xml.stream.XMLOutputFactory in jars
-   *     available to the runtime.
-   *   Platform default XMLOutputFactory instance.
-   *
+   * </li>
+   * <li>
+   *   Use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   *   Otherwise, the system-default implementation is returned.
+   * </li>
+   * <p>
    * Once an application has obtained a reference to a XMLOutputFactory it
    * can use the factory to configure and obtain stream instances.
-   *
+   * </p>
+   * <p>
    * Note that this is a new method that replaces the deprecated newInstance() method.
    *   No changes in behavior are defined by this replacement method relative to the
    *   deprecated method.
-   *
-   * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
+   * </p>
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    */
   public static XMLOutputFactory newFactory()
     throws FactoryConfigurationError
   {
-    return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
-                                                 DEFAULIMPL);
+    return FactoryFinder.find(XMLOutputFactory.class, DEFAULIMPL);
   }
 
   /**
@@ -179,42 +191,59 @@
   public static XMLInputFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
   }
 
   /**
    * Create a new instance of the factory.
    * If the classLoader argument is null, then the ContextClassLoader is used.
-   *
-   * Note that this is a new method that replaces the deprecated
-   *   newInstance(String factoryId, ClassLoader classLoader) method.
+   * <p>
+   * This method uses the following ordered lookup procedure to determine
+   * the XMLOutputFactory implementation class to load:
+   * </p>
+   * <ul>
+   * <li>
+   *   Use the value of the system property identified by {@code factoryId}.
+   * </li>
+   * <li>
+   *   Use the properties file "lib/stax.properties" in the JRE directory.
+   *     This configuration file is in standard java.util.Properties format
+   *     and contains the fully qualified name of the implementation class
+   *     with the key being the given {@code factoryId}.
+   * </li>
+   * <li>
+   *   If {@code factoryId} is "javax.xml.stream.XMLOutputFactory",
+   *   use the service-provider loading facilities, defined by the
+   *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+   *   implementation of the service.
+   * </li>
+   * <li>
+   *   Otherwise, throws a {@link FactoryConfigurationError}.
+   * </li>
+   * </ul>
    *
-   *   No changes in behavior are defined by this replacement method relative
-   *   to the deprecated method.
-   *
+   * <p>
+   * Note that this is a new method that replaces the deprecated
+   *   {@link #newInstance(java.lang.String, java.lang.ClassLoader)
+   *   newInstance(String factoryId, ClassLoader classLoader)} method.
+   * No changes in behavior are defined by this replacement method relative
+   * to the deprecated method.
+   * </p>
    *
    * @param factoryId             Name of the factory to find, same as
    *                              a property name
    * @param classLoader           classLoader to use
    * @return the factory implementation
-   * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
+   * @throws FactoryConfigurationError in case of {@linkplain
+   *   java.util.ServiceConfigurationError service configuration error} or if
+   *   the implementation is not available or cannot be instantiated.
    */
   public static XMLOutputFactory newFactory(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
-      try {
-          //do not fallback if given classloader can't find the class, throw exception
-          return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader, null);
-      } catch (FactoryFinder.ConfigurationError e) {
-          throw new FactoryConfigurationError(e.getException(),
-                  e.getMessage());
-      }
+      //do not fallback if given classloader can't find the class, throw exception
+      return FactoryFinder.find(XMLOutputFactory.class, factoryId, classLoader, null);
   }
 
   /**
--- a/src/javax/xml/transform/FactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/transform/FactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,15 @@
 
 package javax.xml.transform;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
 import java.util.Properties;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
  * <p>Implements pluggable Datatypes.</p>
@@ -43,6 +45,7 @@
  * @author Huizhe.Wang@oracle.com
  */
 class FactoryFinder {
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xalan.internal.";
 
     /**
      * Internal debug flag.
@@ -52,7 +55,7 @@
     /**
      * Cache for properties in java.home/lib/jaxp.properties
      */
-    static Properties cacheProps = new Properties();
+    private final static Properties cacheProps = new Properties();
 
     /**
      * Flag indicating if properties from java.home/lib/jaxp.properties
@@ -64,7 +67,7 @@
      * Security support class use to check access control before
      * getting certain system resources.
      */
-    static SecuritySupport ss = new SecuritySupport();
+    private final static SecuritySupport ss = new SecuritySupport();
 
     // Define system property "jaxp.debug" to get output
     static {
@@ -97,31 +100,31 @@
      *
      * Use bootstrap classLoader if cl = null and useBSClsLoader is true
      */
-    static private Class getProviderClass(String className, ClassLoader cl,
+    static private Class<?> getProviderClass(String className, ClassLoader cl,
             boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException
     {
         try {
             if (cl == null) {
                 if (useBSClsLoader) {
-                    return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                    return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
                     cl = ss.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
                     else {
-                        return cl.loadClass(className);
+                        return Class.forName(className, false, cl);
                     }
                 }
             }
             else {
-                return cl.loadClass(className);
+                return Class.forName(className, false, cl);
             }
         }
         catch (ClassNotFoundException e1) {
             if (doFallback) {
                 // Use current class loader - should always be bootstrap CL
-                return Class.forName(className, true, FactoryFinder.class.getClassLoader());
+                return Class.forName(className, false, FactoryFinder.class.getClassLoader());
             }
             else {
                 throw e1;
@@ -133,24 +136,8 @@
      * Create an instance of a class. Delegates to method
      * <code>getProviderClass()</code> in order to load the class.
      *
-     * @param className Name of the concrete class corresponding to the
-     * service provider
-     *
-     * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code>
-     * current <code>Thread</code>'s context classLoader is used to load the factory class.
-     *
-     * @param doFallback True if the current ClassLoader should be tried as
-     * a fallback if the class is not found using cl
-     */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback)
-        throws ConfigurationError
-    {
-        return newInstance(className, cl, doFallback, false, false);
-    }
-
-    /**
-     * Create an instance of a class. Delegates to method
-     * <code>getProviderClass()</code> in order to load the class.
+     * @param type Base class / Service interface  of the factory to
+     *             instantiate.
      *
      * @param className Name of the concrete class corresponding to the
      * service provider
@@ -161,19 +148,31 @@
      * @param doFallback True if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
      *
-     * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter
-     * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader.
-     *
      * @param useServicesMechanism True use services mechanism
      */
-    static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader, boolean useServicesMechanism)
-        throws ConfigurationError
+    static <T> T newInstance(Class<T> type, String className, ClassLoader cl,
+                             boolean doFallback, boolean useServicesMechanism)
+        throws TransformerFactoryConfigurationError
     {
+        assert type != null;
+
+        boolean useBSClsLoader = false;
+        // make sure we have access to restricted packages
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                cl = null;
+                useBSClsLoader = true;
+            }
+        }
+
         try {
-            Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
+            if (!type.isAssignableFrom(providerClass)) {
+                throw new ClassCastException(className + " cannot be cast to " + type.getName());
+            }
             Object instance = null;
             if (!useServicesMechanism) {
-                instance = newInstanceNoServiceLoader(providerClass);
+                instance = newInstanceNoServiceLoader(type, providerClass);
             }
             if (instance == null) {
                 instance = providerClass.newInstance();
@@ -182,63 +181,87 @@
                 dPrint("created new instance of " + providerClass +
                        " using ClassLoader: " + cl);
             }
-            return instance;
+            return type.cast(instance);
         }
         catch (ClassNotFoundException x) {
-            throw new ConfigurationError(
-                "Provider " + className + " not found", x);
+            throw new TransformerFactoryConfigurationError(x,
+                "Provider " + className + " not found");
         }
         catch (Exception x) {
-            throw new ConfigurationError(
-                "Provider " + className + " could not be instantiated: " + x,
-                x);
+            throw new TransformerFactoryConfigurationError(x,
+                "Provider " + className + " could not be instantiated: " + x);
         }
     }
+
     /**
      * Try to construct using newTransformerFactoryNoServiceLoader
      *   method if available.
      */
-    private static Object newInstanceNoServiceLoader(
-         Class<?> providerClass
-    ) {
+    private static <T> T newInstanceNoServiceLoader(Class<T> type, Class<?> providerClass) {
         // Retain maximum compatibility if no security manager.
         if (System.getSecurityManager() == null) {
             return null;
         }
         try {
-            Method creationMethod =
-                providerClass.getDeclaredMethod(
-                    "newTransformerFactoryNoServiceLoader"
-                );
-                return creationMethod.invoke(null, (Object[])null);
-            } catch (NoSuchMethodException exc) {
+            final Method creationMethod =
+                    providerClass.getDeclaredMethod(
+                        "newTransformerFactoryNoServiceLoader"
+                    );
+            final int modifiers = creationMethod.getModifiers();
+
+            // Do not call the method if it's not public static.
+            if (!Modifier.isPublic(modifiers) || !Modifier.isStatic(modifiers)) {
                 return null;
-            } catch (Exception exc) {
-                return null;
+            }
+
+            // Only call the method if it's declared to return an instance of
+            // TransformerFactory
+            final Class<?> returnType = creationMethod.getReturnType();
+            if (type.isAssignableFrom(returnType)) {
+                final Object result = creationMethod.invoke(null, (Object[])null);
+                return type.cast(result);
+            } else {
+                // This should not happen, as
+                // TransformerFactoryImpl.newTransformerFactoryNoServiceLoader is
+                // declared to return TransformerFactory.
+                throw new ClassCastException(returnType + " cannot be cast to " + type);
+            }
+        } catch (ClassCastException e) {
+            throw new TransformerFactoryConfigurationError(e, e.getMessage());
+        } catch (NoSuchMethodException exc) {
+            return null;
+        } catch (Exception exc) {
+            return null;
         }
     }
+
     /**
      * Finds the implementation Class object in the specified order.  Main
      * entry point.
      * @return Class object of factory, never null
      *
-     * @param factoryId             Name of the factory to find, same as
-     *                              a property name
+     * @param type                  Base class / Service interface  of the
+     *                              factory to find.
+     *
      * @param fallbackClassName     Implementation class name, if nothing else
      *                              is found.  Use null to mean no fallback.
      *
      * Package private so this code can be shared.
      */
-    static Object find(String factoryId, String fallbackClassName)
-        throws ConfigurationError
+    static <T> T find(Class<T> type, String fallbackClassName)
+        throws TransformerFactoryConfigurationError
     {
+        assert type != null;
+
+        final String factoryId = type.getName();
+
         dPrint("find factoryId =" + factoryId);
         // Use the system property first
         try {
             String systemProp = ss.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint("found system property, value=" + systemProp);
-                return newInstance(systemProp, null, true, false, true);
+                return newInstance(type, systemProp, null, true, true);
             }
         }
         catch (SecurityException se) {
@@ -247,7 +270,6 @@
 
         // try to read from $java.home/lib/jaxp.properties
         try {
-            String factoryClassName = null;
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
@@ -262,11 +284,11 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(factoryId);
+            final String factoryClassName = cacheProps.getProperty(factoryId);
 
             if (factoryClassName != null) {
                 dPrint("found in $java.home/jaxp.properties, value=" + factoryClassName);
-                return newInstance(factoryClassName, null, true, false, true);
+                return newInstance(type, factoryClassName, null, true, true);
             }
         }
         catch (Exception ex) {
@@ -274,113 +296,54 @@
         }
 
         // Try Jar Service Provider Mechanism
-        Object provider = findJarServiceProvider(factoryId);
+        T provider = findServiceProvider(type);
         if (provider != null) {
             return provider;
         }
         if (fallbackClassName == null) {
-            throw new ConfigurationError(
-                "Provider for " + factoryId + " cannot be found", null);
+            throw new TransformerFactoryConfigurationError(null,
+                "Provider for " + factoryId + " cannot be found");
         }
 
         dPrint("loaded from fallback value: " + fallbackClassName);
-        return newInstance(fallbackClassName, null, true, false, true);
+        return newInstance(type, fallbackClassName, null, true, true);
     }
 
     /*
-     * Try to find provider using Jar Service Provider Mechanism
+     * Try to find provider using the ServiceLoader.
+     *
+     * @param type Base class / Service interface  of the factory to find.
      *
      * @return instance of provider class if found or null
      */
-    private static Object findJarServiceProvider(String factoryId)
-        throws ConfigurationError
+    private static <T> T findServiceProvider(final Class<T> type)
+        throws TransformerFactoryConfigurationError
     {
-        String serviceId = "META-INF/services/" + factoryId;
-        InputStream is = null;
-
-        // First try the Context ClassLoader
-        ClassLoader cl = ss.getContextClassLoader();
-        boolean useBSClsLoader = false;
-        if (cl != null) {
-            is = ss.getResourceAsStream(cl, serviceId);
-
-            // If no provider found then try the current ClassLoader
-            if (is == null) {
-                cl = FactoryFinder.class.getClassLoader();
-                is = ss.getResourceAsStream(cl, serviceId);
-                useBSClsLoader = true;
-           }
-        } else {
-            // No Context ClassLoader, try the current ClassLoader
-            cl = FactoryFinder.class.getClassLoader();
-            is = ss.getResourceAsStream(cl, serviceId);
-            useBSClsLoader = true;
-        }
-
-        if (is == null) {
-            // No provider found
-            return null;
-        }
-
-        if (debug) {    // Extra check to avoid computing cl strings
-            dPrint("found jar resource=" + serviceId + " using ClassLoader: " + cl);
-        }
-
-        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();
-            rd.close();
-        } catch (IOException x) {
-            // No provider found
-            return null;
-        }
-
-        if (factoryClassName != null && !"".equals(factoryClassName)) {
-            dPrint("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, useBSClsLoader, true);
-        }
-
-        // No provider found
-        return null;
-    }
-
-    static class ConfigurationError extends Error {
-        private Exception exception;
-
-        /**
-         * Construct a new instance with the specified detail string and
-         * exception.
-         */
-        ConfigurationError(String msg, Exception x) {
-            super(msg);
-            this.exception = x;
-        }
-
-        Exception getException() {
-            return exception;
-        }
-        /**
-        * use the exception chaining mechanism of JDK1.4
-        */
-        @Override
-        public Throwable getCause() {
-            return exception;
+      try {
+            return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                public T run() {
+                    final ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
+                    final Iterator<T> iterator = serviceLoader.iterator();
+                    if (iterator.hasNext()) {
+                        return iterator.next();
+                    } else {
+                        return null;
+                    }
+                 }
+            });
+        } catch(ServiceConfigurationError e) {
+            // It is not possible to wrap an error directly in
+            // FactoryConfigurationError - so we need to wrap the
+            // ServiceConfigurationError in a RuntimeException.
+            // The alternative would be to modify the logic in
+            // FactoryConfigurationError to allow setting a
+            // Throwable as the cause, but that could cause
+            // compatibility issues down the road.
+            final RuntimeException x = new RuntimeException(
+                    "Provider for " + type + " cannot be created", e);
+            final TransformerFactoryConfigurationError error =
+                    new TransformerFactoryConfigurationError(x, x.getMessage());
+            throw error;
         }
     }
-
 }
--- a/src/javax/xml/transform/TransformerFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/transform/TransformerFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,8 +52,8 @@
 
     /**
      * <p>Obtain a new instance of a <code>TransformerFactory</code>.
-     * This static method creates a new factory instance
-     * This method uses the following ordered lookup procedure to determine
+     * This static method creates a new factory instance.</p>
+     * <p>This method uses the following ordered lookup procedure to determine
      * the <code>TransformerFactory</code> implementation class to
      * load:</p>
      * <ul>
@@ -67,7 +67,7 @@
      * </code> format and contains the fully qualified name of the
      * implementation class with the key being the system property defined
      * above.
-     *
+     * <br>
      * The jaxp.properties file is read only once by the JAXP implementation
      * and it's values are then cached for future use.  If the file does not exist
      * when the first attempt is made to read from it, no further attempts are
@@ -75,14 +75,12 @@
      * of any property in jaxp.properties after it has been read for the first time.
      * </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/javax.xml.transform.TransformerFactory</code>
-     * in jars available to the runtime.
+     *   Use the service-provider loading facilities, defined by the
+     *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+     *   implementation of the service.
      * </li>
      * <li>
-     * Platform default <code>TransformerFactory</code> instance.
+     *   Otherwise, the system-default implementation is returned.
      * </li>
      * </ul>
      *
@@ -92,22 +90,18 @@
      *
      * @return new TransformerFactory instance, never null.
      *
-     * @throws TransformerFactoryConfigurationError Thrown if the implementation
-     *    is not available or cannot be instantiated.
+     * @throws TransformerFactoryConfigurationError Thrown in case of {@linkplain
+     * java.util.ServiceConfigurationError service configuration error} or if
+     * the implementation is not available or cannot be instantiated.
      */
     public static TransformerFactory newInstance()
         throws TransformerFactoryConfigurationError {
-        try {
-            return (TransformerFactory) FactoryFinder.find(
+
+        return FactoryFinder.find(
             /* The default property name according to the JAXP spec */
-            "javax.xml.transform.TransformerFactory",
+            TransformerFactory.class,
             /* The fallback implementation class name, XSLTC */
             "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new TransformerFactoryConfigurationError(
-                e.getException(),
-                e.getMessage());
-        }
     }
 
     /**
@@ -147,14 +141,10 @@
      */
     public static TransformerFactory newInstance(String factoryClassName, ClassLoader classLoader)
         throws TransformerFactoryConfigurationError{
-        try {
-            //do not fallback if given classloader can't find the class, throw exception
-            return (TransformerFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new TransformerFactoryConfigurationError(
-                e.getException(),
-                e.getMessage());
-        }
+
+        //do not fallback if given classloader can't find the class, throw exception
+        return  FactoryFinder.newInstance(TransformerFactory.class,
+                    factoryClassName, classLoader, false, false);
     }
     /**
      * <p>Process the <code>Source</code> into a <code>Transformer</code>
--- a/src/javax/xml/validation/SchemaFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/validation/SchemaFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,14 @@
 
 import java.io.File;
 import java.net.URL;
-
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
-
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
 
 /**
  * Factory that creates {@link Schema} objects&#x2E; Entry-point to
@@ -79,7 +78,7 @@
  * and has a significant effect on the parsing process, it is impossible
  * to define the DTD validation as a process independent from parsing.
  * For this reason, this specification does not define the semantics for
- * the XML DTD. This doesn't prohibit implentors from implementing it
+ * the XML DTD. This doesn't prohibit implementors from implementing it
  * in a way they see fit, but <em>users are warned that any DTD
  * validation implemented on this interface necessarily deviate from
  * the XML DTD semantics as defined in the XML 1.0</em>.
@@ -147,14 +146,17 @@
      *     is looked for. If present, the value is processed just like above.
      *   </li>
      *   <li>
-     *     <p>The class loader is asked for service provider provider-configuration files matching
-     *     <code>javax.xml.validation.SchemaFactory</code> in the resource directory META-INF/services.
-     *     See the JAR File Specification for file format and parsing rules.
-     *     Each potential service provider is required to implement the method:</p>
-     *     <pre>
-     *        {@link #isSchemaLanguageSupported(String schemaLanguage)}
-     *     </pre>
-     *     The first service provider found in class loader order that supports the specified schema language is returned.
+     *   Use the service-provider loading facilities, defined by the
+     *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
+     *   implementation of the service.<br>
+     *   Each potential service provider is required to implement the method
+     *        {@link #isSchemaLanguageSupported(String schemaLanguage)}.
+     *   <br>
+     *   The first service provider found that supports the specified schema
+     *   language is returned.
+     *   <br>
+     *   In case of {@link java.util.ServiceConfigurationError} a
+     *   {@link SchemaFactoryConfigurationError} will be thrown.
      *   </li>
      *   <li>
      *     Platform default <code>SchemaFactory</code> is located
@@ -186,10 +188,12 @@
      *      If no implementation of the schema language is available.
      * @throws NullPointerException
      *      If the <code>schemaLanguage</code> parameter is null.
+     * @throws SchemaFactoryConfigurationError
+     *      If a configuration error is encountered.
      *
      * @see #newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader)
      */
-    public static final SchemaFactory newInstance(String schemaLanguage) {
+    public static SchemaFactory newInstance(String schemaLanguage) {
         ClassLoader cl;
         cl = ss.getContextClassLoader();
 
@@ -275,19 +279,19 @@
 
     }
 
-        /**
-         * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
-         *
-         * @param schemaLanguage Specifies the schema language which the returned <code>SchemaFactory</code> will understand.
+    /**
+     * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
+     *
+     * @param schemaLanguage Specifies the schema language which the returned <code>SchemaFactory</code> will understand.
      *    <code>schemaLanguage</code> must specify a <a href="#schemaLanguage">valid</a> schema language.
-         *
-         * @return <code>true</code> if <code>SchemaFactory</code> supports <code>schemaLanguage</code>, else <code>false</code>.
-         *
-         * @throws NullPointerException If <code>schemaLanguage</code> is <code>null</code>.
-         * @throws IllegalArgumentException If <code>schemaLanguage.length() == 0</code>
-         *   or <code>schemaLanguage</code> does not specify a <a href="#schemaLanguage">valid</a> schema language.
-         */
-        public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
+     *
+     * @return <code>true</code> if <code>SchemaFactory</code> supports <code>schemaLanguage</code>, else <code>false</code>.
+     *
+     * @throws NullPointerException If <code>schemaLanguage</code> is <code>null</code>.
+     * @throws IllegalArgumentException If <code>schemaLanguage.length() == 0</code>
+     *   or <code>schemaLanguage</code> does not specify a <a href="#schemaLanguage">valid</a> schema language.
+     */
+    public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
 
     /**
      * Look up the value of a feature flag.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/javax/xml/validation/SchemaFactoryConfigurationError.java	Fri Sep 27 15:40:15 2013 +0100
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.xml.validation;
+
+/**
+ * Thrown when a problem with configuration with the Schema Factories
+ * exists. This error will typically be thrown when the class of a
+ * schema factory specified in the system properties cannot be found
+ * or instantiated.
+ * @since 1.8
+ */
+public final class SchemaFactoryConfigurationError extends Error {
+
+    static final long serialVersionUID = 3531438703147750126L;
+
+    /**
+     * Create a new <code>SchemaFactoryConfigurationError</code> with no
+     * detail message.
+     */
+    public SchemaFactoryConfigurationError() {
+    }
+
+
+    /**
+     * Create a new <code>SchemaFactoryConfigurationError</code> with
+     * the <code>String</code> specified as an error message.
+     *
+     * @param message The error message for the exception.
+     */
+    public SchemaFactoryConfigurationError(String message) {
+        super(message);
+    }
+
+    /**
+     * Create a new <code>SchemaFactoryConfigurationError</code> with the
+     * given <code>Throwable</code> base cause.
+     *
+     * @param cause The exception or error to be encapsulated in a
+     * SchemaFactoryConfigurationError.
+     */
+    public SchemaFactoryConfigurationError(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Create a new <code>SchemaFactoryConfigurationError</code> with the
+     * given <code>Throwable</code> base cause and detail message.
+     *
+     * @param cause The exception or error to be encapsulated in a
+     * SchemaFactoryConfigurationError.
+     * @param message The detail message.
+     */
+    public SchemaFactoryConfigurationError(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}
--- a/src/javax/xml/validation/SchemaFactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/validation/SchemaFactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,19 +25,16 @@
 
 package javax.xml.validation;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
  * Implementation of {@link SchemaFactory#newInstance(String)}.
@@ -53,16 +50,17 @@
     /**
      *<p> Take care of restrictions imposed by java security model </p>
      */
-    private static SecuritySupport ss = new SecuritySupport();
+    private static final SecuritySupport ss = new SecuritySupport();
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
     /**
      * <p>Cache properties for performance.</p>
      */
-        private static Properties cacheProps = new Properties();
+    private static final Properties cacheProps = new Properties();
 
-        /**
-         * <p>First time requires initialization overhead.</p>
-         */
-        private static volatile boolean firstTime = true;
+    /**
+     * <p>First time requires initialization overhead.</p>
+     */
+    private static volatile boolean firstTime = true;
 
     static {
         // Use try/catch block to support applets
@@ -114,7 +112,7 @@
                 return;
             }
         } catch( Throwable unused ) {
-            ; // getContextClassLoader() undefined in JDK1.1
+            // getContextClassLoader() undefined in JDK1.1
         }
 
         if( classLoader==ClassLoader.getSystemClassLoader() ) {
@@ -137,9 +135,13 @@
      *
      * @throws NullPointerException
      *      If the <code>schemaLanguage</code> parameter is null.
+     * @throws SchemaFactoryConfigurationError
+     *      If a configuration error is encountered.
      */
     public SchemaFactory newFactory(String schemaLanguage) {
-        if(schemaLanguage==null)        throw new NullPointerException();
+        if(schemaLanguage==null) {
+            throw new NullPointerException();
+        }
         SchemaFactory f = _newFactory(schemaLanguage);
         if (f != null) {
             debugPrintln("factory '" + f.getClass().getName() + "' was found for " + schemaLanguage);
@@ -182,7 +184,6 @@
         String configFile = javah + File.separator +
         "lib" + File.separator + "jaxp.properties";
 
-        String factoryClassName = null ;
 
         // try to read from $java.home/lib/jaxp.properties
         try {
@@ -198,7 +199,7 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(propertyName);
+            final String factoryClassName = cacheProps.getProperty(propertyName);
             debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
 
             if (factoryClassName != null) {
@@ -213,43 +214,15 @@
             }
         }
 
-        /**
-        // try to read from $java.home/lib/jaxp.properties
-        try {
-            String javah = ss.getSystemProperty( "java.home" );
-            String configFile = javah + File.separator +
-            "lib" + File.separator + "jaxp.properties";
-            File f = new File( configFile );
-            if( ss.doesFileExist(f)) {
-                sf = loadFromProperty(
-                        propertyName,f.getAbsolutePath(), new FileInputStream(f));
-                if(sf!=null)    return sf;
-            } else {
-                debugPrintln("Tried to read "+ f.getAbsolutePath()+", but it doesn't exist.");
-            }
-        } catch(Throwable e) {
-            if( debug ) {
-                debugPrintln("failed to read $java.home/lib/jaxp.properties");
-                e.printStackTrace();
-            }
-        }
-         */
+        // Try with ServiceLoader
+        final SchemaFactory factoryImpl = findServiceProvider(schemaLanguage);
 
-        // try META-INF/services files
-        Iterator sitr = createServiceFileIterator();
-        while(sitr.hasNext()) {
-            URL resource = (URL)sitr.next();
-            debugPrintln("looking into " + resource);
-            try {
-                sf = loadFromService(schemaLanguage,resource.toExternalForm(),
-                                                ss.getURLInputStream(resource));
-                if(sf!=null)    return sf;
-            } catch(IOException e) {
-                if( debug ) {
-                    debugPrintln("failed to read "+resource);
-                    e.printStackTrace();
-                }
-            }
+        // The following assertion should always be true.
+        // Uncomment it, recompile, and run with -ea in case of doubts:
+        // assert factoryImpl == null || factoryImpl.isSchemaLanguageSupported(schemaLanguage);
+
+        if (factoryImpl != null) {
+            return factoryImpl;
         }
 
         // platform default
@@ -267,29 +240,37 @@
      * @param className Name of class to create.
      * @return Created class or <code>null</code>.
      */
-    private Class createClass(String className) {
-            Class clazz;
+    private Class<?> createClass(String className) {
+        Class<?> clazz;
+        // make sure we have access to restricted packages
+        boolean internal = false;
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                internal = true;
+            }
+        }
 
-            // use approprite ClassLoader
-            try {
-                    if (classLoader != null) {
-                            clazz = classLoader.loadClass(className);
-                    } else {
-                            clazz = Class.forName(className);
-                    }
-            } catch (Throwable t) {
-                if(debug)   t.printStackTrace();
-                    return null;
+        try {
+            if (classLoader != null && !internal) {
+                clazz = Class.forName(className, false, classLoader);
+            } else {
+                clazz = Class.forName(className);
             }
+        } catch (Throwable t) {
+            if(debug)  {
+                t.printStackTrace();
+            }
+            return null;
+        }
 
-            return clazz;
+        return clazz;
     }
 
     /**
      * <p>Creates an instance of the specified and returns it.</p>
      *
      * @param className
-     *      fully qualified class name to be instanciated.
+     *      fully qualified class name to be instantiated.
      *
      * @return null
      *      if it fails. Error messages will be printed by this method.
@@ -304,7 +285,7 @@
         debugPrintln("createInstance(" + className + ")");
 
         // get Class from className
-        Class clazz = createClass(className);
+        Class<?> clazz = createClass(className);
         if (clazz == null) {
                 debugPrintln("failed to getClass(" + className + ")");
                 return null;
@@ -313,9 +294,13 @@
 
         // instantiate Class as a SchemaFactory
         try {
-            if (!useServicesMechanism) {
-                schemaFactory = (SchemaFactory) newInstanceNoServiceLoader(clazz);
-            }
+                if (!SchemaFactory.class.isAssignableFrom(clazz)) {
+                    throw new ClassCastException(clazz.getName()
+                                + " cannot be cast to " + SchemaFactory.class);
+                }
+                if (!useServicesMechanism) {
+                    schemaFactory = newInstanceNoServiceLoader(clazz);
+                }
                 if (schemaFactory == null) {
                     schemaFactory = (SchemaFactory) clazz.newInstance();
                 }
@@ -341,11 +326,12 @@
 
         return schemaFactory;
     }
+
     /**
-     * Try to construct using newTransformerFactoryNoServiceLoader
+     * Try to construct using newXMLSchemaFactoryNoServiceLoader
      *   method if available.
      */
-    private static Object newInstanceNoServiceLoader(
+    private static SchemaFactory newInstanceNoServiceLoader(
          Class<?> providerClass
     ) {
         // Retain maximum compatibility if no security manager.
@@ -353,196 +339,87 @@
             return null;
         }
         try {
-            Method creationMethod =
+            final Method creationMethod =
                 providerClass.getDeclaredMethod(
                     "newXMLSchemaFactoryNoServiceLoader"
                 );
-                return creationMethod.invoke(null, (Object[])null);
-            } catch (NoSuchMethodException exc) {
-                return null;
-            } catch (Exception exc) {
-                return null;
-        }
-    }
+            final int modifiers = creationMethod.getModifiers();
 
-    /** Iterator that lazily computes one value and returns it. */
-    private static abstract class SingleIterator implements Iterator {
-        private boolean seen = false;
-
-        public final void remove() { throw new UnsupportedOperationException(); }
-        public final boolean hasNext() { return !seen; }
-        public final Object next() {
-            if(seen)    throw new NoSuchElementException();
-            seen = true;
-            return value();
-        }
+            // Do not call the method if it's not public static.
+            if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
+                return null;
+            }
 
-        protected abstract Object value();
-    }
-
-    /**
-     * Looks up a value in a property file
-     * while producing all sorts of debug messages.
-     *
-     * @return null
-     *      if there was an error.
-     */
-    private SchemaFactory loadFromProperty( String keyName, String resourceName, InputStream in )
-        throws IOException {
-        debugPrintln("Reading "+resourceName );
-
-        Properties props=new Properties();
-        props.load(in);
-        in.close();
-        String factoryClassName = props.getProperty(keyName);
-        if(factoryClassName != null){
-            debugPrintln("found "+keyName+" = " + factoryClassName);
-            return createInstance(factoryClassName);
-        } else {
-            debugPrintln(keyName+" is not in the property file");
+            // Only calls "newXMLSchemaFactoryNoServiceLoader" if it's
+            // declared to return an instance of SchemaFactory.
+            final Class<?> returnType = creationMethod.getReturnType();
+            if (SERVICE_CLASS.isAssignableFrom(returnType)) {
+                return SERVICE_CLASS.cast(creationMethod.invoke(null, (Object[])null));
+            } else {
+                // Should not happen since
+                // XMLSchemaFactory.newXMLSchemaFactoryNoServiceLoader is
+                // declared to return XMLSchemaFactory.
+                throw new ClassCastException(returnType
+                            + " cannot be cast to " + SERVICE_CLASS);
+            }
+        } catch(ClassCastException e) {
+            throw new SchemaFactoryConfigurationError(e.getMessage(), e);
+        } catch (NoSuchMethodException exc) {
+            return null;
+        } catch (Exception exc) {
             return null;
         }
     }
 
-    /**
-     * <p>Look up a value in a property file.</p>
-     *
-     * <p>Set <code>debug</code> to <code>true</code> to trace property evaluation.</p>
-     *
-     * @param schemaLanguage Schema Language to support.
-     * @param inputName Name of <code>InputStream</code>.
-     * @param in <code>InputStream</code> of properties.
-     *
-     * @return <code>SchemaFactory</code> as determined by <code>keyName</code> value or <code>null</code> if there was an error.
-     *
-     * @throws IOException If IO error reading from <code>in</code>.
-     */
-    private SchemaFactory loadFromService(
-            String schemaLanguage,
-            String inputName,
-            InputStream in)
-            throws IOException {
-
-            SchemaFactory schemaFactory = null;
-            final Class[] stringClassArray = {"".getClass()};
-            final Object[] schemaLanguageObjectArray = {schemaLanguage};
-            final String isSchemaLanguageSupportedMethod = "isSchemaLanguageSupported";
-
-            debugPrintln("Reading " + inputName);
-
-            // read from InputStream until a match is found
-            BufferedReader configFile = new BufferedReader(new InputStreamReader(in));
-            String line = null;
-            while ((line = configFile.readLine()) != null) {
-                    // '#' is comment char
-                    int comment = line.indexOf("#");
-                    switch (comment) {
-                            case -1: break; // no comment
-                            case 0: line = ""; break; // entire line is a comment
-                            default: line = line.substring(0, comment); break; // trim comment
-                    }
-
-                    // trim whitespace
-                    line = line.trim();
-
-                    // any content left on line?
-                    if (line.length() == 0) {
-                            continue;
-                    }
-
-                    // line content is now the name of the class
-                    Class clazz = createClass(line);
-                    if (clazz == null) {
-                            continue;
-                    }
-
-                    // create an instance of the Class
-                    try {
-                            schemaFactory = (SchemaFactory) clazz.newInstance();
-                    } catch (ClassCastException classCastExcpetion) {
-                            schemaFactory = null;
-                            continue;
-                    } catch (InstantiationException instantiationException) {
-                            schemaFactory = null;
-                            continue;
-                    } catch (IllegalAccessException illegalAccessException) {
-                            schemaFactory = null;
-                            continue;
-                    }
-
-                    // does this Class support desired Schema?
-                    try {
-                            Method isSchemaLanguageSupported = clazz.getMethod(isSchemaLanguageSupportedMethod, stringClassArray);
-                            Boolean supported = (Boolean) isSchemaLanguageSupported.invoke(schemaFactory, schemaLanguageObjectArray);
-                            if (supported.booleanValue()) {
-                                    break;
-                            }
-                    } catch (NoSuchMethodException noSuchMethodException) {
-
-                    } catch (IllegalAccessException illegalAccessException) {
-
-                    } catch (InvocationTargetException invocationTargetException) {
-
-                    }
-                    schemaFactory = null;
+    // Call isSchemaLanguageSupported with initial context.
+    private boolean isSchemaLanguageSupportedBy(final SchemaFactory factory,
+            final String schemaLanguage,
+            AccessControlContext acc) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+            public Boolean run() {
+                return factory.isSchemaLanguageSupported(schemaLanguage);
             }
-
-            // clean up
-            configFile.close();
-
-            // return new instance of SchemaFactory or null
-            return schemaFactory;
+        }, acc);
     }
 
     /**
-     * Returns an {@link Iterator} that enumerates all
-     * the META-INF/services files that we care.
+     * Finds a service provider subclass of SchemaFactory that supports the
+     * given schema language using the ServiceLoader.
+     *
+     * @param schemaLanguage The schema language for which we seek a factory.
+     * @return A SchemaFactory supporting the specified schema language, or null
+     *         if none is found.
+     * @throws SchemaFactoryConfigurationError if a configuration error is found.
      */
-    private Iterator createServiceFileIterator() {
-        if (classLoader == null) {
-            return new SingleIterator() {
-                protected Object value() {
-                    ClassLoader classLoader = SchemaFactoryFinder.class.getClassLoader();
-                    //return (ClassLoader.getSystemResource( SERVICE_ID ));
-                    return ss.getResourceAsURL(classLoader, SERVICE_ID);
-                }
-            };
-        } else {
-            try {
-                //final Enumeration e = classLoader.getResources(SERVICE_ID);
-                final Enumeration e = ss.getResources(classLoader, SERVICE_ID);
-                if(!e.hasMoreElements()) {
-                    debugPrintln("no "+SERVICE_ID+" file was found");
+    private SchemaFactory findServiceProvider(final String schemaLanguage) {
+        assert schemaLanguage != null;
+        // store current context.
+        final AccessControlContext acc = AccessController.getContext();
+        try {
+            return AccessController.doPrivileged(new PrivilegedAction<SchemaFactory>() {
+                public SchemaFactory run() {
+                    final ServiceLoader<SchemaFactory> loader =
+                            ServiceLoader.load(SERVICE_CLASS);
+                    for (SchemaFactory factory : loader) {
+                        // restore initial context to call
+                        // factory.isSchemaLanguageSupported
+                        if (isSchemaLanguageSupportedBy(factory, schemaLanguage, acc)) {
+                            return factory;
+                        }
+                    }
+                    return null; // no factory found.
                 }
-
-                // wrap it into an Iterator.
-                return new Iterator() {
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
-
-                    public boolean hasNext() {
-                        return e.hasMoreElements();
-                    }
-
-                    public Object next() {
-                        return e.nextElement();
-                    }
-                };
-            } catch (IOException e) {
-                debugPrintln("failed to enumerate resources "+SERVICE_ID);
-                if(debug)   e.printStackTrace();
-                return new ArrayList().iterator();  // empty iterator
-            }
+            });
+        } catch (ServiceConfigurationError error) {
+            throw new SchemaFactoryConfigurationError(
+                    "Provider for " + SERVICE_CLASS + " cannot be created", error);
         }
     }
 
-    private static final Class SERVICE_CLASS = SchemaFactory.class;
-    private static final String SERVICE_ID = "META-INF/services/" + SERVICE_CLASS.getName();
+    private static final Class<SchemaFactory> SERVICE_CLASS = SchemaFactory.class;
 
 
-
-    private static String which( Class clazz ) {
+    private static String which( Class<?> clazz ) {
         return which( clazz.getName(), clazz.getClassLoader() );
     }
 
--- a/src/javax/xml/xpath/XPathFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/xpath/XPathFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -90,7 +90,7 @@
      * @throws RuntimeException When there is a failure in creating an
      *   <code>XPathFactory</code> for the default object model.
      */
-    public static final XPathFactory newInstance() {
+    public static XPathFactory newInstance() {
 
         try {
                 return newInstance(DEFAULT_OBJECT_MODEL_URI);
@@ -121,14 +121,17 @@
     *     If present, the value is processed just like above.
     *   </li>
     *   <li>
-    *     The class loader is asked for service provider provider-configuration files matching <code>javax.xml.xpath.XPathFactory</code>
-    *     in the resource directory META-INF/services.
-    *     See the JAR File Specification for file format and parsing rules.
-    *     Each potential service provider is required to implement the method:
-    *     <pre>
-    *       {@link #isObjectModelSupported(String objectModel)}
-    *     </pre>
-    *     The first service provider found in class loader order that supports the specified object model is returned.
+    *     Use the service-provider loading facilities, defined by the
+    *     {@link java.util.ServiceLoader} class, to attempt to locate and load an
+    *     implementation of the service.
+    *     <br>
+    *     Each potential service provider is required to implement the method
+    *     {@link #isObjectModelSupported(String objectModel)}.
+    *     The first service provider found that supports the specified object
+    *     model is returned.
+    *     <br>
+    *     In case of {@link java.util.ServiceConfigurationError} an
+    *     {@link XPathFactoryConfigurationException} will be thrown.
     *   </li>
     *   <li>
     *     Platform default <code>XPathFactory</code> is located in a platform specific way.
@@ -152,43 +155,41 @@
     *
     * @return Instance of an <code>XPathFactory</code>.
     *
-    * @throws XPathFactoryConfigurationException If the specified object model is unavailable.
+    * @throws XPathFactoryConfigurationException If the specified object model
+    *      is unavailable, or if there is a configuration error.
     * @throws NullPointerException If <code>uri</code> is <code>null</code>.
-        * @throws IllegalArgumentException If <code>uri</code> is <code>null</code>
+    * @throws IllegalArgumentException If <code>uri</code> is <code>null</code>
     *   or <code>uri.length() == 0</code>.
     */
-    public static final XPathFactory newInstance(final String uri)
+    public static XPathFactory newInstance(final String uri)
         throws XPathFactoryConfigurationException {
 
         if (uri == null) {
-                throw new NullPointerException(
-                        "XPathFactory#newInstance(String uri) cannot be called with uri == null"
-                );
+            throw new NullPointerException(
+                    "XPathFactory#newInstance(String uri) cannot be called with uri == null");
         }
 
-                if (uri.length() == 0) {
-                        throw new IllegalArgumentException(
-                                "XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
-                        );
-                }
+        if (uri.length() == 0) {
+            throw new IllegalArgumentException(
+                    "XPathFactory#newInstance(String uri) cannot be called with uri == \"\"");
+        }
 
-                ClassLoader classLoader = ss.getContextClassLoader();
+        ClassLoader classLoader = ss.getContextClassLoader();
 
         if (classLoader == null) {
             //use the current class loader
             classLoader = XPathFactory.class.getClassLoader();
         }
 
-                XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
+        XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
 
-                if (xpathFactory == null) {
-                        throw new XPathFactoryConfigurationException(
-                                "No XPathFactory implementation found for the object model: "
-                                + uri
-                        );
-                }
+        if (xpathFactory == null) {
+            throw new XPathFactoryConfigurationException(
+                    "No XPathFactory implementation found for the object model: "
+                    + uri);
+        }
 
-                return xpathFactory;
+        return xpathFactory;
     }
 
     /**
@@ -242,16 +243,14 @@
         ClassLoader cl = classLoader;
 
         if (uri == null) {
-                throw new NullPointerException(
-                        "XPathFactory#newInstance(String uri) cannot be called with uri == null"
-                );
+            throw new NullPointerException(
+                    "XPathFactory#newInstance(String uri) cannot be called with uri == null");
         }
 
-                if (uri.length() == 0) {
-                        throw new IllegalArgumentException(
-                                "XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
-                        );
-                }
+        if (uri.length() == 0) {
+            throw new IllegalArgumentException(
+                    "XPathFactory#newInstance(String uri) cannot be called with uri == \"\"");
+        }
 
         if (cl == null) {
             cl = ss.getContextClassLoader();
@@ -260,31 +259,32 @@
         XPathFactory f = new XPathFactoryFinder(cl).createInstance(factoryClassName);
 
         if (f == null) {
-                        throw new XPathFactoryConfigurationException(
-                                "No XPathFactory implementation found for the object model: "
-                                + uri
-                        );
+            throw new XPathFactoryConfigurationException(
+                    "No XPathFactory implementation found for the object model: "
+                    + uri);
         }
         //if this factory supports the given schemalanguage return this factory else thrown exception
-        if(f.isObjectModelSupported(uri)){
+        if (f.isObjectModelSupported(uri)) {
             return f;
-        }else{
-            throw new XPathFactoryConfigurationException("Factory " + factoryClassName + " doesn't support given " + uri + " object model");
+        } else {
+            throw new XPathFactoryConfigurationException("Factory "
+                    + factoryClassName + " doesn't support given " + uri
+                    + " object model");
         }
 
     }
 
-        /**
-         * <p>Is specified object model supported by this <code>XPathFactory</code>?</p>
-         *
-         * @param objectModel Specifies the object model which the returned <code>XPathFactory</code> will understand.
-         *
-         * @return <code>true</code> if <code>XPathFactory</code> supports <code>objectModel</code>, else <code>false</code>.
-         *
-         * @throws NullPointerException If <code>objectModel</code> is <code>null</code>.
-         * @throws IllegalArgumentException If <code>objectModel.length() == 0</code>.
-         */
-        public abstract boolean isObjectModelSupported(String objectModel);
+    /**
+     * <p>Is specified object model supported by this <code>XPathFactory</code>?</p>
+     *
+     * @param objectModel Specifies the object model which the returned <code>XPathFactory</code> will understand.
+     *
+     * @return <code>true</code> if <code>XPathFactory</code> supports <code>objectModel</code>, else <code>false</code>.
+     *
+     * @throws NullPointerException If <code>objectModel</code> is <code>null</code>.
+     * @throws IllegalArgumentException If <code>objectModel.length() == 0</code>.
+     */
+    public abstract boolean isObjectModelSupported(String objectModel);
 
     /**
      * <p>Set a feature for this <code>XPathFactory</code> and
@@ -314,8 +314,8 @@
      *   it creates cannot support this feature.
      * @throws NullPointerException if <code>name</code> is <code>null</code>.
      */
-        public abstract void setFeature(String name, boolean value)
-                throws XPathFactoryConfigurationException;
+    public abstract void setFeature(String name, boolean value)
+            throws XPathFactoryConfigurationException;
 
     /**
      * <p>Get the state of the named feature.</p>
@@ -339,8 +339,8 @@
      *   it creates cannot support this feature.
      * @throws NullPointerException if <code>name</code> is <code>null</code>.
      */
-        public abstract boolean getFeature(String name)
-                throws XPathFactoryConfigurationException;
+    public abstract boolean getFeature(String name)
+            throws XPathFactoryConfigurationException;
 
     /**
      * <p>Establish a default variable resolver.</p>
@@ -359,19 +359,19 @@
     public abstract void setXPathVariableResolver(XPathVariableResolver resolver);
 
     /**
-       * <p>Establish a default function resolver.</p>
-       *
-       * <p>Any <code>XPath</code> objects constructed from this factory will
-       * use the specified resolver by default.</p>
-       *
-       * <p>A <code>NullPointerException</code> is thrown if
-       * <code>resolver</code> is <code>null</code>.</p>
-       *
-       * @param resolver XPath function resolver.
-       *
-       * @throws NullPointerException If <code>resolver</code> is
-       *   <code>null</code>.
-       */
+     * <p>Establish a default function resolver.</p>
+     *
+     * <p>Any <code>XPath</code> objects constructed from this factory will
+     * use the specified resolver by default.</p>
+     *
+     * <p>A <code>NullPointerException</code> is thrown if
+     * <code>resolver</code> is <code>null</code>.</p>
+     *
+     * @param resolver XPath function resolver.
+     *
+     * @throws NullPointerException If <code>resolver</code> is
+     *   <code>null</code>.
+     */
     public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver);
 
     /**
--- a/src/javax/xml/xpath/XPathFactoryFinder.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/javax/xml/xpath/XPathFactoryFinder.java	Fri Sep 27 15:40:15 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,16 @@
 
 package javax.xml.xpath;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
 
 /**
  * Implementation of {@link XPathFactory#newInstance(String)}.
@@ -48,8 +44,9 @@
  * @since 1.5
  */
 class XPathFactoryFinder  {
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xpath.internal";
 
-    private static SecuritySupport ss = new SecuritySupport() ;
+    private static final SecuritySupport ss = new SecuritySupport() ;
     /** debug support code. */
     private static boolean debug = false;
     static {
@@ -64,12 +61,12 @@
     /**
      * <p>Cache properties for performance.</p>
      */
-        private static Properties cacheProps = new Properties();
+    private static final Properties cacheProps = new Properties();
 
-        /**
-         * <p>First time requires initialization overhead.</p>
-         */
-        private volatile static boolean firstTime = true;
+    /**
+     * <p>First time requires initialization overhead.</p>
+     */
+    private volatile static boolean firstTime = true;
 
     /**
      * <p>Conditional debug printing.</p>
@@ -92,9 +89,8 @@
      * to find <code>XPathFactory</code>.</p>
      *
      * @param loader
-     *      to be used to load resource, {@link XPathFactory}, and
-     *      {@link SchemaFactoryLoader} implementations during
-     *      the resolution process.
+     *      to be used to load resource and {@link XPathFactory}
+     *      implementations during the resolution process.
      *      If this parameter is null, the default system class loader
      *      will be used.
      */
@@ -112,7 +108,7 @@
                 return;
             }
         } catch( Throwable unused ) {
-            ; // getContextClassLoader() undefined in JDK1.1
+             // getContextClassLoader() undefined in JDK1.1
         }
 
         if( classLoader==ClassLoader.getSystemClassLoader() ) {
@@ -125,7 +121,7 @@
 
     /**
      * <p>Creates a new {@link XPathFactory} object for the specified
-     * schema language.</p>
+     * object model.</p>
      *
      * @param uri
      *       Identifies the underlying object model.
@@ -135,8 +131,10 @@
      * @throws NullPointerException
      *      If the parameter is null.
      */
-    public XPathFactory newFactory(String uri) {
-        if(uri==null)        throw new NullPointerException();
+    public XPathFactory newFactory(String uri) throws XPathFactoryConfigurationException {
+        if (uri == null) {
+            throw new NullPointerException();
+        }
         XPathFactory f = _newFactory(uri);
         if (f != null) {
             debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
@@ -153,8 +151,8 @@
      *
      * @return {@link XPathFactory} for the given object model.
      */
-    private XPathFactory _newFactory(String uri) {
-        XPathFactory xpathFactory;
+    private XPathFactory _newFactory(String uri) throws XPathFactoryConfigurationException {
+        XPathFactory xpathFactory = null;
 
         String propertyName = SERVICE_CLASS.getName() + ":" + uri;
 
@@ -165,7 +163,9 @@
             if(r!=null) {
                 debugPrintln("The value is '"+r+"'");
                 xpathFactory = createInstance(r, true);
-                if(xpathFactory != null)    return xpathFactory;
+                if (xpathFactory != null) {
+                    return xpathFactory;
+                }
             } else
                 debugPrintln("The property is undefined.");
         } catch( Throwable t ) {
@@ -179,8 +179,6 @@
         String configFile = javah + File.separator +
         "lib" + File.separator + "jaxp.properties";
 
-        String factoryClassName = null ;
-
         // try to read from $java.home/lib/jaxp.properties
         try {
             if(firstTime){
@@ -195,7 +193,7 @@
                     }
                 }
             }
-            factoryClassName = cacheProps.getProperty(propertyName);
+            final String factoryClassName = cacheProps.getProperty(propertyName);
             debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
 
             if (factoryClassName != null) {
@@ -210,23 +208,16 @@
             }
         }
 
-        // try META-INF/services files
-        Iterator sitr = createServiceFileIterator();
-        while(sitr.hasNext()) {
-            URL resource = (URL)sitr.next();
-            debugPrintln("looking into " + resource);
-            try {
-                xpathFactory = loadFromService(uri, resource.toExternalForm(),
-                                                ss.getURLInputStream(resource));
-                if (xpathFactory != null) {
-                    return xpathFactory;
-                }
-            } catch(IOException e) {
-                if( debug ) {
-                    debugPrintln("failed to read "+resource);
-                    e.printStackTrace();
-                }
-            }
+        // Try with ServiceLoader
+        assert xpathFactory == null;
+        xpathFactory = findServiceProvider(uri);
+
+        // The following assertion should always be true.
+        // Uncomment it, recompile, and run with -ea in case of doubts:
+        // assert xpathFactory == null || xpathFactory.isObjectModelSupported(uri);
+
+        if (xpathFactory != null) {
+            return xpathFactory;
         }
 
         // platform default
@@ -244,53 +235,67 @@
      * @param className Name of class to create.
      * @return Created class or <code>null</code>.
      */
-    private Class createClass(String className) {
-            Class clazz;
+    private Class<?> createClass(String className) {
+        Class clazz;
+        // make sure we have access to restricted packages
+        boolean internal = false;
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                internal = true;
+            }
+        }
 
-            // use approprite ClassLoader
-            try {
-                    if (classLoader != null) {
-                            clazz = classLoader.loadClass(className);
-                    } else {
-                            clazz = Class.forName(className);
-                    }
-            } catch (Throwable t) {
-                if(debug)   t.printStackTrace();
-                    return null;
+        // use approprite ClassLoader
+        try {
+            if (classLoader != null && !internal) {
+                    clazz = Class.forName(className, false, classLoader);
+            } else {
+                    clazz = Class.forName(className);
             }
+        } catch (Throwable t) {
+            if(debug) {
+                t.printStackTrace();
+            }
+            return null;
+        }
 
-            return clazz;
+        return clazz;
     }
 
     /**
      * <p>Creates an instance of the specified and returns it.</p>
      *
      * @param className
-     *      fully qualified class name to be instanciated.
+     *      fully qualified class name to be instantiated.
      *
      * @return null
      *      if it fails. Error messages will be printed by this method.
      */
-    XPathFactory createInstance( String className ) {
+    XPathFactory createInstance( String className )
+            throws XPathFactoryConfigurationException
+    {
         return createInstance( className, false );
     }
-    XPathFactory createInstance( String className, boolean useServicesMechanism  ) {
+
+    XPathFactory createInstance( String className, boolean useServicesMechanism  )
+            throws XPathFactoryConfigurationException
+    {
         XPathFactory xPathFactory = null;
 
         debugPrintln("createInstance(" + className + ")");
 
         // get Class from className
-        Class clazz = createClass(className);
+        Class<?> clazz = createClass(className);
         if (clazz == null) {
-                debugPrintln("failed to getClass(" + className + ")");
-                return null;
+            debugPrintln("failed to getClass(" + className + ")");
+            return null;
         }
         debugPrintln("loaded " + className + " from " + which(clazz));
 
         // instantiate Class as a XPathFactory
         try {
             if (!useServicesMechanism) {
-                xPathFactory = (XPathFactory) newInstanceNoServiceLoader(clazz);
+                xPathFactory = newInstanceNoServiceLoader(clazz);
             }
             if (xPathFactory == null) {
                 xPathFactory = (XPathFactory) clazz.newInstance();
@@ -321,203 +326,94 @@
      * Try to construct using newXPathFactoryNoServiceLoader
      *   method if available.
      */
-    private static Object newInstanceNoServiceLoader(
+    private static XPathFactory newInstanceNoServiceLoader(
          Class<?> providerClass
-    ) {
+    ) throws XPathFactoryConfigurationException {
         // Retain maximum compatibility if no security manager.
         if (System.getSecurityManager() == null) {
             return null;
         }
         try {
             Method creationMethod =
-                providerClass.getDeclaredMethod(
-                    "newXPathFactoryNoServiceLoader"
-                );
-                return creationMethod.invoke(null, (Object[])null);
-            } catch (NoSuchMethodException exc) {
-                return null;
-            } catch (Exception exc) {
-                return null;
-        }
-    }
-
-    /**
-     * <p>Look up a value in a property file.</p>
-     *
-     * <p>Set <code>debug</code> to <code>true</code> to trace property evaluation.</p>
-     *
-     * @param objectModel URI of object model to support.
-     * @param inputName Name of <code>InputStream</code>.
-     * @param in <code>InputStream</code> of properties.
-     *
-     * @return <code>XPathFactory</code> as determined by <code>keyName</code> value or <code>null</code> if there was an error.
-     *
-     * @throws IOException If IO error reading from <code>in</code>.
-     */
-    private XPathFactory loadFromService(
-            String objectModel,
-            String inputName,
-            InputStream in)
-            throws IOException {
-
-            XPathFactory xPathFactory = null;
-            final Class[] stringClassArray = {"".getClass()};
-            final Object[] objectModelObjectArray = {objectModel};
-            final String isObjectModelSupportedMethod = "isObjectModelSupported";
-
-            debugPrintln("Reading " + inputName);
+                    providerClass.getDeclaredMethod(
+                        "newXPathFactoryNoServiceLoader"
+                    );
+            final int modifiers = creationMethod.getModifiers();
 
-            // read from InputStream until a match is found
-            BufferedReader configFile = new BufferedReader(new InputStreamReader(in));
-            String line = null;
-            while ((line = configFile.readLine()) != null) {
-                    // '#' is comment char
-                    int comment = line.indexOf("#");
-                    switch (comment) {
-                            case -1: break; // no comment
-                            case 0: line = ""; break; // entire line is a comment
-                            default: line = line.substring(0, comment); break; // trim comment
-                    }
-
-                    // trim whitespace
-                    line = line.trim();
-
-                    // any content left on line?
-                    if (line.length() == 0) {
-                            continue;
-                    }
-
-                    // line content is now the name of the class
-                    Class clazz = createClass(line);
-                    if (clazz == null) {
-                            continue;
-                    }
-
-                    // create an instance of the Class
-                    try {
-                            xPathFactory = (XPathFactory) clazz.newInstance();
-                    } catch (ClassCastException classCastExcpetion) {
-                            xPathFactory = null;
-                            continue;
-                    } catch (InstantiationException instantiationException) {
-                            xPathFactory = null;
-                            continue;
-                    } catch (IllegalAccessException illegalAccessException) {
-                            xPathFactory = null;
-                            continue;
-                    }
-
-                    // does this Class support desired object model?
-                    try {
-                            Method isObjectModelSupported = clazz.getMethod(isObjectModelSupportedMethod, stringClassArray);
-                            Boolean supported = (Boolean) isObjectModelSupported.invoke(xPathFactory, objectModelObjectArray);
-                            if (supported.booleanValue()) {
-                                    break;
-                            }
-
-                    } catch (NoSuchMethodException noSuchMethodException) {
-
-                    } catch (IllegalAccessException illegalAccessException) {
-
-                    } catch (InvocationTargetException invocationTargetException) {
-
-                    }
-                    xPathFactory = null;
+            // Do not call "newXPathFactoryNoServiceLoader" if it's
+            // not public static.
+            if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
+                return null;
             }
 
-            // clean up
-            configFile.close();
-
-            // return new instance of XPathFactory or null
-            return xPathFactory;
-    }
-
-    /** Iterator that lazily computes one value and returns it. */
-    private static abstract class SingleIterator implements Iterator {
-        private boolean seen = false;
-
-        public final void remove() { throw new UnsupportedOperationException(); }
-        public final boolean hasNext() { return !seen; }
-        public final Object next() {
-            if(seen)    throw new NoSuchElementException();
-            seen = true;
-            return value();
-        }
-
-        protected abstract Object value();
-    }
-
-    /**
-     * Looks up a value in a property file
-     * while producing all sorts of debug messages.
-     *
-     * @return null
-     *      if there was an error.
-     */
-    private XPathFactory loadFromProperty( String keyName, String resourceName, InputStream in )
-        throws IOException {
-        debugPrintln("Reading "+resourceName );
-
-        Properties props = new Properties();
-        props.load(in);
-        in.close();
-        String factoryClassName = props.getProperty(keyName);
-        if(factoryClassName != null){
-            debugPrintln("found "+keyName+" = " + factoryClassName);
-            return createInstance(factoryClassName, true);
-        } else {
-            debugPrintln(keyName+" is not in the property file");
+            // Only calls "newXPathFactoryNoServiceLoader" if it's
+            // declared to return an instance of XPathFactory.
+            final Class<?> returnType = creationMethod.getReturnType();
+            if (SERVICE_CLASS.isAssignableFrom(returnType)) {
+                return SERVICE_CLASS.cast(creationMethod.invoke(null, (Object[])null));
+            } else {
+                // Should not happen since
+                // XPathFactoryImpl.newXPathFactoryNoServiceLoader is
+                // declared to return XPathFactory.
+                throw new ClassCastException(returnType
+                            + " cannot be cast to " + SERVICE_CLASS);
+            }
+        } catch (ClassCastException e) {
+            throw new XPathFactoryConfigurationException(e);
+        } catch (NoSuchMethodException exc) {
+            return null;
+        } catch (Exception exc) {
             return null;
         }
     }
 
+    // Call isObjectModelSupportedBy with initial context.
+    private boolean isObjectModelSupportedBy(final XPathFactory factory,
+            final String objectModel,
+            AccessControlContext acc) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                    public Boolean run() {
+                        return factory.isObjectModelSupported(objectModel);
+                    }
+                }, acc);
+    }
+
     /**
-     * Returns an {@link Iterator} that enumerates all
-     * the META-INF/services files that we care.
+     * Finds a service provider subclass of XPathFactory that supports the
+     * given object model using the ServiceLoader.
+     *
+     * @param objectModel URI of object model to support.
+     * @return An XPathFactory supporting the specified object model, or null
+     *         if none is found.
+     * @throws XPathFactoryConfigurationException if a configuration error is found.
      */
-    private Iterator createServiceFileIterator() {
-        if (classLoader == null) {
-            return new SingleIterator() {
-                protected Object value() {
-                    ClassLoader classLoader = XPathFactoryFinder.class.getClassLoader();
-                    return ss.getResourceAsURL(classLoader, SERVICE_ID);
-                    //return (ClassLoader.getSystemResource( SERVICE_ID ));
-                }
-            };
-        } else {
-            try {
-                //final Enumeration e = classLoader.getResources(SERVICE_ID);
-                final Enumeration e = ss.getResources(classLoader, SERVICE_ID);
-                if(!e.hasMoreElements()) {
-                    debugPrintln("no "+SERVICE_ID+" file was found");
+    private XPathFactory findServiceProvider(final String objectModel)
+            throws XPathFactoryConfigurationException {
+
+        assert objectModel != null;
+        // store current context.
+        final AccessControlContext acc = AccessController.getContext();
+        try {
+            return AccessController.doPrivileged(new PrivilegedAction<XPathFactory>() {
+                public XPathFactory run() {
+                    final ServiceLoader<XPathFactory> loader =
+                            ServiceLoader.load(SERVICE_CLASS);
+                    for (XPathFactory factory : loader) {
+                        // restore initial context to call
+                        // factory.isObjectModelSupportedBy
+                        if (isObjectModelSupportedBy(factory, objectModel, acc)) {
+                            return factory;
+                        }
+                    }
+                    return null; // no factory found.
                 }
-
-                // wrap it into an Iterator.
-                return new Iterator() {
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
-
-                    public boolean hasNext() {
-                        return e.hasMoreElements();
-                    }
-
-                    public Object next() {
-                        return e.nextElement();
-                    }
-                };
-            } catch (IOException e) {
-                debugPrintln("failed to enumerate resources "+SERVICE_ID);
-                if(debug)   e.printStackTrace();
-                return new ArrayList().iterator();  // empty iterator
-            }
+            });
+        } catch (ServiceConfigurationError error) {
+            throw new XPathFactoryConfigurationException(error);
         }
     }
 
-    private static final Class SERVICE_CLASS = XPathFactory.class;
-    private static final String SERVICE_ID = "META-INF/services/" + SERVICE_CLASS.getName();
-
-
+    private static final Class<XPathFactory> SERVICE_CLASS = XPathFactory.class;
 
     private static String which( Class clazz ) {
         return which( clazz.getName(), clazz.getClassLoader() );
--- a/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Fri Sep 27 15:40:15 2013 +0100
@@ -104,6 +104,8 @@
      */
     private static final String FALLBACK_CLASS =
             "com.sun.org.apache.xerces.internal.dom.DOMXSImplementationSourceImpl";
+    private static final String DEFAULT_PACKAGE =
+            "com.sun.org.apache.xerces.internal.dom";
     /**
      * Private constructor.
      * @param srcs Vector List of DOMImplementationSources
@@ -168,10 +170,15 @@
             StringTokenizer st = new StringTokenizer(p);
             while (st.hasMoreTokens()) {
                 String sourceName = st.nextToken();
-                // Use context class loader, falling back to Class.forName
-                // if and only if this fails...
+                // make sure we have access to restricted packages
+                boolean internal = false;
+                if (System.getSecurityManager() != null) {
+                    if (sourceName != null && sourceName.startsWith(DEFAULT_PACKAGE)) {
+                        internal = true;
+                    }
+                }
                 Class sourceClass = null;
-                if (classLoader != null) {
+                if (classLoader != null && !internal) {
                     sourceClass = classLoader.loadClass(sourceName);
                 } else {
                     sourceClass = Class.forName(sourceName);
--- a/src/org/xml/sax/helpers/NewInstance.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/org/xml/sax/helpers/NewInstance.java	Fri Sep 27 15:40:15 2013 +0100
@@ -54,9 +54,10 @@
  * including versions of Java 2.</p>
  *
  * @author Edwin Goei, David Brownell
+ * @version 2.0.1 (sax2r2)
  */
 class NewInstance {
-
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
     /**
      * Creates a new instance of the specified class name
      *
@@ -66,8 +67,16 @@
         throws ClassNotFoundException, IllegalAccessException,
             InstantiationException
     {
+        // make sure we have access to restricted packages
+        boolean internal = false;
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                internal = true;
+            }
+        }
+
         Class driverClass;
-        if (classLoader == null) {
+        if (classLoader == null || internal) {
             driverClass = Class.forName(className);
         } else {
             driverClass = classLoader.loadClass(className);
@@ -75,29 +84,4 @@
         return driverClass.newInstance();
     }
 
-    /**
-     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
-     * the context ClassLoader.
-     */
-    static ClassLoader getClassLoader ()
-    {
-        Method m = null;
-
-        try {
-            m = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
-        } catch (NoSuchMethodException e) {
-            // Assume that we are running JDK 1.1, use the current ClassLoader
-            return NewInstance.class.getClassLoader();
-        }
-
-        try {
-            return (ClassLoader) m.invoke(Thread.currentThread(), (Object[]) null);
-        } catch (IllegalAccessException e) {
-            // assert(false)
-            throw new UnknownError(e.getMessage());
-        } catch (InvocationTargetException e) {
-            // assert(e.getTargetException() instanceof SecurityException)
-            throw new UnknownError(e.getMessage());
-        }
-    }
 }
--- a/src/org/xml/sax/helpers/ParserAdapter.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/org/xml/sax/helpers/ParserAdapter.java	Fri Sep 27 15:40:15 2013 +0100
@@ -74,13 +74,14 @@
  *
  * @since SAX 2.0
  * @author David Megginson
+ * @version 2.0.1 (sax2r2)
  * @see org.xml.sax.helpers.XMLReaderAdapter
  * @see org.xml.sax.XMLReader
  * @see org.xml.sax.Parser
  */
 public class ParserAdapter implements XMLReader, DocumentHandler
 {
-
+    private static SecuritySupport ss = new SecuritySupport();
 
     ////////////////////////////////////////////////////////////////////
     // Constructors.
@@ -102,7 +103,7 @@
     {
         super();
 
-        String driver = System.getProperty("org.xml.sax.parser");
+        String driver = ss.getSystemProperty("org.xml.sax.parser");
 
         try {
             setup(ParserFactory.makeParser());
--- a/src/org/xml/sax/helpers/ParserFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/org/xml/sax/helpers/ParserFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -30,12 +30,6 @@
 
 package org.xml.sax.helpers;
 
-import java.lang.ClassNotFoundException;
-import java.lang.IllegalAccessException;
-import java.lang.InstantiationException;
-import java.lang.SecurityException;
-import java.lang.ClassCastException;
-
 import org.xml.sax.Parser;
 
 
@@ -69,9 +63,10 @@
  *             interface.
  * @since SAX 1.0
  * @author David Megginson
+ * @version 2.0.1 (sax2r2)
  */
 public class ParserFactory {
-
+    private static SecuritySupport ss = new SecuritySupport();
 
     /**
      * Private null constructor.
@@ -109,7 +104,7 @@
         NullPointerException,
         ClassCastException
     {
-        String className = System.getProperty("org.xml.sax.parser");
+        String className = ss.getSystemProperty("org.xml.sax.parser");
         if (className == null) {
             throw new NullPointerException("No value for sax.parser property");
         } else {
@@ -146,7 +141,7 @@
         ClassCastException
     {
         return (Parser) NewInstance.newInstance (
-                NewInstance.getClassLoader (), className);
+                ss.getContextClassLoader(), className);
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/xml/sax/helpers/SecuritySupport.java	Fri Sep 27 15:40:15 2013 +0100
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.xml.sax.helpers;
+
+import java.io.*;
+import java.security.*;
+
+/**
+ * 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.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+class SecuritySupport  {
+
+
+    ClassLoader getContextClassLoader() throws SecurityException{
+        return (ClassLoader)
+                AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                ClassLoader cl = null;
+                //try {
+                cl = Thread.currentThread().getContextClassLoader();
+                //} catch (SecurityException ex) { }
+
+                if (cl == null)
+                    cl = ClassLoader.getSystemClassLoader();
+
+                return cl;
+            }
+        });
+    }
+
+    String getSystemProperty(final String propName) {
+        return (String)
+            AccessController.doPrivileged(new PrivilegedAction() {
+                public Object run() {
+                    return System.getProperty(propName);
+                }
+            });
+    }
+
+    FileInputStream getFileInputStream(final File file)
+        throws FileNotFoundException
+    {
+        try {
+            return (FileInputStream)
+                AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                    public Object run() throws FileNotFoundException {
+                        return new FileInputStream(file);
+                    }
+                });
+        } catch (PrivilegedActionException e) {
+            throw (FileNotFoundException)e.getException();
+        }
+    }
+
+    InputStream getResourceAsStream(final ClassLoader cl,
+                                           final String name)
+    {
+        return (InputStream)
+            AccessController.doPrivileged(new PrivilegedAction() {
+                public Object run() {
+                    InputStream ris;
+                    if (cl == null) {
+                        ris = Object.class.getResourceAsStream(name);
+                    } else {
+                        ris = cl.getResourceAsStream(name);
+                    }
+                    return ris;
+                }
+            });
+    }
+
+    boolean doesFileExist(final File f) {
+    return ((Boolean)
+            AccessController.doPrivileged(new PrivilegedAction() {
+                public Object run() {
+                    return new Boolean(f.exists());
+                }
+            })).booleanValue();
+    }
+
+}
--- a/src/org/xml/sax/helpers/XMLReaderFactory.java	Tue Aug 13 17:06:23 2013 +0100
+++ b/src/org/xml/sax/helpers/XMLReaderFactory.java	Fri Sep 27 15:40:15 2013 +0100
@@ -34,8 +34,6 @@
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import org.xml.sax.XMLReader;
 import org.xml.sax.SAXException;
 
@@ -85,8 +83,8 @@
     }
 
     private static final String property = "org.xml.sax.driver";
+    private static SecuritySupport ss = new SecuritySupport();
 
-    private static String _clsFromJar = null;
     private static boolean _jarread = false;
     /**
      * Attempt to create an XMLReader from system defaults.
@@ -134,43 +132,45 @@
         throws SAXException
     {
         String          className = null;
-        ClassLoader     loader = NewInstance.getClassLoader ();
+        ClassLoader     cl = ss.getContextClassLoader();
 
         // 1. try the JVM-instance-wide system property
-        try { className = System.getProperty (property); }
-        catch (RuntimeException e) { /* normally fails for applets */ }
+        try {
+            className = ss.getSystemProperty(property);
+        }
+        catch (RuntimeException e) { /* continue searching */ }
 
         // 2. if that fails, try META-INF/services/
         if (className == null) {
             if (!_jarread) {
-                final ClassLoader       loader1 = loader;
                 _jarread = true;
-                _clsFromJar =  (String)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        String clsName = null;
-                        try {
-                            String      service = "META-INF/services/" + property;
-                            InputStream in;
-                            BufferedReader      reader;
-                            if (loader1 == null)
-                                in = ClassLoader.getSystemResourceAsStream (service);
-                            else
-                                in = loader1.getResourceAsStream (service);
+                String      service = "META-INF/services/" + property;
+                InputStream in;
+                BufferedReader      reader;
+
+                try {
+                    if (cl != null) {
+                        in = ss.getResourceAsStream(cl, service);
 
-                            if (in != null) {
-                                reader = new BufferedReader (
-                                        new InputStreamReader (in, "UTF8"));
-                                clsName = reader.readLine ();
-                                in.close ();
-                            }
-                        } catch (Exception e) {
+                        // If no provider found then try the current ClassLoader
+                        if (in == null) {
+                            cl = null;
+                            in = ss.getResourceAsStream(cl, service);
                         }
-                        return clsName;
+                    } else {
+                        // No Context ClassLoader, try the current ClassLoader
+                        in = ss.getResourceAsStream(cl, service);
                     }
-                });
+
+                    if (in != null) {
+                        reader = new BufferedReader (
+                                new InputStreamReader (in, "UTF8"));
+                        className = reader.readLine ();
+                        in.close ();
+                    }
+                } catch (Exception e) {
+                }
             }
-            className = _clsFromJar;
         }
 
         // 3. Distro-specific fallback
@@ -187,7 +187,7 @@
 
         // do we know the XMLReader implementation class yet?
         if (className != null)
-            return loadClass (loader, className);
+            return loadClass (cl, className);
 
         // 4. panic -- adapt any SAX1 parser
         try {
@@ -217,7 +217,7 @@
     public static XMLReader createXMLReader (String className)
         throws SAXException
     {
-        return loadClass (NewInstance.getClassLoader (), className);
+        return loadClass (ss.getContextClassLoader(), className);
     }
 
     private static XMLReader loadClass (ClassLoader loader, String className)