# HG changeset patch # User lana # Date 1471556036 0 # Node ID 81c849024b6b6080fd63f6354ce536b26a53846b # Parent 39eafa2fc0730fb6c8b9fffaddf458893e83067d# Parent 7071a8494a74e5d15238fd4a429a6da2f073cd9b Merge diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AbortException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AbortException.java Thu Aug 18 21:33:56 2016 +0000 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 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 com.sun.org.apache.xerces.internal.dom; + +public class AbortException extends RuntimeException { + + private static final long serialVersionUID = 2608302175475740417L; + + /** + * Constructor AbortException + */ + public AbortException() { super(null, null, false, false); } +} diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java Thu Aug 18 21:01:22 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java Thu Aug 18 21:33:56 2016 +0000 @@ -26,6 +26,7 @@ import java.io.StringReader; import java.util.Vector; +import com.sun.org.apache.xerces.internal.dom.AbortException; import com.sun.org.apache.xerces.internal.impl.Constants; import com.sun.org.apache.xerces.internal.impl.RevalidationHandler; import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar; @@ -157,11 +158,6 @@ // attribute value normalization final XMLString fNormalizedValue = new XMLString(new char[16], 0, 0); - /** - * If the user stops the process, this exception will be thrown. - */ - public static final RuntimeException abort = new RuntimeException(); - //DTD validator private XMLDTDValidator fDTDValidator; @@ -242,11 +238,8 @@ XMLGrammarDescription.XML_SCHEMA, fValidationHandler); fValidationHandler = null; } - } - catch (RuntimeException e) { - if( e==abort ) - return; // processing aborted by the user - throw e; // otherwise re-throw. + } catch (AbortException e) { + return; } } @@ -1371,10 +1364,10 @@ error.fRelatedData = locator.fRelatedNode; if(!errorHandler.handleError(error)) - throw abort; + throw new AbortException(); } if( severity==DOMError.SEVERITY_FATAL_ERROR ) - throw abort; + throw new AbortException(); } protected final void updateQName (Node node, QName qname){ @@ -2043,5 +2036,4 @@ return null; } - } // DOMNormalizer class diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java Thu Aug 18 21:01:22 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java Thu Aug 18 21:33:56 2016 +0000 @@ -28,6 +28,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; +import com.sun.org.apache.xerces.internal.dom.AbortException; import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl; import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl; import com.sun.org.apache.xerces.internal.dom.DOMLocatorImpl; @@ -501,11 +502,9 @@ } catch (LSException lse) { // Rethrow LSException. throw lse; + } catch (AbortException e) { + return null; } catch (RuntimeException e) { - if (e == DOMNormalizer.abort) { - // stopped at user request - return null; - } throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace(); } catch (IOException ioe) { // REVISIT: A generic IOException doesn't provide enough information @@ -733,11 +732,9 @@ } catch (LSException lse) { // Rethrow LSException. throw lse; + } catch (AbortException e) { + return false; } catch (RuntimeException e) { - if (e == DOMNormalizer.abort) { - // stopped at user request - return false; - } throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace(); } catch (Exception e) { if (ser.fDOMErrorHandler != null) { @@ -833,11 +830,9 @@ } catch (LSException lse) { // Rethrow LSException. throw lse; + } catch (AbortException e) { + return false; } catch (RuntimeException e) { - if (e == DOMNormalizer.abort) { - // stopped at user request - return false; - } throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace(); } catch (Exception e) { if (ser.fDOMErrorHandler != null) { diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/XPathImplUtil.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/XPathImplUtil.java Thu Aug 18 21:01:22 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/XPathImplUtil.java Thu Aug 18 21:33:56 2016 +0000 @@ -28,6 +28,7 @@ import com.sun.org.apache.xalan.internal.res.XSLMessages; import com.sun.org.apache.xalan.internal.utils.FactoryImpl; import com.sun.org.apache.xml.internal.dtm.DTM; +import com.sun.org.apache.xpath.internal.axes.LocPathIterator; import com.sun.org.apache.xpath.internal.objects.XObject; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; import java.io.IOException; @@ -73,6 +74,12 @@ XObject eval(Object contextItem, com.sun.org.apache.xpath.internal.XPath xpath) throws javax.xml.transform.TransformerException { com.sun.org.apache.xpath.internal.XPathContext xpathSupport; + if (contextItem == null && xpath.getExpression() instanceof LocPathIterator) { + // the operation must have no dependency on the context that is null + throw new TransformerException(XSLMessages.createXPATHMessage( + XPATHErrorResources.ER_CONTEXT_CAN_NOT_BE_NULL, + new Object[] {})); + } if (functionResolver != null) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing, featureManager); diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java Thu Aug 18 21:01:22 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java Thu Aug 18 21:33:56 2016 +0000 @@ -93,6 +93,7 @@ public static final String ER_CURRENT_TAKES_NO_ARGS = "ER_CURRENT_TAKES_NO_ARGS"; public static final String ER_DOCUMENT_REPLACED = "ER_DOCUMENT_REPLACED"; + public static final String ER_CONTEXT_CAN_NOT_BE_NULL = "ER_CONTEXT_CAN_NOT_BE_NULL"; public static final String ER_CONTEXT_HAS_NO_OWNERDOC = "ER_CONTEXT_HAS_NO_OWNERDOC"; public static final String ER_LOCALNAME_HAS_TOO_MANY_ARGS = @@ -368,6 +369,9 @@ { ER_DOCUMENT_REPLACED, "document() function implementation has been replaced by com.sun.org.apache.xalan.internal.xslt.FuncDocument!"}, + { ER_CONTEXT_CAN_NOT_BE_NULL, + "The context can not be null when the operation is context-dependent."}, + { ER_CONTEXT_HAS_NO_OWNERDOC, "context does not have an owner document!"}, diff -r 39eafa2fc073 -r 81c849024b6b jaxp/src/java.xml/share/classes/javax/xml/xpath/XPath.java --- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPath.java Thu Aug 18 21:01:22 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPath.java Thu Aug 18 21:33:56 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -34,18 +34,20 @@ * * *