Merge
authorlana
Thu, 02 Jul 2015 16:07:57 -0700
changeset 31498 8ebacfaf4ba6
parent 31496 c8efa0262675 (current diff)
parent 31497 4a6b2e733c0d (diff)
child 31499 fae46850f641
Merge
jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/JavaWrapper.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SmartTransformerFactoryImpl.java
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/JavaWrapper.java	Thu Jul 02 08:54:00 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-package com.sun.org.apache.bcel.internal.util;
-
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- *    "Apache BCEL" must not be used to endorse or promote products
- *    derived from this software without prior written permission. For
- *    written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    "Apache BCEL", nor may "Apache" appear in their name, without
- *    prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-import java.lang.reflect.*;
-
-/**
- * Java interpreter replacement, i.e., wrapper that uses its own ClassLoader
- * to modify/generate classes as they're requested. You can take this as a template
- * for your own applications.<br>
- * Call this wrapper with
- * <pre>java com.sun.org.apache.bcel.internal.util.JavaWrapper &lt;real.class.name&gt; [arguments]</pre>
- * <p>
- * To use your own class loader you can set the "bcel.classloader" system property
- * which defaults to "com.sun.org.apache.bcel.internal.util.ClassLoader", e.g., with
- * <pre>java com.sun.org.apache.bcel.internal.util.JavaWrapper -Dbcel.classloader=foo.MyLoader &lt;real.class.name&gt; [arguments]</pre>
- * </p>
- *
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see ClassLoader
- */
-public class JavaWrapper {
-  private java.lang.ClassLoader loader;
-
-  private static java.lang.ClassLoader getClassLoader() {
-    String s = SecuritySupport.getSystemProperty("bcel.classloader");
-
-    if((s == null) || "".equals(s))
-      s = "com.sun.org.apache.bcel.internal.util.ClassLoader";
-
-    try {
-      return (java.lang.ClassLoader)Class.forName(s).newInstance();
-    } catch(Exception e) {
-      throw new RuntimeException(e.toString());
-    }
-  }
-
-  public JavaWrapper(java.lang.ClassLoader loader) {
-    this.loader = loader;
-  }
-
-  public JavaWrapper() {
-    this(getClassLoader());
-  }
-
-  /** Runs the _main method of the given class with the arguments passed in argv
-   *
-   * @param class_name the fully qualified class name
-   * @param argv the arguments just as you would pass them directly
-   */
-  public void runMain(String class_name, String[] argv) throws ClassNotFoundException
-  {
-    Class   cl    = loader.loadClass(class_name);
-    Method method = null;
-
-    try {
-      method = cl.getMethod("_main",  new Class[] { argv.getClass() });
-
-      /* Method _main is sane ?
-       */
-      int   m = method.getModifiers();
-      Class r = method.getReturnType();
-
-      if(!(Modifier.isPublic(m) && Modifier.isStatic(m)) ||
-         Modifier.isAbstract(m) || (r != Void.TYPE))
-        throw new NoSuchMethodException();
-    } catch(NoSuchMethodException no) {
-      System.out.println("In class " + class_name +
-                         ": public static void _main(String[] argv) is not defined");
-      return;
-    }
-
-    try {
-      method.invoke(null, new Object[] { argv });
-    } catch(Exception ex) {
-      ex.printStackTrace();
-    }
-  }
-
-  /** Default _main method used as wrapper, expects the fully qualified class name
-   * of the real class as the first argument.
-   */
-  public static void _main(String[] argv) throws Exception {
-    /* Expects class name as first argument, other arguments are by-passed.
-     */
-    if(argv.length == 0) {
-      System.out.println("Missing class name.");
-      return;
-    }
-
-    String class_name = argv[0];
-    String[] new_argv = new String[argv.length - 1];
-    System.arraycopy(argv, 1, new_argv, 0, new_argv.length);
-
-    JavaWrapper wrapper = new JavaWrapper();
-    wrapper.runMain(class_name, new_argv);
-  }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java	Thu Jul 02 16:07:57 2015 -0700
@@ -22,20 +22,16 @@
  */
 package com.sun.org.apache.xalan.internal.lib;
 
-import java.util.Hashtable;
 import java.util.StringTokenizer;
 
-import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
 import com.sun.org.apache.xalan.internal.extensions.ExpressionContext;
-import com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck;
 import com.sun.org.apache.xpath.internal.NodeSet;
 import com.sun.org.apache.xpath.internal.objects.XBoolean;
 import com.sun.org.apache.xpath.internal.objects.XNumber;
 import com.sun.org.apache.xpath.internal.objects.XObject;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
@@ -275,102 +271,6 @@
     return tokenize(toTokenize, " \t\n\r");
   }
 
-  /**
-   * Return a Node of basic debugging information from the
-   * EnvironmentCheck utility about the Java environment.
-   *
-   * <p>Simply calls the {@link com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck}
-   * utility to grab info about the Java environment and CLASSPATH,
-   * etc., and then returns the resulting Node.  Stylesheets can
-   * then maniuplate this data or simply xsl:copy-of the Node.  Note
-   * that we first attempt to load the more advanced
-   * org.apache.env.Which utility by reflection; only if that fails
-   * to we still use the internal version.  Which is available from
-   * <a href="http://xml.apache.org/commons/">http://xml.apache.org/commons/</a>.</p>
-   *
-   * <p>We throw a WrappedRuntimeException in the unlikely case
-   * that reading information from the environment throws us an
-   * exception. (Is this really the best thing to do?)</p>
-   *
-   * @param myContext an <code>ExpressionContext</code> passed in by the
-   *                  extension mechanism.  This must be an XPathContext.
-   * @return a Node as described above.
-   */
-  public static Node checkEnvironment(ExpressionContext myContext)
-  {
-
-    Document factoryDocument = getDocument();
-
-    Node resultNode = null;
-    try
-    {
-      // First use reflection to try to load Which, which is a
-      //  better version of EnvironmentCheck
-      resultNode = checkEnvironmentUsingWhich(myContext, factoryDocument);
-
-      if (null != resultNode)
-        return resultNode;
-
-      // If reflection failed, fallback to our internal EnvironmentCheck
-      EnvironmentCheck envChecker = new EnvironmentCheck();
-      Hashtable h = envChecker.getEnvironmentHash();
-      resultNode = factoryDocument.createElement("checkEnvironmentExtension");
-      envChecker.appendEnvironmentReport(resultNode, factoryDocument, h);
-      envChecker = null;
-    }
-    catch(Exception e)
-    {
-      throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
-    }
-
-    return resultNode;
-  }
-
-  /**
-   * Private worker method to attempt to use org.apache.env.Which.
-   *
-   * @param myContext an <code>ExpressionContext</code> passed in by the
-   *                  extension mechanism.  This must be an XPathContext.
-   * @param factoryDocument providing createElement services, etc.
-   * @return a Node with environment info; null if any error
-   */
-  private static Node checkEnvironmentUsingWhich(ExpressionContext myContext,
-        Document factoryDocument)
-  {
-    final String WHICH_CLASSNAME = "org.apache.env.Which";
-    final String WHICH_METHODNAME = "which";
-    final Class WHICH_METHOD_ARGS[] = { java.util.Hashtable.class,
-                                        java.lang.String.class,
-                                        java.lang.String.class };
-    try
-    {
-      // Use reflection to try to find xml-commons utility 'Which'
-      Class clazz = ObjectFactory.findProviderClass(WHICH_CLASSNAME, true);
-      if (null == clazz)
-        return null;
-
-      // Fully qualify names since this is the only method they're used in
-      java.lang.reflect.Method method = clazz.getMethod(WHICH_METHODNAME, WHICH_METHOD_ARGS);
-      Hashtable report = new Hashtable();
-
-      // Call the method with our Hashtable, common options, and ignore return value
-      Object[] methodArgs = { report, "XmlCommons;Xalan;Xerces;Crimson;Ant", "" };
-      Object returnValue = method.invoke(null, methodArgs);
-
-      // Create a parent to hold the report and append hash to it
-      Node resultNode = factoryDocument.createElement("checkEnvironmentExtension");
-      com.sun.org.apache.xml.internal.utils.Hashtree2Node.appendHashToNode(report, "whichReport",
-            resultNode, factoryDocument);
-
-      return resultNode;
-    }
-    catch (Throwable t)
-    {
-      // Simply return null; no need to report error
-      return null;
-    }
-  }
-
     /**
    * @return an instance of DOM Document
      */
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Thu Jul 02 16:07:57 2015 -0700
@@ -121,22 +121,7 @@
     public static Object newInstance(String className, boolean doFallback)
         throws ConfigurationError
     {
-        if (System.getSecurityManager()!=null) {
-            return newInstance(className, null, doFallback);
-        } else {
-            return newInstance(className,
-                findClassLoader (), doFallback);
-        }
-    }
-
-    /**
-     * Create an instance of a class using the specified ClassLoader
-     */
-    static Object newInstance(String className, ClassLoader cl,
-                                      boolean doFallback)
-        throws ConfigurationError
-    {
-        // assert(className != null);
+        ClassLoader cl = System.getSecurityManager()!=null ? null : findClassLoader();
         try{
             Class providerClass = findProviderClass(className, cl, doFallback);
             Object instance = providerClass.newInstance();
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SmartTransformerFactoryImpl.java	Thu Jul 02 08:54:00 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,455 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-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.
- */
-/*
- * $Id: SmartTransformerFactoryImpl.java,v 1.2.4.1 2005/09/14 09:57:13 pvedula Exp $
- */
-
-
-package com.sun.org.apache.xalan.internal.xsltc.trax;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TemplatesHandler;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import org.xml.sax.XMLFilter;
-
-/**
- * Implementation of a transformer factory that uses an XSLTC
- * transformer factory for the creation of Templates objects
- * and uses the Xalan processor transformer factory for the
- * creation of Transformer objects.
- * @author G. Todd Miller
- */
-public class SmartTransformerFactoryImpl extends SAXTransformerFactory
-{
-    /**
-     * <p>Name of class as a constant to use for debugging.</p>
-     */
-    private static final String CLASS_NAME = "SmartTransformerFactoryImpl";
-
-    private SAXTransformerFactory _xsltcFactory = null;
-    private SAXTransformerFactory _xalanFactory = null;
-    private SAXTransformerFactory _currFactory = null;
-    private ErrorListener      _errorlistener = null;
-    private URIResolver        _uriresolver = null;
-
-    /**
-     * <p>State of secure processing feature.</p>
-     */
-    private boolean featureSecureProcessing = false;
-
-    /**
-     * implementation of the SmartTransformerFactory. This factory
-     * uses com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory
-     * to return Templates objects; and uses
-     * com.sun.org.apache.xalan.internal.processor.TransformerFactory
-     * to return Transformer objects.
-     */
-    public SmartTransformerFactoryImpl() { }
-
-    private void createXSLTCTransformerFactory() {
-        _xsltcFactory = new TransformerFactoryImpl();
-        _currFactory = _xsltcFactory;
-    }
-
-    private void createXalanTransformerFactory() {
-        final String xalanMessage =
-            "com.sun.org.apache.xalan.internal.xsltc.trax.SmartTransformerFactoryImpl "+
-            "could not create an "+
-            "com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.";
-        // try to create instance of Xalan factory...
-        try {
-            Class xalanFactClass = ObjectFactory.findProviderClass(
-                "com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl",
-                true);
-            _xalanFactory = (SAXTransformerFactory)
-                xalanFactClass.newInstance();
-        }
-        catch (ClassNotFoundException e) {
-            System.err.println(xalanMessage);
-        }
-        catch (InstantiationException e) {
-            System.err.println(xalanMessage);
-        }
-        catch (IllegalAccessException e) {
-            System.err.println(xalanMessage);
-        }
-        _currFactory = _xalanFactory;
-    }
-
-    public void setErrorListener(ErrorListener listener)
-        throws IllegalArgumentException
-    {
-        _errorlistener = listener;
-    }
-
-    public ErrorListener getErrorListener() {
-        return _errorlistener;
-    }
-
-    public Object getAttribute(String name)
-        throws IllegalArgumentException
-    {
-        // GTM: NB: 'debug' should change to something more unique...
-        if ((name.equals("translet-name")) || (name.equals("debug"))) {
-            if (_xsltcFactory == null) {
-                createXSLTCTransformerFactory();
-            }
-            return _xsltcFactory.getAttribute(name);
-        }
-        else {
-            if (_xalanFactory == null) {
-                createXalanTransformerFactory();
-            }
-            return _xalanFactory.getAttribute(name);
-        }
-    }
-
-    public void setAttribute(String name, Object value)
-        throws IllegalArgumentException {
-        // GTM: NB: 'debug' should change to something more unique...
-        if ((name.equals("translet-name")) || (name.equals("debug"))) {
-            if (_xsltcFactory == null) {
-                createXSLTCTransformerFactory();
-            }
-            _xsltcFactory.setAttribute(name, value);
-        }
-        else {
-            if (_xalanFactory == null) {
-                createXalanTransformerFactory();
-            }
-            _xalanFactory.setAttribute(name, value);
-        }
-    }
-
-    /**
-     * <p>Set a feature for this <code>SmartTransformerFactory</code> and <code>Transformer</code>s
-     * or <code>Template</code>s created by this factory.</p>
-     *
-     * <p>
-     * Feature names are fully qualified {@link java.net.URI}s.
-     * Implementations may define their own features.
-     * An {@link TransformerConfigurationException} is thrown if this <code>TransformerFactory</code> or the
-     * <code>Transformer</code>s or <code>Template</code>s it creates cannot support the feature.
-     * It is possible for an <code>TransformerFactory</code> to expose a feature value but be unable to change its state.
-     * </p>
-     *
-     * <p>See {@link javax.xml.transform.TransformerFactory} for full documentation of specific features.</p>
-     *
-     * @param name Feature name.
-     * @param value Is feature state <code>true</code> or <code>false</code>.
-     *
-     * @throws TransformerConfigurationException if this <code>TransformerFactory</code>
-     *   or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
-     * @throws NullPointerException If the <code>name</code> parameter is null.
-     */
-    public void setFeature(String name, boolean value)
-        throws TransformerConfigurationException {
-
-        // feature name cannot be null
-        if (name == null) {
-            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SET_FEATURE_NULL_NAME);
-            throw new NullPointerException(err.toString());
-        }
-        // secure processing?
-        else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
-            featureSecureProcessing = value;
-            // all done processing feature
-            return;
-        }
-        else {
-            // unknown feature
-            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name);
-            throw new TransformerConfigurationException(err.toString());
-        }
-    }
-
-    /**
-     * javax.xml.transform.sax.TransformerFactory implementation.
-     * Look up the value of a feature (to see if it is supported).
-     * This method must be updated as the various methods and features of this
-     * class are implemented.
-     *
-     * @param name The feature name
-     * @return 'true' if feature is supported, 'false' if not
-     */
-    public boolean getFeature(String name) {
-        // All supported features should be listed here
-        String[] features = {
-            DOMSource.FEATURE,
-            DOMResult.FEATURE,
-            SAXSource.FEATURE,
-            SAXResult.FEATURE,
-            StreamSource.FEATURE,
-            StreamResult.FEATURE
-        };
-
-        // feature name cannot be null
-        if (name == null) {
-            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_GET_FEATURE_NULL_NAME);
-            throw new NullPointerException(err.toString());
-        }
-
-        // Inefficient, but it really does not matter in a function like this
-        for (int i = 0; i < features.length; i++) {
-            if (name.equals(features[i]))
-                return true;
-        }
-
-        // secure processing?
-        if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
-            return featureSecureProcessing;
-        }
-
-        // unknown feature
-        return false;
-    }
-
-    public URIResolver getURIResolver() {
-        return _uriresolver;
-    }
-
-    public void setURIResolver(URIResolver resolver) {
-        _uriresolver = resolver;
-    }
-
-    public Source getAssociatedStylesheet(Source source, String media,
-                                          String title, String charset)
-        throws TransformerConfigurationException
-    {
-        if (_currFactory == null) {
-            createXSLTCTransformerFactory();
-        }
-        return _currFactory.getAssociatedStylesheet(source, media,
-                title, charset);
-    }
-
-    /**
-     * Create a Transformer object that copies the input document to the
-     * result. Uses the com.sun.org.apache.xalan.internal.processor.TransformerFactory.
-     * @return A Transformer object.
-     */
-    public Transformer newTransformer()
-        throws TransformerConfigurationException
-    {
-        if (_xalanFactory == null) {
-            createXalanTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xalanFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xalanFactory.setURIResolver(_uriresolver);
-        }
-        _currFactory = _xalanFactory;
-        return _currFactory.newTransformer();
-    }
-
-    /**
-     * Create a Transformer object that from the input stylesheet
-     * Uses the com.sun.org.apache.xalan.internal.processor.TransformerFactory.
-     * @param source the stylesheet.
-     * @return A Transformer object.
-     */
-    public Transformer newTransformer(Source source) throws
-        TransformerConfigurationException
-    {
-        if (_xalanFactory == null) {
-            createXalanTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xalanFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xalanFactory.setURIResolver(_uriresolver);
-        }
-        _currFactory = _xalanFactory;
-        return _currFactory.newTransformer(source);
-    }
-
-    /**
-     * Create a Templates object that from the input stylesheet
-     * Uses the com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
-     * @param source the stylesheet.
-     * @return A Templates object.
-     */
-    public Templates newTemplates(Source source)
-        throws TransformerConfigurationException
-    {
-        if (_xsltcFactory == null) {
-            createXSLTCTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xsltcFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xsltcFactory.setURIResolver(_uriresolver);
-        }
-        _currFactory = _xsltcFactory;
-        return _currFactory.newTemplates(source);
-    }
-
-    /**
-     * Get a TemplatesHandler object that can process SAX ContentHandler
-     * events into a Templates object. Uses the
-     * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
-     */
-    public TemplatesHandler newTemplatesHandler()
-        throws TransformerConfigurationException
-    {
-        if (_xsltcFactory == null) {
-            createXSLTCTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xsltcFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xsltcFactory.setURIResolver(_uriresolver);
-        }
-        return _xsltcFactory.newTemplatesHandler();
-    }
-
-    /**
-     * Get a TransformerHandler object that can process SAX ContentHandler
-     * events based on a copy transformer.
-     * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
-     */
-    public TransformerHandler newTransformerHandler()
-        throws TransformerConfigurationException
-    {
-        if (_xalanFactory == null) {
-            createXalanTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xalanFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xalanFactory.setURIResolver(_uriresolver);
-        }
-        return _xalanFactory.newTransformerHandler();
-    }
-
-    /**
-     * Get a TransformerHandler object that can process SAX ContentHandler
-     * events based on a transformer specified by the stylesheet Source.
-     * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
-     */
-    public TransformerHandler newTransformerHandler(Source src)
-        throws TransformerConfigurationException
-    {
-        if (_xalanFactory == null) {
-            createXalanTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xalanFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xalanFactory.setURIResolver(_uriresolver);
-        }
-        return _xalanFactory.newTransformerHandler(src);
-    }
-
-
-    /**
-     * Get a TransformerHandler object that can process SAX ContentHandler
-     * events based on a transformer specified by the stylesheet Source.
-     * Uses com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
-     */
-    public TransformerHandler newTransformerHandler(Templates templates)
-        throws TransformerConfigurationException
-    {
-        if (_xsltcFactory == null) {
-            createXSLTCTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xsltcFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xsltcFactory.setURIResolver(_uriresolver);
-        }
-        return _xsltcFactory.newTransformerHandler(templates);
-    }
-
-
-    /**
-     * Create an XMLFilter that uses the given source as the
-     * transformation instructions. Uses
-     * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
-     */
-    public XMLFilter newXMLFilter(Source src)
-        throws TransformerConfigurationException {
-        if (_xsltcFactory == null) {
-            createXSLTCTransformerFactory();
-        }
-        if (_errorlistener != null) {
-            _xsltcFactory.setErrorListener(_errorlistener);
-        }
-        if (_uriresolver != null) {
-            _xsltcFactory.setURIResolver(_uriresolver);
-        }
-        Templates templates = _xsltcFactory.newTemplates(src);
-        if (templates == null ) return null;
-        return newXMLFilter(templates);
-    }
-
-    /*
-     * Create an XMLFilter that uses the given source as the
-     * transformation instructions. Uses
-     * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
-     */
-    public XMLFilter newXMLFilter(Templates templates)
-        throws TransformerConfigurationException {
-        try {
-            return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
-        }
-        catch(TransformerConfigurationException e1) {
-            if (_xsltcFactory == null) {
-                createXSLTCTransformerFactory();
-            }
-            ErrorListener errorListener = _xsltcFactory.getErrorListener();
-            if(errorListener != null) {
-                try {
-                    errorListener.fatalError(e1);
-                    return null;
-                }
-                catch( TransformerException e2) {
-                    new TransformerConfigurationException(e2);
-                }
-            }
-            throw e1;
-        }
-    }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java	Thu Jul 02 16:07:57 2015 -0700
@@ -371,11 +371,7 @@
             // to restrict the number of validation handlers being
             // requested
             if(freeValidatorIndex < 0) {
-                return (RevalidationHandler) (ObjectFactory
-                            .newInstance(
-                                "com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator",
-                                ObjectFactory.findClassLoader(),
-                                true));
+                return new com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator();
             }
             // return first available validator
             RevalidationHandler val = validators[freeValidatorIndex];
@@ -384,11 +380,7 @@
         }
         else if(schemaType == XMLGrammarDescription.XML_DTD) {
             if(freeDTDValidatorIndex < 0) {
-                return (RevalidationHandler) (ObjectFactory
-                            .newInstance(
-                                "com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator",
-                                ObjectFactory.findClassLoader(),
-                                true));
+                return new com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator();
             }
             // return first available validator
             RevalidationHandler val = dtdValidators[freeDTDValidatorIndex];
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Thu Jul 02 16:07:57 2015 -0700
@@ -638,7 +638,7 @@
                         // set preference for redirection
                         followRedirects = httpInputSource.getFollowHTTPRedirects();
                         if (!followRedirects) {
-                            setInstanceFollowRedirects(urlConnection, followRedirects);
+                            urlConnection.setInstanceFollowRedirects(followRedirects);
                         }
                     }
 
@@ -2193,20 +2193,6 @@
     } // expandSystemIdStrictOn(String,String):String
 
     /**
-     * Attempt to set whether redirects will be followed for an <code>HttpURLConnection</code>.
-     * This may fail on earlier JDKs which do not support setting this preference.
-     */
-    public static void setInstanceFollowRedirects(HttpURLConnection urlCon, boolean followRedirects) {
-        try {
-            Method method = HttpURLConnection.class.getMethod("setInstanceFollowRedirects", new Class[] {Boolean.TYPE});
-            method.invoke(urlCon, new Object[] {followRedirects ? Boolean.TRUE : Boolean.FALSE});
-        }
-        // setInstanceFollowRedirects doesn't exist.
-        catch (Exception exc) {}
-    }
-
-
-    /**
      * Helper method for expandSystemId(String,String,boolean):String
      */
     private static String expandSystemIdStrictOff(String systemId, String baseSystemId)
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java	Thu Jul 02 16:07:57 2015 -0700
@@ -845,13 +845,7 @@
      */
     public static DOMException createDOMException(short code, Throwable cause) {
         DOMException de = new DOMException(code, cause != null ? cause.getMessage() : null);
-        if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
-            try {
-                ThrowableMethods.fgThrowableInitCauseMethod.invoke(de, new Object [] {cause});
-            }
-            // Something went wrong. There's not much we can do about it.
-            catch (Exception e) {}
-        }
+        if (cause != null) de.initCause(cause);
         return de;
     }
 
@@ -860,42 +854,8 @@
      */
     public static LSException createLSException(short code, Throwable cause) {
         LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
-        if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
-            try {
-                ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
-            }
-            // Something went wrong. There's not much we can do about it.
-            catch (Exception e) {}
-        }
+        if (cause != null) lse.initCause(cause);
         return lse;
     }
 
-    /**
-     * Holder of methods from java.lang.Throwable.
-     */
-    static class ThrowableMethods {
-
-        // Method: java.lang.Throwable.initCause(java.lang.Throwable)
-        private static java.lang.reflect.Method fgThrowableInitCauseMethod = null;
-
-        // Flag indicating whether or not Throwable methods available.
-        private static boolean fgThrowableMethodsAvailable = false;
-
-        private ThrowableMethods() {}
-
-        // Attempt to get methods for java.lang.Throwable on class initialization.
-        static {
-            try {
-                fgThrowableInitCauseMethod = Throwable.class.getMethod("initCause", new Class [] {Throwable.class});
-                fgThrowableMethodsAvailable = true;
-            }
-            // ClassNotFoundException, NoSuchMethodException or SecurityException
-            // Whatever the case, we cannot use java.lang.Throwable.initCause(java.lang.Throwable).
-            catch (Exception exc) {
-                fgThrowableInitCauseMethod = null;
-                fgThrowableMethodsAvailable = false;
-            }
-        }
-    }
-
 } // class DOMUtil
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java	Thu Jul 02 16:07:57 2015 -0700
@@ -140,7 +140,7 @@
                     // set preference for redirection
                     boolean followRedirects = httpInputSource.getFollowHTTPRedirects();
                     if (!followRedirects) {
-                        XMLEntityManager.setInstanceFollowRedirects(urlConnection, followRedirects);
+                        urlConnection.setInstanceFollowRedirects(followRedirects);
                     }
                 }
 
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java	Thu Jul 02 16:07:57 2015 -0700
@@ -323,63 +323,5 @@
             super.printStackTrace(s);
         } catch (Throwable e) {}
 
-        boolean isJdk14OrHigher = false;
-        try {
-            Throwable.class.getMethod("getCause", (Class[]) null);
-            isJdk14OrHigher = true;
-        } catch (NoSuchMethodException nsme) {
-            // do nothing
-        }
-
-        // The printStackTrace method of the Throwable class in jdk 1.4
-        // and higher will include the cause when printing the backtrace.
-        // The following code is only required when using jdk 1.3 or lower
-        if (!isJdk14OrHigher) {
-            Throwable exception = getException();
-
-            for (int i = 0; (i < 10) && (null != exception); i++) {
-                s.println("---------");
-
-                try {
-                    if (exception instanceof DTMException) {
-                        String locInfo =
-                            ((DTMException) exception)
-                                .getLocationAsString();
-
-                        if (null != locInfo) {
-                            s.println(locInfo);
-                        }
-                    }
-
-                    exception.printStackTrace(s);
-                } catch (Throwable e) {
-                    s.println("Could not print stack trace...");
-                }
-
-                try {
-                    Method meth =
-                        ((Object) exception).getClass().getMethod("getException",
-                            (Class[]) null);
-
-                    if (null != meth) {
-                        Throwable prev = exception;
-
-                        exception = (Throwable) meth.invoke(exception, (Object[]) null);
-
-                        if (prev == exception) {
-                            break;
-                        }
-                    } else {
-                        exception = null;
-                    }
-                } catch (InvocationTargetException ite) {
-                    exception = null;
-                } catch (IllegalAccessException iae) {
-                    exception = null;
-                } catch (NoSuchMethodException nsme) {
-                    exception = null;
-                }
-            }
-        }
     }
 }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java	Thu Jul 02 16:07:57 2015 -0700
@@ -348,8 +348,7 @@
             if (haveXercesParser) {
               // IncrementalSAXSource_Xerces to avoid threading.
               try {
-                coParser =(IncrementalSAXSource)
-                  Class.forName("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces").newInstance();
+                coParser = new com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces();
               }  catch( Exception ex ) {
                 ex.printStackTrace();
                 coParser=null;
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java	Thu Jul 02 16:07:57 2015 -0700
@@ -87,6 +87,9 @@
         {
                 try
                 {
+                        // This should be cleaned up and the use of reflection
+                        // removed - see JDK-8129880
+
                         // Xerces-2 incremental parsing support (as of Beta 3)
                         // ContentHandlers still get set on fIncrementalParser (to get
                         // conversion from XNI events to SAX events), but
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Thu Jul 02 16:07:57 2015 -0700
@@ -233,7 +233,13 @@
                 }
                 parser.parse(new InputSource(is), spHandler);
             } else {
-                Parser parser = (Parser) ReflectUtil.forName(parserClass).newInstance();
+                Class<?> c =  ReflectUtil.forName(parserClass);
+                if (!Parser.class.isAssignableFrom(c)) {
+                    throw new ClassCastException(parserClass
+                                + " cannot be cast to "
+                                + Parser.class.getName());
+                }
+                Parser parser = (Parser) c.newInstance();
                 parser.setDocumentHandler(this);
                 if (bResolver != null) {
                     parser.setEntityResolver(bResolver);
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Thu Jul 02 16:07:57 2015 -0700
@@ -1220,37 +1220,13 @@
                     if ( internal != null && internal.length() > 0 )
                         _printer.printText( internal );
                     endDTD();
-                }
-                // DOM Level 1 -- does implementation have methods?
-                catch (NoSuchMethodError nsme) {
-                    Class docTypeClass = docType.getClass();
-
-                    String docTypePublicId = null;
-                    String docTypeSystemId = null;
-                    try {
-                        java.lang.reflect.Method getPublicId = docTypeClass.getMethod("getPublicId", (Class[]) null);
-                        if (getPublicId.getReturnType().equals(String.class)) {
-                            docTypePublicId = (String)getPublicId.invoke(docType, (Object[]) null);
-                        }
-                    }
-                    catch (Exception e) {
-                        // ignore
-                    }
-                    try {
-                        java.lang.reflect.Method getSystemId = docTypeClass.getMethod("getSystemId", (Class[]) null);
-                        if (getSystemId.getReturnType().equals(String.class)) {
-                            docTypeSystemId = (String)getSystemId.invoke(docType, (Object[]) null);
-                        }
-                    }
-                    catch (Exception e) {
-                        // ignore
-                    }
+                } catch (Exception e) {
+                    // ignore
                     _printer.enterDTD();
-                    _docTypePublicId = docTypePublicId;
-                    _docTypeSystemId = docTypeSystemId;
+                    _docTypePublicId = null;
+                    _docTypeSystemId = null;
                     endDTD();
                 }
-
                 serializeDTD(docType.getName());
 
             }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java	Thu Jul 02 16:07:57 2015 -0700
@@ -54,7 +54,6 @@
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
 import org.w3c.dom.ls.LSException;
 import org.w3c.dom.ls.LSOutput;
 import org.w3c.dom.ls.LSSerializer;
@@ -1030,15 +1029,12 @@
     private String _getXmlVersion(Node node) {
         Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
                 ? (Document) node : node.getOwnerDocument();
-        if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+        if (doc != null) {
             try {
-                return (String) DocumentMethods.fgDocumentGetXmlVersionMethod.invoke(doc, (Object[]) null);
+                return doc.getXmlVersion();
             } // The VM ran out of memory or there was some other serious problem. Re-throw.
-            catch (VirtualMachineError vme) {
+             catch (VirtualMachineError | ThreadDeath vme) {
                 throw vme;
-            } // ThreadDeath should always be re-thrown
-            catch (ThreadDeath td) {
-                throw td;
             } // Ignore all other exceptions and errors
             catch (Throwable t) {
             }
@@ -1049,15 +1045,12 @@
     private String _getInputEncoding(Node node) {
         Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
                 ? (Document) node : node.getOwnerDocument();
-        if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+        if (doc != null) {
             try {
-                return (String) DocumentMethods.fgDocumentGetInputEncodingMethod.invoke(doc, (Object[]) null);
+                return doc.getInputEncoding();
             } // The VM ran out of memory or there was some other serious problem. Re-throw.
-            catch (VirtualMachineError vme) {
+            catch (VirtualMachineError | ThreadDeath vme) {
                 throw vme;
-            } // ThreadDeath should always be re-thrown
-            catch (ThreadDeath td) {
-                throw td;
             } // Ignore all other exceptions and errors
             catch (Throwable t) {
             }
@@ -1068,15 +1061,12 @@
     private String _getXmlEncoding(Node node) {
         Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
                 ? (Document) node : node.getOwnerDocument();
-        if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+        if (doc != null) {
             try {
-                return (String) DocumentMethods.fgDocumentGetXmlEncodingMethod.invoke(doc, (Object[]) null);
+                return doc.getXmlEncoding();
             } // The VM ran out of memory or there was some other serious problem. Re-throw.
-            catch (VirtualMachineError vme) {
+            catch (VirtualMachineError | ThreadDeath vme) {
                 throw vme;
-            } // ThreadDeath should always be re-thrown
-            catch (ThreadDeath td) {
-                throw td;
             } // Ignore all other exceptions and errors
             catch (Throwable t) {
             }
@@ -1084,42 +1074,4 @@
         return null;
     }
 
-    /**
-     * Holder of DOM Level 3 methods from org.w3c.dom.Document.
-     */
-    static class DocumentMethods {
-
-        // Method: org.w3c.dom.Document.getXmlVersion()
-        private static java.lang.reflect.Method fgDocumentGetXmlVersionMethod = null;
-
-        // Method: org.w3c.dom.Document.getInputEncoding()
-        private static java.lang.reflect.Method fgDocumentGetInputEncodingMethod = null;
-
-        // Method: org.w3c.dom.Document.getXmlEncoding()
-        private static java.lang.reflect.Method fgDocumentGetXmlEncodingMethod = null;
-
-        // Flag indicating whether or not Document methods are available.
-        private static boolean fgDocumentMethodsAvailable = false;
-
-        private DocumentMethods() {
-        }
-
-        // Attempt to get methods for org.w3c.dom.Document on class initialization.
-        static {
-            try {
-                fgDocumentGetXmlVersionMethod = Document.class.getMethod("getXmlVersion", new Class[]{});
-                fgDocumentGetInputEncodingMethod = Document.class.getMethod("getInputEncoding", new Class[]{});
-                fgDocumentGetXmlEncodingMethod = Document.class.getMethod("getXmlEncoding", new Class[]{});
-                fgDocumentMethodsAvailable = true;
-            } // ClassNotFoundException, NoSuchMethodException or SecurityException
-            // Whatever the case, we cannot retrieve the methods.
-            catch (Exception exc) {
-                fgDocumentGetXmlVersionMethod = null;
-                fgDocumentGetInputEncodingMethod = null;
-                fgDocumentGetXmlEncodingMethod = null;
-                fgDocumentMethodsAvailable = false;
-            }
-        }
-    }
-
 } //DOMSerializerImpl
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java	Thu Jul 02 16:07:57 2015 -0700
@@ -26,6 +26,8 @@
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import com.sun.org.apache.xerces.internal.util.EncodingMap;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
 
 /**
  * This class represents an encoding.
@@ -37,9 +39,6 @@
  */
 public class EncodingInfo {
 
-    // An array to hold the argument for a method of Charset, CharsetEncoder or CharToByteConverter.
-    private Object [] fArgsForMethod = null;
-
     // name of encoding as registered with IANA;
     // preferably a MIME name, but aliases are fine too.
     String ianaName;
@@ -47,15 +46,7 @@
     int lastPrintable;
 
     // The CharsetEncoder with which we test unusual characters.
-    Object fCharsetEncoder = null;
-
-    // The CharToByteConverter with which we test unusual characters.
-    Object fCharToByteConverter = null;
-
-    // Is the converter null because it can't be instantiated
-    // for some reason (perhaps we're running with insufficient authority as
-    // an applet?
-    boolean fHaveTriedCToB = false;
+    CharsetEncoder fCharsetEncoder = null;
 
     // Is the charset encoder usable or available.
     boolean fHaveTriedCharsetEncoder = false;
@@ -118,16 +109,12 @@
     private boolean isPrintable0(char ch) {
 
         // Attempt to get a CharsetEncoder for this encoding.
-        if (fCharsetEncoder == null && CharsetMethods.fgNIOCharsetAvailable && !fHaveTriedCharsetEncoder) {
-            if (fArgsForMethod == null) {
-                fArgsForMethod = new Object [1];
-            }
+        if (fCharsetEncoder == null && !fHaveTriedCharsetEncoder) {
             // try and create the CharsetEncoder
             try {
-                fArgsForMethod[0] = javaName;
-                Object charset = CharsetMethods.fgCharsetForNameMethod.invoke(null, fArgsForMethod);
-                if (((Boolean) CharsetMethods.fgCharsetCanEncodeMethod.invoke(charset, (Object[]) null)).booleanValue()) {
-                    fCharsetEncoder = CharsetMethods.fgCharsetNewEncoderMethod.invoke(charset, (Object[]) null);
+                Charset charset = java.nio.charset.Charset.forName(javaName);
+                if (charset.canEncode()) {
+                    fCharsetEncoder = charset.newEncoder();
                 }
                 // This charset cannot be used for encoding, don't try it again...
                 else {
@@ -142,8 +129,7 @@
         // Attempt to use the CharsetEncoder to determine whether the character is printable.
         if (fCharsetEncoder != null) {
             try {
-                fArgsForMethod[0] = new Character(ch);
-                return ((Boolean) CharsetMethods.fgCharsetEncoderCanEncodeMethod.invoke(fCharsetEncoder, fArgsForMethod)).booleanValue();
+                return fCharsetEncoder.canEncode(ch);
             }
             catch (Exception e) {
                 // obviously can't use this charset encoder; possibly a JDK bug
@@ -152,39 +138,7 @@
             }
         }
 
-        // As a last resort try to use a sun.io.CharToByteConverter to
-        // determine whether this character is printable. We will always
-        // reach here on JDK 1.3 or below.
-        if (fCharToByteConverter == null) {
-            if (fHaveTriedCToB || !CharToByteConverterMethods.fgConvertersAvailable) {
-                // forget it; nothing we can do...
-                return false;
-            }
-            if (fArgsForMethod == null) {
-                fArgsForMethod = new Object [1];
-            }
-            // try and create the CharToByteConverter
-            try {
-                fArgsForMethod[0] = javaName;
-                fCharToByteConverter = CharToByteConverterMethods.fgGetConverterMethod.invoke(null, fArgsForMethod);
-            }
-            catch (Exception e) {
-                // don't try it again...
-                fHaveTriedCToB = true;
-                return false;
-            }
-        }
-        try {
-            fArgsForMethod[0] = new Character(ch);
-            return ((Boolean) CharToByteConverterMethods.fgCanConvertMethod.invoke(fCharToByteConverter, fArgsForMethod)).booleanValue();
-        }
-        catch (Exception e) {
-            // obviously can't use this converter; probably some kind of
-            // security restriction
-            fCharToByteConverter = null;
-            fHaveTriedCToB = false;
-            return false;
-        }
+        return false;
     }
 
     // is this an encoding name recognized by this JDK?
@@ -194,82 +148,4 @@
         String s = new String(bTest, name);
     }
 
-    /**
-     * Holder of methods from java.nio.charset.Charset and java.nio.charset.CharsetEncoder.
-     */
-    static class CharsetMethods {
-
-        // Method: java.nio.charset.Charset.forName(java.lang.String)
-        private static java.lang.reflect.Method fgCharsetForNameMethod = null;
-
-        // Method: java.nio.charset.Charset.canEncode()
-        private static java.lang.reflect.Method fgCharsetCanEncodeMethod = null;
-
-        // Method: java.nio.charset.Charset.newEncoder()
-        private static java.lang.reflect.Method fgCharsetNewEncoderMethod = null;
-
-        // Method: java.nio.charset.CharsetEncoder.canEncode(char)
-        private static java.lang.reflect.Method fgCharsetEncoderCanEncodeMethod = null;
-
-        // Flag indicating whether or not java.nio.charset.* is available.
-        private static boolean fgNIOCharsetAvailable = false;
-
-        private CharsetMethods() {}
-
-        // Attempt to get methods for Charset and CharsetEncoder on class initialization.
-        static {
-            try {
-                Class charsetClass = Class.forName("java.nio.charset.Charset");
-                Class charsetEncoderClass = Class.forName("java.nio.charset.CharsetEncoder");
-                fgCharsetForNameMethod = charsetClass.getMethod("forName", new Class [] {String.class});
-                fgCharsetCanEncodeMethod = charsetClass.getMethod("canEncode", new Class [] {});
-                fgCharsetNewEncoderMethod = charsetClass.getMethod("newEncoder", new Class [] {});
-                fgCharsetEncoderCanEncodeMethod = charsetEncoderClass.getMethod("canEncode", new Class [] {Character.TYPE});
-                fgNIOCharsetAvailable = true;
-            }
-            // ClassNotFoundException, NoSuchMethodException or SecurityException
-            // Whatever the case, we cannot use java.nio.charset.*.
-            catch (Exception exc) {
-                fgCharsetForNameMethod = null;
-                fgCharsetCanEncodeMethod = null;
-                fgCharsetEncoderCanEncodeMethod = null;
-                fgCharsetNewEncoderMethod = null;
-                fgNIOCharsetAvailable = false;
-            }
-        }
-    }
-
-    /**
-     * Holder of methods from sun.io.CharToByteConverter.
-     */
-    static class CharToByteConverterMethods {
-
-        // Method: sun.io.CharToByteConverter.getConverter(java.lang.String)
-        private static java.lang.reflect.Method fgGetConverterMethod = null;
-
-        // Method: sun.io.CharToByteConverter.canConvert(char)
-        private static java.lang.reflect.Method fgCanConvertMethod = null;
-
-        // Flag indicating whether or not sun.io.CharToByteConverter is available.
-        private static boolean fgConvertersAvailable = false;
-
-        private CharToByteConverterMethods() {}
-
-        // Attempt to get methods for char to byte converter on class initialization.
-        static {
-            try {
-                Class clazz = Class.forName("sun.io.CharToByteConverter");
-                fgGetConverterMethod = clazz.getMethod("getConverter", new Class [] {String.class});
-                fgCanConvertMethod = clazz.getMethod("canConvert", new Class [] {Character.TYPE});
-                fgConvertersAvailable = true;
-            }
-            // ClassNotFoundException, NoSuchMethodException or SecurityException
-            // Whatever the case, we cannot use sun.io.CharToByteConverter.
-            catch (Exception exc) {
-                fgGetConverterMethod = null;
-                fgCanConvertMethod = null;
-                fgConvertersAvailable = false;
-            }
-        }
-    }
 }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java	Thu Jul 02 16:07:57 2015 -0700
@@ -378,6 +378,12 @@
     int funcIndex;
     Object funcIndexObj = getFunctionID(name);
 
+    if (func != null && !Function.class.isAssignableFrom(func)) {
+        throw new ClassCastException(func.getName()
+                  + " cannot be cast to "
+                  + Function.class.getName());
+    }
+
     if (null != funcIndexObj)
     {
       funcIndex = ((Integer) funcIndexObj).intValue();
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Thu Jul 02 16:07:57 2015 -0700
@@ -64,7 +64,6 @@
     private Node currentNode = null;
     private Node node = null;
     private NamespaceSupport namespaceContext = null;
-    private Method  mXmlVersion = null;
     private boolean [] needContextPop = null;
     private StringBuffer stringBuffer = null;
     private int resizeValue = 20;
@@ -83,25 +82,11 @@
             ownerDoc = node.getOwnerDocument();
             currentNode = node;
         }
-        getDLThreeMethods();
         stringBuffer = new StringBuffer();
         needContextPop = new boolean[resizeValue];
         namespaceContext = new NamespaceSupport();
     }
 
-    private void getDLThreeMethods(){
-        try{
-            mXmlVersion =  ownerDoc.getClass().getMethod("setXmlVersion",new Class[] {String.class});
-        }catch(NoSuchMethodException mex){
-            //log these errors at fine level.
-            mXmlVersion = null;
-        }catch(SecurityException se){
-            //log these errors at fine level.
-            mXmlVersion = null;
-        }
-    }
-
-
     /**
      * This method has no effect when called.
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
@@ -557,15 +542,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument() throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {"1.0"});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion("1.0");
     }
 
     /**
@@ -575,15 +552,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String version) throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {version});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion(version);
     }
 
     /**
@@ -594,15 +563,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String encoding, String version) throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {version});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion(version);
         //TODO: What to do with encoding.-Venu
     }
 
--- a/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java	Thu Jul 02 16:07:57 2015 -0700
@@ -110,6 +110,12 @@
      */
     public synchronized Throwable initCause(Throwable cause) {
 
+        // TransformerException doesn't set its cause (probably
+        // because it predates initCause()) - and we may not want
+        // to change this since Exceptions are serializable...
+        // But this also leads to the broken code in printStackTrace
+        // below...
+
         if (this.containedException != null) {
             throw new IllegalStateException("Can't overwrite cause");
         }
@@ -312,61 +318,57 @@
         }
 
         try {
-            String locInfo = getLocationAsString();
+            try {
+                String locInfo = getLocationAsString();
 
-            if (null != locInfo) {
-                s.println(locInfo);
-            }
+                if (null != locInfo) {
+                    s.println(locInfo);
+                }
 
-            super.printStackTrace(s);
-        } catch (Throwable e) {}
+                super.printStackTrace(s);
+            } catch (Throwable e) {}
 
-        Throwable exception = getException();
+            Throwable exception = getException();
 
-        for (int i = 0; (i < 10) && (null != exception); i++) {
-            s.println("---------");
+            for (int i = 0; (i < 10) && (null != exception); i++) {
+                s.println("---------");
 
-            try {
-                if (exception instanceof TransformerException) {
-                    String locInfo =
-                        ((TransformerException) exception)
-                            .getLocationAsString();
-
-                    if (null != locInfo) {
-                        s.println(locInfo);
-                    }
+                try {
+                    exception.printStackTrace(s);
+                    // if exception is a TransformerException it will print
+                    // its contained exception, so we don't need to redo it here,
+                    // and we can exit the loop now.
+                    if (exception instanceof TransformerException) break;
+                } catch (Throwable e) {
+                    s.println("Could not print stack trace...");
                 }
 
-                exception.printStackTrace(s);
-            } catch (Throwable e) {
-                s.println("Could not print stack trace...");
-            }
+                try {
+                    // Is this still needed?
+                    Method meth = exception.getClass().getMethod("getException");
 
-            try {
-                Method meth =
-                    ((Object) exception).getClass().getMethod("getException",
-                        (Class[]) null);
+                    if (null != meth) {
+                        Throwable prev = exception;
+
+                        exception = (Throwable) meth.invoke(exception, (Object[]) null);
 
-                if (null != meth) {
-                    Throwable prev = exception;
-
-                    exception = (Throwable) meth.invoke(exception, (Object[]) null);
-
-                    if (prev == exception) {
-                        break;
+                        if (prev == exception) {
+                            break;
+                        }
+                    } else {
+                        exception = null;
                     }
-                } else {
+                } catch (InvocationTargetException ite) {
+                    exception = null;
+                } catch (IllegalAccessException iae) {
+                    exception = null;
+                } catch (NoSuchMethodException nsme) {
                     exception = null;
                 }
-            } catch (InvocationTargetException ite) {
-                exception = null;
-            } catch (IllegalAccessException iae) {
-                exception = null;
-            } catch (NoSuchMethodException nsme) {
-                exception = null;
             }
+        } finally {
+            // ensure output is written
+            s.flush();
         }
-        // insure output is written
-        s.flush();
     }
 }
--- a/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java	Thu Jul 02 16:07:57 2015 -0700
@@ -28,7 +28,6 @@
 import java.io.File;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java	Thu Jul 02 16:07:57 2015 -0700
@@ -41,13 +41,10 @@
 
     ClassLoader getContextClassLoader() {
         return
-        AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+        AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public ClassLoader run() {
-                ClassLoader cl = null;
-                //try {
-                cl = Thread.currentThread().getContextClassLoader();
-                //} catch (SecurityException ex) { }
+                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                 if (cl == null)
                     cl = ClassLoader.getSystemClassLoader();
                 return cl;
@@ -56,7 +53,7 @@
     }
 
     String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
                 @Override
                 public String run() {
                     return System.getProperty(propName);
@@ -69,7 +66,7 @@
     {
         try {
             return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<FileInputStream>() {
+                new PrivilegedExceptionAction<>() {
                     @Override
                     public FileInputStream run() throws FileNotFoundException {
                         return new FileInputStream(file);
@@ -82,7 +79,7 @@
 
     // Used for debugging purposes
     String getClassSource(Class<?> cls) {
-        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public String run() {
                 CodeSource cs = cls.getProtectionDomain().getCodeSource();
@@ -97,7 +94,7 @@
     }
 
     boolean doesFileExist(final File f) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public Boolean run() {
                 return f.exists();
--- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java	Thu Jul 02 16:07:57 2015 -0700
@@ -40,7 +40,7 @@
 
 
     ClassLoader getContextClassLoader() {
-        return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public ClassLoader run() {
                 ClassLoader cl = null;
@@ -53,7 +53,7 @@
     }
 
     String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public String run() {
                 return System.getProperty(propName);
@@ -66,7 +66,7 @@
     {
         try {
             return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<FileInputStream>() {
+                new PrivilegedExceptionAction<>() {
                     @Override
                     public FileInputStream run() throws FileNotFoundException {
                         return new FileInputStream(file);
@@ -79,7 +79,7 @@
 
     // Used for debugging purposes
     String getClassSource(Class<?> cls) {
-        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public String run() {
                 CodeSource cs = cls.getProtectionDomain().getCodeSource();
@@ -94,7 +94,7 @@
     }
 
     boolean doesFileExist(final File f) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
             @Override
             public Boolean run() {
                 return f.exists();
--- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Thu Jul 02 16:07:57 2015 -0700
@@ -28,7 +28,6 @@
 import java.io.File;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Thu Jul 02 08:54:00 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Thu Jul 02 16:07:57 2015 -0700
@@ -333,59 +333,36 @@
     }
 
     /**
-     * A simple JRE (Java Runtime Environment) 1.1 test
-     *
-     * @return <code>true</code> if JRE 1.1
-     */
-    private static boolean isJRE11() {
-        try {
-            Class c = Class.forName("java.security.AccessController");
-            // java.security.AccessController existed since 1.2 so, if no
-            // exception was thrown, the DOM application is running in a JRE
-            // 1.2 or higher
-            return false;
-        } catch (Exception ex) {
-            // ignore
-        }
-        return true;
-    }
-
-    /**
-     * This method returns the ContextClassLoader or <code>null</code> if
-     * running in a JRE 1.1
+     * This method returns the ContextClassLoader.
      *
      * @return The Context Classloader
      */
     private static ClassLoader getContextClassLoader() {
-        return isJRE11()
-            ? null
-            : (ClassLoader)
-              AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        ClassLoader classLoader = null;
-                        try {
-                            classLoader =
-                                Thread.currentThread().getContextClassLoader();
-                        } catch (SecurityException ex) {
-                        }
-                        return classLoader;
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public ClassLoader run() {
+                    ClassLoader classLoader = null;
+                    try {
+                        classLoader =
+                            Thread.currentThread().getContextClassLoader();
+                    } catch (SecurityException ex) {
                     }
-                });
+                    return classLoader;
+                }
+            });
     }
 
     /**
      * This method returns the system property indicated by the specified name
-     * after checking access control privileges. For a JRE 1.1, this check is
-     * not done.
+     * after checking access control privileges.
      *
      * @param name the name of the system property
      * @return the system property
      */
     private static String getSystemProperty(final String name) {
-        return isJRE11()
-            ? (String) System.getProperty(name)
-            : (String) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                    @Override
+                    public String run() {
                         return System.getProperty(name);
                     }
                 });
@@ -394,7 +371,7 @@
     /**
      * This method returns an Inputstream for the reading resource
      * META_INF/services/org.w3c.dom.DOMImplementationSourceList after checking
-     * access control privileges. For a JRE 1.1, this check is not done.
+     * access control privileges.
      *
      * @param classLoader classLoader
      * @param name the resource
@@ -402,28 +379,18 @@
      */
     private static InputStream getResourceAsStream(final ClassLoader classLoader,
                                                    final String name) {
-        if (isJRE11()) {
-            InputStream ris;
-            if (classLoader == null) {
-                ris = ClassLoader.getSystemResourceAsStream(name);
-            } else {
-                ris = classLoader.getResourceAsStream(name);
-            }
-            return ris;
-        } else {
-            return (InputStream)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                        public Object run() {
-                            InputStream ris;
-                            if (classLoader == null) {
-                                ris =
-                                    ClassLoader.getSystemResourceAsStream(name);
-                            } else {
-                                ris = classLoader.getResourceAsStream(name);
-                            }
-                            return ris;
-                        }
-                    });
-        }
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public InputStream run() {
+                    InputStream ris;
+                    if (classLoader == null) {
+                        ris =
+                            ClassLoader.getSystemResourceAsStream(name);
+                    } else {
+                        ris = classLoader.getResourceAsStream(name);
+                    }
+                    return ris;
+                }
+            });
     }
 }