6738894: Merge jaxp fixes from 6 update train into OpenJDK 6 and 7

6573268: Four JCK-devtools-6a tests report OOM: Java Heap space since JDK7 b14

Reviewed-by: darcy
This commit is contained in:
Tim Bell 2009-04-20 22:50:16 -07:00
parent 38930ae468
commit 1633b4781d
23 changed files with 211 additions and 83 deletions

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: Import.java,v 1.2.4.1 2005/09/12 10:32:33 pvedula Exp $
* $Id: Import.java,v 1.8 2007/04/09 21:30:40 joehw Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.compiler;

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: Include.java,v 1.2.4.1 2005/09/01 15:44:18 pvedula Exp $
* $Id: Include.java,v 1.8 2007/04/09 21:30:41 joehw Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.compiler;

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: Type.java,v 1.2.4.2 2005/09/15 18:34:13 jeffsuttor Exp $
* $Id: Type.java,v 1.8 2007/03/28 16:51:19 joehw Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.compiler.util;

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: SAX2DOM.java,v 1.7 2006/01/26 07:01:40 jeffsuttor Exp $
* $Id: SAX2DOM.java,v 1.8.2.1 2006/12/04 18:45:41 spericas Exp $
*/
@ -68,7 +68,7 @@ public class SAX2DOM implements ContentHandler, LexicalHandler, Constants {
static final DocumentBuilderFactory _factory =
DocumentBuilderFactory.newInstance();
public SAX2DOM() throws ParserConfigurationException {
public SAX2DOM() throws ParserConfigurationException {
synchronized (SAX2DOM.class) {
_document = _factory.newDocumentBuilder().newDocument();
}

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: TemplatesImpl.java,v 1.2.4.1 2005/09/06 12:19:26 pvedula Exp $
* $Id: TemplatesImpl.java,v 1.8 2007/03/26 20:12:27 spericas Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.trax;

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: TransformerFactoryImpl.java,v 1.2.4.1 2005/09/15 06:15:38 pvedula Exp $
* $Id: TransformerFactoryImpl.java,v 1.8 2007/04/09 21:30:41 joehw Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.trax;

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: TransformerImpl.java,v 1.5 2005/09/28 13:48:46 pvedula Exp $
* $Id: TransformerImpl.java,v 1.10 2007/06/13 01:57:09 joehw Exp $
*/
package com.sun.org.apache.xalan.internal.xsltc.trax;

View file

@ -148,7 +148,6 @@ public class EntityImpl
* @exception DOMException
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public void setPrefix(String prefix)
throws DOMException
{

View file

@ -45,8 +45,8 @@ import com.sun.xml.internal.stream.StaxEntityResolverWrapper;
public class PropertyManager {
protected static final String STAX_NOTATIONS = "javax.xml.stream.notations";
protected static final String STAX_ENTITIES = "javax.xml.stream.entities";
public static final String STAX_NOTATIONS = "javax.xml.stream.notations";
public static final String STAX_ENTITIES = "javax.xml.stream.entities";
private static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning";

View file

@ -289,6 +289,8 @@ public class XMLDocumentFragmentScannerImpl
protected boolean fReportCdataEvent = false ;
protected boolean fIsCoalesce = false ;
protected String fDeclaredEncoding = null;
/** Disallow doctype declaration. */
protected boolean fDisallowDoctype = false;
// drivers
@ -1852,6 +1854,11 @@ public class XMLDocumentFragmentScannerImpl
}
// start general entity
if (!fEntityStore.isDeclaredEntity(name)) {
//SUPPORT_DTD=false && ReplaceEntityReferences should throw exception
if (fDisallowDoctype && fReplaceEntityReferences) {
reportFatalError("EntityNotDeclared", new Object[]{name});
return;
}
//REVISIT: one more case needs to be included: external PE and standalone is no
if ( fHasExternalDTD && !fStandalone) {
if (fValidation)

View file

@ -62,6 +62,10 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
* @author Arnaud Le Hors, IBM
* @author Eric Ye, IBM
* @author Sunitha Reddy, Sun Microsystems
*
* Refer to the table in unit-test javax.xml.stream.XMLStreamReaderTest.SupportDTD for changes
* related to property SupportDTD.
* @author Joe Wang, Sun Microsystems
*/
public class XMLDocumentScannerImpl
extends XMLDocumentFragmentScannerImpl{
@ -185,9 +189,6 @@ public class XMLDocumentScannerImpl
/** Load external DTD. */
protected boolean fLoadExternalDTD = true;
/** Disallow doctype declaration. */
protected boolean fDisallowDoctype = false;
// state
/** Seen doctype declaration. */
@ -227,8 +228,8 @@ public class XMLDocumentScannerImpl
/** String. */
private XMLString fString = new XMLString();
public static final char [] DOCTYPE = {'D','O','C','T','Y','P','E'};
public static final char [] COMMENTSTRING = {'-','-'};
private static final char [] DOCTYPE = {'D','O','C','T','Y','P','E'};
private static final char [] COMMENTSTRING = {'-','-'};
//
// Constructors
@ -708,6 +709,12 @@ public class XMLDocumentScannerImpl
//
// Private methods
//
/** Set the scanner state after scanning DTD */
protected void setEndDTDScanState() {
setScannerState(SCANNER_STATE_PROLOG);
setDriver(fPrologDriver);
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
}
/** Returns the scanner state name. */
protected String getScannerStateName(int state) {
@ -930,19 +937,20 @@ public class XMLDocumentScannerImpl
reportFatalError("AlreadySeenDoctype", null);
}
fSeenDoctypeDecl = true;
if(fDTDDriver == null){
fDTDDriver = new DTDDriver();
}
// scanDoctypeDecl() sends XNI doctypeDecl event that
// in SAX is converted to startDTD() event.
if (scanDoctypeDecl(fDisallowDoctype)) {
//allow parsing of entity decls to continue in order to stay well-formed
setScannerState(SCANNER_STATE_DTD_INTERNAL_DECLS);
fSeenInternalSubset = true;
if(fDTDDriver == null){
fDTDDriver = new DTDDriver();
}
setDriver(fContentDriver);
int dtdEvent = fDTDDriver.next();
//always return DTD event, the event however, will not contain any entities
return fDTDDriver.next();
// If no DTD support, ignore and continue parsing
return fDisallowDoctype ? next() : dtdEvent;
//return fDisallowDoctype ? next() : dtdEvent;
}
/** xxx:check this part again
@ -955,17 +963,17 @@ public class XMLDocumentScannerImpl
}
*/
if (fDisallowDoctype) {
setScannerState(SCANNER_STATE_PROLOG);
return next();
}
// handle external subset
if (fDoctypeSystemId != null) {
if (((fValidation || fLoadExternalDTD)
&& (fValidationManager == null || !fValidationManager.isCachedDTD()))) {
setScannerState(SCANNER_STATE_DTD_EXTERNAL);
if (!fDisallowDoctype)
setScannerState(SCANNER_STATE_DTD_EXTERNAL);
else
setScannerState(SCANNER_STATE_PROLOG);
setDriver(fContentDriver);
if(fDTDDriver == null)
fDTDDriver = new DTDDriver();
return fDTDDriver.next();
}
@ -976,8 +984,13 @@ public class XMLDocumentScannerImpl
// This handles the case of a DOCTYPE that had neither an internal subset or an external subset.
fDTDScanner.setInputSource(fExternalSubsetSource);
fExternalSubsetSource = null;
setScannerState(SCANNER_STATE_DTD_EXTERNAL_DECLS);
if (!fDisallowDoctype)
setScannerState(SCANNER_STATE_DTD_EXTERNAL_DECLS);
else
setScannerState(SCANNER_STATE_PROLOG);
setDriver(fContentDriver);
if(fDTDDriver == null)
fDTDDriver = new DTDDriver();
return fDTDDriver.next();
}
}
@ -1117,19 +1130,21 @@ public class XMLDocumentScannerImpl
}
fMarkupDepth--;
// scan external subset next
if (!XMLDocumentScannerImpl.this.fDisallowDoctype &&
fDoctypeSystemId != null && (fValidation || fLoadExternalDTD)) {
setScannerState(SCANNER_STATE_DTD_EXTERNAL);
if (fDisallowDoctype) {
//simply reset the entity store without having to mess around
//with the DTD Scanner code
fEntityStore = fEntityManager.getEntityStore();
fEntityStore.reset();
} else {
// scan external subset next unless we are ignoring DTDs
if (fDoctypeSystemId != null && (fValidation || fLoadExternalDTD)) {
setScannerState(SCANNER_STATE_DTD_EXTERNAL);
break;
}
}
// break out of here
else {
setScannerState(SCANNER_STATE_PROLOG);
setDriver(fPrologDriver);
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
return true;
}
setEndDTDScanState();
return true;
}
break;
}
@ -1160,13 +1175,16 @@ public class XMLDocumentScannerImpl
boolean completeDTD = true;
boolean moreToScan = fDTDScanner.scanDTDExternalSubset(completeDTD);
if (!moreToScan) {
setScannerState(SCANNER_STATE_PROLOG);
setDriver(fPrologDriver);
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
setEndDTDScanState();
return true;
}
break;
}
case SCANNER_STATE_PROLOG : {
// skip entity decls
setEndDTDScanState();
return true;
}
default: {
throw new XNIException("DTDDriver#dispatch: scanner state="+fScannerState+" ("+getScannerStateName(fScannerState)+')');
}

View file

@ -56,7 +56,6 @@ public class XMLStreamFilterImpl implements javax.xml.stream.XMLStreamReader {
* hasNext() to advance the underlining stream in order to find the next acceptable event
*/
private boolean fStreamAdvancedByHasNext = false;
/** Creates a new instance of XMLStreamFilterImpl */
public XMLStreamFilterImpl(XMLStreamReader reader,StreamFilter filter){
@ -436,7 +435,6 @@ public class XMLStreamFilterImpl implements javax.xml.stream.XMLStreamReader {
*/
public String getVersion() {
return fStreamReader.getVersion();
}
/**
@ -532,5 +530,4 @@ public class XMLStreamFilterImpl implements javax.xml.stream.XMLStreamReader {
public String getAttributeLocalName(int index){
return fStreamReader.getAttributeLocalName(index);
}
}

View file

@ -34,4 +34,3 @@ XPointerResolutionUnsuccessful = XPointer resolution unsuccessful.
# Messages from erroneous set-up
IncompatibleNamespaceContext = The type of the NamespaceContext is incompatible with using XInclude; it must be an instance of XIncludeNamespaceSupport
ExpandedSystemId = Could not expand system id of included resource
null

View file

@ -1214,19 +1214,29 @@ public class XSAttributeChecker {
int max = ((XInt)attrValues[ATTIDX_MAXOCCURS]).intValue();
if (max != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
// The maxOccurs restriction no longer applies to elements
// and wildcards. These are now validated using a constant
// space algorithm. The restriction still applies to model
// groups such as xs:sequence.
// maxOccurLimit is only check in secure mode
if (fSchemaHandler.fSecureProcessing != null) {
String localName = element.getLocalName();
String localName = element.getLocalName();
if (fSchemaHandler.fSecureProcessing != null &&
!localName.equals("element") && !localName.equals("any")) {
// The maxOccurs restriction no longer applies to elements
// and wildcards in a sequence in which they are the only
// particle. These are now validated using a constant
// space algorithm. The restriction still applies to all
// other cases.
// Determine if constant-space algorithm can be applied
final boolean optimize =
(localName.equals("element") || localName.equals("any")) &&
(element.getNextSibling() == null) &&
(element.getPreviousSibling() == null) &&
(element.getParentNode().getLocalName().equals("sequence"));
if (!optimize) {
//Revisit :: IMO this is not right place to check
// maxOccurNodeLimit.
int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getMaxOccurNodeLimit();
if (max > maxOccurNodeLimit) {
reportSchemaError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
// reset max values in case processing continues on error
attrValues[ATTIDX_MAXOCCURS] = fXIntPool.getXInt(maxOccurNodeLimit);
@ -1234,6 +1244,7 @@ public class XSAttributeChecker {
max = maxOccurNodeLimit;
}
}
}
if (min > max) {
reportSchemaError ("p-props-correct.2.1",
@ -1607,6 +1618,10 @@ public class XSAttributeChecker {
return retValue;
}
void reportSchemaFatalError (String key, Object[] args, Element ele) {
fSchemaHandler.reportSchemaFatalError(key, args, ele);
}
void reportSchemaError (String key, Object[] args, Element ele) {
fSchemaHandler.reportSchemaError(key, args, ele);
}

View file

@ -2523,25 +2523,26 @@ public class XSDHandler {
return false;
}
void reportSchemaFatalError(String key, Object[] args, Element ele) {
reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
void reportSchemaError(String key, Object[] args, Element ele) {
if (element2Locator(ele, xl)) {
fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
key, args, XMLErrorReporter.SEVERITY_ERROR);
}
else {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
key, args, XMLErrorReporter.SEVERITY_ERROR);
}
reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR);
}
void reportSchemaWarning(String key, Object[] args, Element ele) {
reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING);
}
void reportSchemaErr(String key, Object[] args, Element ele, short type) {
if (element2Locator(ele, xl)) {
fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
key, args, XMLErrorReporter.SEVERITY_WARNING);
key, args, type);
}
else {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
key, args, XMLErrorReporter.SEVERITY_WARNING);
key, args, type);
}
}

View file

@ -111,6 +111,10 @@ public final class XMLSchemaFactory extends SchemaFactory {
fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper);
fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
// Enable secure processing feature by default
fSecurityManager = new SecurityManager();
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
}
/**

View file

@ -943,8 +943,7 @@ public class XIncludeHandler
setState(STATE_IGNORE);
}
else {
reportFatalError("NoFallback",
new Object[] { attributes.getValue(null, "href") });
reportFatalError("NoFallback");
}
}
else if (isFallbackElement(element)) {
@ -1002,8 +1001,7 @@ public class XIncludeHandler
// we check to see if the children of this include element contained a fallback
if (getState() == STATE_EXPECT_FALLBACK
&& !getSawFallback(fDepth + 1)) {
reportFatalError("NoFallback",
new Object[] { "unknown" });
reportFatalError("NoFallback");
}
}
if (isFallbackElement(element)) {

View file

@ -53,7 +53,35 @@ public class ThreadControllerWrapper
{
/**
* Will get a thread from the pool, execute the task
* This class was introduced as a fix for CR 6607339.
*/
final class SafeThread extends Thread {
private volatile boolean ran = false;
public SafeThread(Runnable target) {
super(target);
}
public final void run() {
if (Thread.currentThread() != this) {
throw new IllegalStateException("The run() method in a"
+ " SafeThread cannot be called from another thread.");
}
synchronized (this) {
if (!ran) {
ran = true;
}
else {
throw new IllegalStateException("The run() method in a"
+ " SafeThread cannot be called more than once.");
}
}
super.run();
}
}
/**
* Will get a thread from the pool, execute the task
* and return the thread to the pool.
*
* The return value is used only to wait for completion
@ -68,7 +96,7 @@ public class ThreadControllerWrapper
public Thread run(Runnable task, int priority)
{
Thread t = new Thread(task);
Thread t = new SafeThread(task);
t.start();

View file

@ -18,7 +18,7 @@
* limitations under the License.
*/
/*
* $Id: NodeSequence.java,v 1.2.4.2 2005/09/14 19:45:19 jeffsuttor Exp $
* $Id: NodeSequence.java,v 1.6 2007/01/12 19:26:42 spericas Exp $
*/
package com.sun.org.apache.xpath.internal.axes;

View file

@ -25,6 +25,8 @@
package com.sun.xml.internal.stream.events;
import com.sun.org.apache.xerces.internal.impl.PropertyManager;
import java.util.List;
import javax.xml.stream.util.XMLEventAllocator;
import javax.xml.stream.*;
import javax.xml.stream.events.*;
@ -144,7 +146,13 @@ public class XMLEventAllocatorImpl implements XMLEventAllocator {
break;
}
case XMLEvent.DTD:{
event = new DTDEvent(streamReader.getText());
DTDEvent dtdEvent = new DTDEvent(streamReader.getText());
dtdEvent.setLocation(streamReader.getLocation());
List entities = (List)streamReader.getProperty(PropertyManager.STAX_ENTITIES);
if (entities != null && entities.size() != 0) dtdEvent.setEntities(entities);
List notations = (List)streamReader.getProperty(PropertyManager.STAX_NOTATIONS);
if (notations != null && notations.size() != 0) dtdEvent.setNotations(notations);
event = dtdEvent;
break;
}
case XMLEvent.CDATA:{