# HG changeset patch # User andrew # Date 1317228865 -3600 # Node ID eece170ba62e06d1379578d722d4b2e29c1aeea1 # Parent b68688478d61d1ae00440ffb9849092f6015441d 7040147: jaxp 1.4.5 jdk7 integration diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/bcel/internal/classfile/Utility.java --- a/sources/jaxp_src/src/com/sun/org/apache/bcel/internal/classfile/Utility.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/bcel/internal/classfile/Utility.java Wed Sep 28 17:54:25 2011 +0100 @@ -431,7 +431,7 @@ default: // Never reached System.err.println("Unreachable default case reached!"); - System.exit(-1); + buf.setLength(0); } } } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/bcel/internal/generic/ArrayType.java --- a/sources/jaxp_src/src/com/sun/org/apache/bcel/internal/generic/ArrayType.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/bcel/internal/generic/ArrayType.java Wed Sep 28 17:54:25 2011 +0100 @@ -145,7 +145,7 @@ /** @return a hash code value for the object. */ - public int hashcode() { return basic_type.hashCode() ^ dimensions; } + public int hashCode() { return basic_type.hashCode() ^ dimensions; } /** @return true if both type objects refer to the same array type. */ diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Wed Sep 28 17:54:25 2011 +0100 @@ -68,7 +68,7 @@ // protected /** Chunk shift. */ - protected static final int CHUNK_SHIFT = 11; // 2^11 = 2k + protected static final int CHUNK_SHIFT = 8; // 2^8 = 256 /** Chunk size. */ protected static final int CHUNK_SIZE = (1 << CHUNK_SHIFT); @@ -77,7 +77,7 @@ protected static final int CHUNK_MASK = CHUNK_SIZE - 1; /** Initial chunk size. */ - protected static final int INITIAL_CHUNK_COUNT = (1 << (16 - CHUNK_SHIFT)); // 2^16 = 64k + protected static final int INITIAL_CHUNK_COUNT = (1 << (13 - CHUNK_SHIFT)); // 32 // // Data @@ -132,7 +132,7 @@ // // private data // - private transient final StringBuffer fBufferStr = new StringBuffer(); + private transient final StringBuilder fBufferStr = new StringBuilder(); private transient final ArrayList fStrChunks = new ArrayList(); // diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java Wed Sep 28 17:54:25 2011 +0100 @@ -60,7 +60,7 @@ * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. * - * @version $Id: XSSimpleTypeDecl.java,v 1.11 2010-11-01 04:39:47 joehw Exp $ + * @version $Id: XSSimpleTypeDecl.java 3029 2011-04-24 17:50:18Z joehw $ */ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo { diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java Wed Sep 28 17:54:25 2011 +0100 @@ -24,8 +24,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; import com.sun.org.apache.xerces.internal.xni.NamespaceContext; -import java.util.Hashtable; -import java.util.Enumeration; +import java.util.ArrayList; import java.util.Locale; /** @@ -35,7 +34,7 @@ * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: ValidationState.java,v 1.6 2010/07/23 02:09:27 joehw Exp $ + * @version $Id: ValidationState.java,v 1.7 2010-11-01 04:39:53 joehw Exp $ */ public class ValidationState implements ValidationContext { @@ -52,10 +51,8 @@ private SymbolTable fSymbolTable = null; private Locale fLocale = null; - //REVISIT: Should replace with a lighter structure. - private final Hashtable fIdTable = new Hashtable(); - private final Hashtable fIdRefTable = new Hashtable(); - private final static Object fNullValue = new Object(); + private ArrayList fIdList; + private ArrayList fIdRefList; // // public methods @@ -93,13 +90,19 @@ * otherwise return the first IDREF value without a matching ID value. */ public String checkIDRefID () { - Enumeration en = fIdRefTable.keys(); + if (fIdList == null) { + if (fIdRefList != null) { + return fIdRefList.get(0); + } + } - String key; - while (en.hasMoreElements()) { - key = (String)en.nextElement(); - if (!fIdTable.containsKey(key)) { - return key; + if (fIdRefList != null) { + String key; + for (int i = 0; i < fIdRefList.size(); i++) { + key = fIdRefList.get(i); + if (!fIdList.contains(key)) { + return key; + } } } return null; @@ -109,8 +112,8 @@ fExtraChecking = true; fFacetChecking = true; fNamespaces = true; - fIdTable.clear(); - fIdRefTable.clear(); + fIdList = null; + fIdRefList = null; fEntityState = null; fNamespaceContext = null; fSymbolTable = null; @@ -123,8 +126,8 @@ * the two tables. */ public void resetIDTables() { - fIdTable.clear(); - fIdRefTable.clear(); + fIdList = null; + fIdRefList = null; } // @@ -165,15 +168,18 @@ // id public boolean isIdDeclared(String name) { - return fIdTable.containsKey(name); + if (fIdList == null) return false; + return fIdList.contains(name); } public void addId(String name) { - fIdTable.put(name, fNullValue); + if (fIdList == null) fIdList = new ArrayList(); + fIdList.add(name); } // idref public void addIdRef(String name) { - fIdRefTable.put(name, fNullValue); + if (fIdRefList == null) fIdRefList = new ArrayList(); + fIdRefList.add(name); } // get symbols diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java Wed Sep 28 17:54:25 2011 +0100 @@ -69,6 +69,8 @@ import com.sun.org.apache.xerces.internal.xs.StringList; import com.sun.org.apache.xerces.internal.xs.XSLoader; import com.sun.org.apache.xerces.internal.xs.XSModel; +import java.util.HashMap; +import java.util.Map; import org.w3c.dom.DOMConfiguration; import org.w3c.dom.DOMError; import org.w3c.dom.DOMErrorHandler; @@ -256,7 +258,7 @@ private CMBuilder fCMBuilder; private XSDDescription fXSDDescription = new XSDDescription(); - private Hashtable fJAXPCache; + private Map fJAXPCache; private Locale fLocale = Locale.getDefault(); // XSLoader attributes @@ -340,8 +342,10 @@ } fCMBuilder = builder; fSchemaHandler = new XSDHandler(fGrammarBucket); - fDeclPool = new XSDeclarationPool(); - fJAXPCache = new Hashtable(); + if (fDeclPool != null) { + fDeclPool.reset(); + } + fJAXPCache = new HashMap(); fSettingsChanged = true; } @@ -539,7 +543,7 @@ desc.setBaseSystemId(source.getBaseSystemId()); desc.setLiteralSystemId( source.getSystemId()); // none of the other fields make sense for preparsing - Hashtable locationPairs = new Hashtable(); + Map locationPairs = new HashMap(); // Process external schema location properties. // We don't call tokenizeSchemaLocationStr here, because we also want // to check whether the values are valid URI. @@ -571,7 +575,7 @@ */ SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source, - Hashtable locationPairs) throws IOException, XNIException { + Map locationPairs) throws IOException, XNIException { // this should only be done once per invocation of this object; // unless application alters JAXPSource in the mean time. @@ -595,7 +599,7 @@ * @return * @throws IOException */ - public static XMLInputSource resolveDocument(XSDDescription desc, Hashtable locationPairs, + public static XMLInputSource resolveDocument(XSDDescription desc, Map locationPairs, XMLEntityResolver entityResolver) throws IOException { String loc = null; // we consider the schema location properties for import @@ -626,7 +630,7 @@ // add external schema locations to the location pairs public static void processExternalHints(String sl, String nsl, - Hashtable locations, + Map locations, XMLErrorReporter er) { if (sl != null) { try { @@ -677,9 +681,9 @@ // otherwise, true is returned. In either case, locations // is augmented to include as many tokens as possible. // @param schemaStr The schemaLocation string to tokenize - // @param locations Hashtable mapping namespaces to LocationArray objects holding lists of locaitons + // @param locations HashMap mapping namespaces to LocationArray objects holding lists of locaitons // @return true if no problems; false if string could not be tokenized - public static boolean tokenizeSchemaLocationStr(String schemaStr, Hashtable locations) { + public static boolean tokenizeSchemaLocationStr(String schemaStr, Map locations) { if (schemaStr!= null) { StringTokenizer t = new StringTokenizer(schemaStr, " \n\t\r"); String namespace, location; @@ -698,7 +702,7 @@ } } return true; - } // tokenizeSchemaLocation(String, Hashtable): boolean + } // tokenizeSchemaLocation(String, HashMap): boolean /** * Translate the various JAXP SchemaSource property types to XNI @@ -710,7 +714,7 @@ * Note: all JAXP schema files will be checked for full-schema validity if the feature was set up * */ - private void processJAXPSchemaSource(Hashtable locationPairs) throws IOException { + private void processJAXPSchemaSource(Map locationPairs) throws IOException { fJAXPProcessed = true; if (fJAXPSource == null) { return; @@ -975,20 +979,21 @@ // Determine schema dv factory to use SchemaDVFactory dvFactory = null; - try { - dvFactory = (SchemaDVFactory)componentManager.getProperty(SCHEMA_DV_FACTORY); - } catch (XMLConfigurationException e) { - } + dvFactory = fSchemaHandler.getDVFactory(); if (dvFactory == null) { dvFactory = SchemaDVFactory.getInstance(); + fSchemaHandler.setDVFactory(dvFactory); } - fSchemaHandler.setDVFactory(dvFactory); - boolean psvi = componentManager.getFeature(AUGMENT_PSVI, false); if (!psvi) { - fDeclPool.reset(); + if (fDeclPool != null) { + fDeclPool.reset(); + } + else { + fDeclPool = new XSDeclarationPool(); + } fCMBuilder.setDeclPool(fDeclPool); fSchemaHandler.setDeclPool(fDeclPool); if (dvFactory instanceof SchemaDVFactoryImpl) { diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java Wed Sep 28 17:54:25 2011 +0100 @@ -83,8 +83,6 @@ import com.sun.org.apache.xerces.internal.xs.XSConstants; import com.sun.org.apache.xerces.internal.xs.XSObjectList; import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; import com.sun.org.apache.xerces.internal.parsers.XMLParser; /** @@ -489,8 +487,6 @@ /** Schema Grammar Description passed, to give a chance to application to supply the Grammar */ protected final XSDDescription fXSDDescription = new XSDDescription(); protected final Hashtable fLocationPairs = new Hashtable(); - protected final Hashtable fExpandedLocationPairs = new Hashtable(); - protected final ArrayList fUnparsedLocations = new ArrayList(); // handlers @@ -1293,7 +1289,6 @@ fIdConstraint = false; //reset XSDDescription fLocationPairs.clear(); - fExpandedLocationPairs.clear(); // cleanup id table fValidationState.resetIDTables(); diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java Wed Sep 28 17:54:25 2011 +0100 @@ -160,6 +160,12 @@ } public XSCMValidator getContentModel(CMBuilder cmBuilder) { + // for complex type with empty or simple content, + // there is no content model validator + if (fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE || + fContentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) { + return null; + } if (fCMValidator == null) synchronized (this) { if (fCMValidator == null) { diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java Wed Sep 28 17:54:25 2011 +0100 @@ -21,7 +21,8 @@ package com.sun.org.apache.xerces.internal.impl.xs; import java.util.Enumeration; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; import java.util.Vector; /** @@ -39,7 +40,7 @@ /** * Hashtable that maps between Namespace and a Grammar */ - Hashtable fGrammarRegistry = new Hashtable(); + Map fGrammarRegistry = new HashMap(); SchemaGrammar fNoNSGrammar = null; /** @@ -217,10 +218,11 @@ int count = fGrammarRegistry.size() + (fNoNSGrammar==null ? 0 : 1); SchemaGrammar[] grammars = new SchemaGrammar[count]; // get grammars with target namespace - Enumeration schemas = fGrammarRegistry.elements(); int i = 0; - while (schemas.hasMoreElements()) - grammars[i++] = (SchemaGrammar)schemas.nextElement(); + for(Map.Entry entry : fGrammarRegistry.entrySet()){ + grammars[i++] = entry.getValue(); + } + // add the grammar without target namespace, if any if (fNoNSGrammar != null) grammars[count-1] = fNoNSGrammar; diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Wed Sep 28 17:54:25 2011 +0100 @@ -42,6 +42,7 @@ import com.sun.org.apache.xerces.internal.util.XMLSymbols; import com.sun.org.apache.xerces.internal.xni.QName; import com.sun.org.apache.xerces.internal.xs.XSConstants; +import java.util.HashMap; import org.w3c.dom.Attr; import org.w3c.dom.Element; @@ -145,9 +146,9 @@ // used to store the map from element name to attribute list // for 14 global elements - private static final Hashtable fEleAttrsMapG = new Hashtable(29); + private static final Map fEleAttrsMapG = new HashMap(29); // for 39 local elememnts - private static final Hashtable fEleAttrsMapL = new Hashtable(79); + private static final Map fEleAttrsMapL = new HashMap(79); // used to initialize fEleAttrsMap // step 1: all possible data types @@ -926,7 +927,7 @@ protected SymbolTable fSymbolTable = null; // used to store the mapping from processed element to attributes - protected Hashtable fNonSchemaAttrs = new Hashtable(); + protected Map fNonSchemaAttrs = new HashMap(); // temprory vector, used to hold the namespace list protected Vector fNamespaceList = new Vector(); @@ -992,7 +993,7 @@ reportSchemaError("s4s-elt-schema-ns", new Object[] {elName}, element); } - Hashtable eleAttrsMap = fEleAttrsMapG; + Map eleAttrsMap = fEleAttrsMapG; String lookupName = elName; // REVISIT: only local element and attribute are different from others. @@ -1808,9 +1809,9 @@ } class LargeContainer extends Container { - Hashtable items; + Map items; LargeContainer(int size) { - items = new Hashtable(size*2+1); + items = new HashMap(size*2+1); values = new OneAttr[size]; } void put(String key, OneAttr value) { diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java --- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Wed Sep 28 17:54:25 2011 +0100 @@ -25,7 +25,9 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; import java.util.Stack; import java.util.Vector; @@ -239,8 +241,6 @@ // //protected data that can be accessable by any traverser - // stores decl - protected Hashtable fNotationRegistry = new Hashtable(); protected XSDeclarationPool fDeclPool = null; @@ -258,62 +258,55 @@ // By asking the node for its ownerDocument and looking in // XSDocumentInfoRegistry we can easily get the corresponding // XSDocumentInfo object. - private Hashtable fUnparsedAttributeRegistry = new Hashtable(); - private Hashtable fUnparsedAttributeGroupRegistry = new Hashtable(); - private Hashtable fUnparsedElementRegistry = new Hashtable(); - private Hashtable fUnparsedGroupRegistry = new Hashtable(); - private Hashtable fUnparsedIdentityConstraintRegistry = new Hashtable(); - private Hashtable fUnparsedNotationRegistry = new Hashtable(); - private Hashtable fUnparsedTypeRegistry = new Hashtable(); + private boolean registryEmpty = true; + private Map fUnparsedAttributeRegistry = new HashMap(); + private Map fUnparsedAttributeGroupRegistry = new HashMap(); + private Map fUnparsedElementRegistry = new HashMap(); + private Map fUnparsedGroupRegistry = new HashMap(); + private Map fUnparsedIdentityConstraintRegistry = new HashMap(); + private Map fUnparsedNotationRegistry = new HashMap(); + private Map fUnparsedTypeRegistry = new HashMap(); // Compensation for the above hashtables to locate XSDocumentInfo, // Since we may take Schema Element directly, so can not get the // corresponding XSDocumentInfo object just using above hashtables. - private Hashtable fUnparsedAttributeRegistrySub = new Hashtable(); - private Hashtable fUnparsedAttributeGroupRegistrySub = new Hashtable(); - private Hashtable fUnparsedElementRegistrySub = new Hashtable(); - private Hashtable fUnparsedGroupRegistrySub = new Hashtable(); - private Hashtable fUnparsedIdentityConstraintRegistrySub = new Hashtable(); - private Hashtable fUnparsedNotationRegistrySub = new Hashtable(); - private Hashtable fUnparsedTypeRegistrySub = new Hashtable(); + private Map fUnparsedAttributeRegistrySub = new HashMap(); + private Map fUnparsedAttributeGroupRegistrySub = new HashMap(); + private Map fUnparsedElementRegistrySub = new HashMap(); + private Map fUnparsedGroupRegistrySub = new HashMap(); + private Map fUnparsedIdentityConstraintRegistrySub = new HashMap(); + private Map fUnparsedNotationRegistrySub = new HashMap(); + private Map fUnparsedTypeRegistrySub = new HashMap(); // Stores XSDocumentInfo (keyed by component name), to check for duplicate // components declared within the same xsd document - private Hashtable fUnparsedRegistriesExt[] = new Hashtable[] { + private Map fUnparsedRegistriesExt[] = new HashMap[] { null, - new Hashtable(), // ATTRIBUTE_TYPE - new Hashtable(), // ATTRIBUTEGROUP_TYPE - new Hashtable(), // ELEMENT_TYPE - new Hashtable(), // GROUP_TYPE - new Hashtable(), // IDENTITYCONSTRAINT_TYPE - new Hashtable(), // NOTATION_TYPE - new Hashtable(), // TYPEDECL_TYPE + null, // ATTRIBUTE_TYPE + null, // ATTRIBUTEGROUP_TYPE + null, // ELEMENT_TYPE + null, // GROUP_TYPE + null, // IDENTITYCONSTRAINT_TYPE + null, // NOTATION_TYPE + null, // TYPEDECL_TYPE }; - // this is keyed with a documentNode (or the schemaRoot nodes - // contained in the XSDocumentInfo objects) and its value is the - // XSDocumentInfo object corresponding to that document. - // Basically, the function of this registry is to be a link - // between the nodes we fetch from calls to the fUnparsed* - // arrays and the XSDocumentInfos they live in. - private Hashtable fXSDocumentInfoRegistry = new Hashtable(); - // this hashtable is keyed on by XSDocumentInfo objects. Its values // are Vectors containing the XSDocumentInfo objects d, // ed or d by the key XSDocumentInfo. - private Hashtable fDependencyMap = new Hashtable(); + private Map fDependencyMap = new HashMap(); // this hashtable is keyed on by a target namespace. Its values // are Vectors containing namespaces imported by schema documents // with the key target namespace. // if an imprted schema has absent namespace, the value "null" is stored. - private Hashtable fImportMap = new Hashtable(); + private Map fImportMap = new HashMap(); // all namespaces that imports other namespaces // if the importing schema has absent namespace, empty string is stored. // (because the key of a hashtable can't be null.) private Vector fAllTNSs = new Vector(); // stores instance document mappings between namespaces and schema hints - private Hashtable fLocationPairs = null; - private static final Hashtable EMPTY_TABLE = new Hashtable(); + private Map fLocationPairs = null; + private static final Map EMPTY_TABLE = new HashMap(); // Records which nodes are hidden when the input is a DOMInputSource. Hashtable fHiddenNodes = null; @@ -342,33 +335,33 @@ // schema document. This combination is used so that the user's // EntityResolver can provide a consistent way of identifying a // schema document that is included in multiple other schemas. - private Hashtable fTraversed = new Hashtable(); + private Map fTraversed = new HashMap(); // this hashtable contains a mapping from Schema Element to its systemId // this is useful to resolve a uri relative to the referring document - private Hashtable fDoc2SystemId = new Hashtable(); + private Map fDoc2SystemId = new HashMap(); // the primary XSDocumentInfo we were called to parse private XSDocumentInfo fRoot = null; // This hashtable's job is to act as a link between the Schema Element and its // XSDocumentInfo object. - private Hashtable fDoc2XSDocumentMap = new Hashtable(); + private Map fDoc2XSDocumentMap = new HashMap(); // map between elements and the XSDocumentInfo // objects that correspond to the documents being redefined. - private Hashtable fRedefine2XSDMap = new Hashtable(); + private Map fRedefine2XSDMap = null; // map between elements and the namespace support - private Hashtable fRedefine2NSSupport = new Hashtable(); + private Map fRedefine2NSSupport = null; // these objects store a mapping between the names of redefining // groups/attributeGroups and the groups/AttributeGroups which // they redefine by restriction (implicitly). It is up to the // Group and AttributeGroup traversers to check these restrictions for // validity. - private Hashtable fRedefinedRestrictedAttributeGroupRegistry = new Hashtable(); - private Hashtable fRedefinedRestrictedGroupRegistry = new Hashtable(); + private Map fRedefinedRestrictedAttributeGroupRegistry = new HashMap(); + private Map fRedefinedRestrictedGroupRegistry = new HashMap(); // a variable storing whether the last schema document // processed (by getSchema) was a duplicate. @@ -496,7 +489,7 @@ * @throws IOException */ public SchemaGrammar parseSchema(XMLInputSource is, XSDDescription desc, - Hashtable locationPairs) + Map locationPairs) throws IOException { fLocationPairs = locationPairs; fSchemaParser.resetNodePool(); @@ -1012,6 +1005,7 @@ schemaHint = (String)includeAttrs[XSAttributeChecker.ATTIDX_SCHEMALOCATION]; // store the namespace decls of the redefine element if (localName.equals(SchemaSymbols.ELT_REDEFINE)) { + if (fRedefine2NSSupport == null) fRedefine2NSSupport = new HashMap(); fRedefine2NSSupport.put(child, new SchemaNamespaceSupport(currSchemaInfo.fNamespaceSupport)); } @@ -1119,6 +1113,7 @@ newSchemaInfo != null) { // must record which schema we're redefining so that we can // rename the right things later! + if (fRedefine2XSDMap == null) fRedefine2XSDMap = new HashMap(); fRedefine2XSDMap.put(child, newSchemaInfo); } if (newSchemaRoot != null) { @@ -1208,7 +1203,7 @@ // that implicit redefinitions of groups and attributeGroups can be handled). protected void buildGlobalNameRegistries() { - + registryEmpty = false; // Starting with fRoot, we examine each child of the schema // element. Skipping all imports and includes, we record the names // of all other global components (and children of ). We @@ -1385,7 +1380,7 @@ // includes and imports will not show up here! if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_REDEFINE)) { // use the namespace decls for the redefine, instead of for the parent - currSchemaDoc.backupNSSupport((SchemaNamespaceSupport)fRedefine2NSSupport.get(globalComp)); + currSchemaDoc.backupNSSupport((fRedefine2NSSupport!=null)?(SchemaNamespaceSupport)fRedefine2NSSupport.get(globalComp):null); for (Element redefinedComp = DOMUtil.getFirstVisibleChildElement(globalComp, fHiddenNodes); redefinedComp != null; redefinedComp = DOMUtil.getNextVisibleSiblingElement(redefinedComp, fHiddenNodes)) { @@ -1698,32 +1693,32 @@ // the component is not parsed, try to find a DOM element for it switch (declType) { case ATTRIBUTE_TYPE : - decl = (Element)fUnparsedAttributeRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedAttributeRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedAttributeRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedAttributeRegistrySub, declKey); break; case ATTRIBUTEGROUP_TYPE : - decl = (Element)fUnparsedAttributeGroupRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedAttributeGroupRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedAttributeGroupRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedAttributeGroupRegistrySub, declKey); break; case ELEMENT_TYPE : - decl = (Element)fUnparsedElementRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedElementRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedElementRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedElementRegistrySub, declKey); break; case GROUP_TYPE : - decl = (Element)fUnparsedGroupRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedGroupRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedGroupRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedGroupRegistrySub, declKey); break; case IDENTITYCONSTRAINT_TYPE : - decl = (Element)fUnparsedIdentityConstraintRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedIdentityConstraintRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedIdentityConstraintRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedIdentityConstraintRegistrySub, declKey); break; case NOTATION_TYPE : - decl = (Element)fUnparsedNotationRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedNotationRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedNotationRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedNotationRegistrySub, declKey); break; case TYPEDECL_TYPE : - decl = (Element)fUnparsedTypeRegistry.get(declKey); - declDoc = (XSDocumentInfo)fUnparsedTypeRegistrySub.get(declKey); + decl = getElementFromMap(fUnparsedTypeRegistry, declKey); + declDoc = getDocInfoFromMap(fUnparsedTypeRegistrySub, declKey); break; default: reportSchemaError("Internal-Error", new Object [] {"XSDHandler asked to locate component of type " + declType + "; it does not recognize this type!"}, elmNode); @@ -1870,7 +1865,7 @@ // if the parent is use the namespace delcs for it. Element parent = DOMUtil.getParent(decl); if (DOMUtil.getLocalName(parent).equals(SchemaSymbols.ELT_REDEFINE)) - nsSupport = (SchemaNamespaceSupport)fRedefine2NSSupport.get(parent); + nsSupport = (fRedefine2NSSupport!=null)?(SchemaNamespaceSupport)fRedefine2NSSupport.get(parent):null; // back up the current SchemaNamespaceSupport, because we need to provide // a fresh one to the traverseGlobal methods. schemaDoc.backupNSSupport(nsSupport); @@ -1983,11 +1978,11 @@ // an accessor method. Just makes sure callers // who want the Identity constraint registry vaguely know what they're about. - protected Hashtable getIDRegistry() { + protected Map getIDRegistry() { return fUnparsedIdentityConstraintRegistry; } // an accessor method. - protected Hashtable getIDRegistry_sub() { + protected Map getIDRegistry_sub() { return fUnparsedIdentityConstraintRegistrySub; } @@ -2042,7 +2037,7 @@ Element referElement, boolean usePairs) { XMLInputSource schemaSource = null; try { - Hashtable pairs = usePairs ? fLocationPairs : EMPTY_TABLE; + Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE; schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver); } catch (IOException ex) { @@ -2095,7 +2090,7 @@ XMLInputSource schemaSource = null; try { - Hashtable pairs = usePairs ? fLocationPairs : EMPTY_TABLE; + Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE; schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver); } catch (IOException ex) { @@ -2503,7 +2498,7 @@ else { XSObject[] components = schemaSource.getComponents(); if (components != null && components.length > 0) { - Hashtable importDependencies = new Hashtable(); + Map importDependencies = new HashMap(); Vector expandedComponents = expandComponents(components, importDependencies); if (fNamespaceGrowth || canAddComponents(expandedComponents)) { addGlobalComponents(expandedComponents, importDependencies); @@ -2956,7 +2951,7 @@ } } - private Vector expandComponents(XSObject[] components, Hashtable dependencies) { + private Vector expandComponents(XSObject[] components, Map dependencies) { Vector newComponents = new Vector(); for (int i=0; i dependencies) { short componentType = component.getType(); switch (componentType) { case XSConstants.TYPE_DEFINITION : @@ -2998,7 +2993,7 @@ } } - private void expandRelatedAttributeComponents(XSAttributeDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { + private void expandRelatedAttributeComponents(XSAttributeDeclaration decl, Vector componentList, String namespace, Map dependencies) { addRelatedType(decl.getTypeDefinition(), componentList, namespace, dependencies); /*final XSComplexTypeDefinition enclosingType = decl.getEnclosingCTDefinition(); @@ -3007,7 +3002,7 @@ }*/ } - private void expandRelatedElementComponents(XSElementDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { + private void expandRelatedElementComponents(XSElementDeclaration decl, Vector componentList, String namespace, Map dependencies) { addRelatedType(decl.getTypeDefinition(), componentList, namespace, dependencies); /*final XSTypeDefinition enclosingType = decl.getEnclosingCTDefinition(); @@ -3021,7 +3016,7 @@ } } - private void expandRelatedTypeComponents(XSTypeDefinition type, Vector componentList, String namespace, Hashtable dependencies) { + private void expandRelatedTypeComponents(XSTypeDefinition type, Vector componentList, String namespace, Map dependencies) { if (type instanceof XSComplexTypeDecl) { expandRelatedComplexTypeComponents((XSComplexTypeDecl) type, componentList, namespace, dependencies); } @@ -3031,16 +3026,16 @@ } private void expandRelatedModelGroupDefinitionComponents(XSModelGroupDefinition modelGroupDef, Vector componentList, - String namespace, Hashtable dependencies) { + String namespace, Map dependencies) { expandRelatedModelGroupComponents(modelGroupDef.getModelGroup(), componentList, namespace, dependencies); } private void expandRelatedAttributeGroupComponents(XSAttributeGroupDefinition attrGroup, Vector componentList - , String namespace, Hashtable dependencies) { + , String namespace, Map dependencies) { expandRelatedAttributeUsesComponents(attrGroup.getAttributeUses(), componentList, namespace, dependencies); } - private void expandRelatedComplexTypeComponents(XSComplexTypeDecl type, Vector componentList, String namespace, Hashtable dependencies) { + private void expandRelatedComplexTypeComponents(XSComplexTypeDecl type, Vector componentList, String namespace, Map dependencies) { addRelatedType(type.getBaseType(), componentList, namespace, dependencies); expandRelatedAttributeUsesComponents(type.getAttributeUses(), componentList, namespace, dependencies); final XSParticle particle = type.getParticle(); @@ -3049,7 +3044,7 @@ } } - private void expandRelatedSimpleTypeComponents(XSSimpleTypeDefinition type, Vector componentList, String namespace, Hashtable dependencies) { + private void expandRelatedSimpleTypeComponents(XSSimpleTypeDefinition type, Vector componentList, String namespace, Map dependencies) { final XSTypeDefinition baseType = type.getBaseType(); if (baseType != null) { addRelatedType(baseType, componentList, namespace, dependencies); @@ -3074,7 +3069,7 @@ } private void expandRelatedAttributeUsesComponents(XSObjectList attrUses, Vector componentList, - String namespace, Hashtable dependencies) { + String namespace, Map dependencies) { final int attrUseSize = (attrUses == null) ? 0 : attrUses.size(); for (int i=0; i dependencies) { addRelatedAttribute(component.getAttrDeclaration(), componentList, namespace, dependencies); } private void expandRelatedParticleComponents(XSParticle component, Vector componentList, - String namespace, Hashtable dependencies) { + String namespace, Map dependencies) { XSTerm term = component.getTerm(); switch (term.getType()) { case XSConstants.ELEMENT_DECLARATION : @@ -3102,7 +3097,7 @@ } private void expandRelatedModelGroupComponents(XSModelGroup modelGroup, Vector componentList, - String namespace, Hashtable dependencies) { + String namespace, Map dependencies) { XSObjectList particles = modelGroup.getParticles(); final int length = (particles == null) ? 0 : particles.getLength(); for (int i=0; i dependencies) { if (!type.getAnonymous()) { if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead if (!componentList.contains(type)) { @@ -3125,7 +3120,7 @@ } } - private void addRelatedElement(XSElementDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { + private void addRelatedElement(XSElementDeclaration decl, Vector componentList, String namespace, Map dependencies) { if (decl.getScope() == XSConstants.SCOPE_GLOBAL) { if (!componentList.contains(decl)) { Vector importedNamespaces = findDependentNamespaces(namespace, dependencies); @@ -3138,7 +3133,7 @@ } } - private void addRelatedAttribute(XSAttributeDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { + private void addRelatedAttribute(XSAttributeDeclaration decl, Vector componentList, String namespace, Map dependencies) { if (decl.getScope() == XSConstants.SCOPE_GLOBAL) { if (!componentList.contains(decl)) { Vector importedNamespaces = findDependentNamespaces(namespace, dependencies); @@ -3151,7 +3146,7 @@ } } - private void addGlobalComponents(Vector components, Hashtable importDependencies) { + private void addGlobalComponents(Vector components, Map importDependencies) { final XSDDescription desc = new XSDDescription(); final int size = components.size(); @@ -3240,13 +3235,14 @@ } } - private void updateImportDependencies(Hashtable table) { - Enumeration keys = table.keys(); + private void updateImportDependencies(Map table) { + if (table == null) return; String namespace; Vector importList; - while (keys.hasMoreElements()) { - namespace = (String) keys.nextElement(); - importList = (Vector) table.get(null2EmptyString(namespace)); + + for(Map.Entry entry : table.entrySet()){ + namespace = entry.getKey(); + importList = entry.getValue(); if (importList.size() > 0) { expandImportList(namespace, importList); } @@ -3330,9 +3326,9 @@ return sg; } - private Vector findDependentNamespaces(String namespace, Hashtable table) { + private Vector findDependentNamespaces(String namespace, Map table) { final String ns = null2EmptyString(namespace); - Vector namespaceList = (Vector) table.get(ns); + Vector namespaceList = (Vector) getFromMap(table, ns); if (namespaceList == null) { namespaceList = new Vector(); @@ -3390,6 +3386,7 @@ // before traversing a schema's parse tree, need to reset all traversers and // clear all registries void prepareForTraverse() { + if (!registryEmpty) { fUnparsedAttributeRegistry.clear(); fUnparsedAttributeGroupRegistry.clear(); fUnparsedElementRegistry.clear(); @@ -3405,16 +3402,17 @@ fUnparsedIdentityConstraintRegistrySub.clear(); fUnparsedNotationRegistrySub.clear(); fUnparsedTypeRegistrySub.clear(); + } for (int i=1; i<= TYPEDECL_TYPE; i++) { - fUnparsedRegistriesExt[i].clear(); + if (fUnparsedRegistriesExt[i] != null) + fUnparsedRegistriesExt[i].clear(); } - fXSDocumentInfoRegistry.clear(); fDependencyMap.clear(); fDoc2XSDocumentMap.clear(); - fRedefine2XSDMap.clear(); - fRedefine2NSSupport.clear(); + if (fRedefine2XSDMap != null) fRedefine2XSDMap.clear(); + if (fRedefine2NSSupport != null) fRedefine2NSSupport.clear(); fAllTNSs.removeAllElements(); fImportMap.clear(); fRoot = null; @@ -3473,6 +3471,9 @@ public void setDVFactory(SchemaDVFactory dvFactory){ fDVFactory = dvFactory; } + public SchemaDVFactory getDVFactory(){ + return fDVFactory; + } public void reset(XMLComponentManager componentManager) { @@ -3660,7 +3661,7 @@ * or because we've found the thing we're redefining. */ void checkForDuplicateNames(String qName, int declType, - Hashtable registry, Hashtable registry_sub, Element currComp, + Map registry, Map registry_sub, Element currComp, XSDocumentInfo currSchema) { Object objElem = null; // REVISIT: when we add derivation checking, we'll have to make @@ -3685,7 +3686,7 @@ // (the parent of the colliding element is a redefine) boolean collidedWithRedefine = true; if ((DOMUtil.getLocalName((elemParent = DOMUtil.getParent(collidingElem))).equals(SchemaSymbols.ELT_REDEFINE))) { - redefinedSchema = (XSDocumentInfo)(fRedefine2XSDMap.get(elemParent)); + redefinedSchema = (fRedefine2XSDMap != null)?(XSDocumentInfo) (fRedefine2XSDMap.get(elemParent)): null; // case where we're a redefining element. } else if ((DOMUtil.getLocalName(DOMUtil.getParent(currComp)).equals(SchemaSymbols.ELT_REDEFINE))) { @@ -3735,14 +3736,20 @@ // we've just got a flat-out collision (we tolerate duplicate // declarations, only if they are defined in different schema // documents) - if (!fTolerateDuplicates || fUnparsedRegistriesExt[declType].get(qName) == currSchema) { + if (!fTolerateDuplicates) { reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp); + } else if (fUnparsedRegistriesExt[declType] != null) { + if (fUnparsedRegistriesExt[declType].get(qName) == currSchema) { + reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp); + } } } } // store the lastest current document info if (fTolerateDuplicates) { + if (fUnparsedRegistriesExt[declType] == null) + fUnparsedRegistriesExt[declType] = new HashMap(); fUnparsedRegistriesExt[declType].put(qName, currSchema); } @@ -4077,6 +4084,21 @@ return false; } + private Element getElementFromMap(Map registry, String declKey) { + if (registry == null) return null; + return registry.get(declKey); + } + + private XSDocumentInfo getDocInfoFromMap(Map registry, String declKey) { + if (registry == null) return null; + return registry.get(declKey); + } + + private Object getFromMap(Map registry, String key) { + if (registry == null) return null; + return registry.get(key); + } + void reportSchemaFatalError(String key, Object[] args, Element ele) { reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_FATAL_ERROR, null); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/datatype/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/datatype/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/datatype/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -39,22 +39,22 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() { - return (ClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - ClassLoader cl = null; - try { - cl = Thread.currentThread().getContextClassLoader(); - } catch (SecurityException ex) { } - return cl; - } - }); + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ClassLoader cl = null; + try { + cl = Thread.currentThread().getContextClassLoader(); + } catch (SecurityException ex) { } + return cl; + } + }); } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -65,16 +65,16 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getResourceAsStream(final ClassLoader cl, @@ -85,7 +85,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/parsers/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/parsers/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/parsers/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -39,26 +39,26 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() throws SecurityException{ - return (ClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { ClassLoader cl = null; //try { cl = Thread.currentThread().getContextClassLoader(); //} catch (SecurityException ex) { } - + if (cl == null) cl = ClassLoader.getSystemClassLoader(); - + return cl; } }); } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -69,16 +69,16 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getResourceAsStream(final ClassLoader cl, @@ -89,7 +89,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/stream/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/stream/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/stream/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -39,26 +39,26 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() throws SecurityException{ - return (ClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { ClassLoader cl = null; //try { cl = Thread.currentThread().getContextClassLoader(); //} catch (SecurityException ex) { } - + if (cl == null) cl = ClassLoader.getSystemClassLoader(); - + return cl; } }); } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -69,16 +69,16 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getResourceAsStream(final ClassLoader cl, @@ -89,7 +89,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/transform/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/transform/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/transform/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -39,7 +39,7 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() throws SecurityException{ return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { @@ -56,7 +56,7 @@ } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -67,16 +67,16 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getResourceAsStream(final ClassLoader cl, @@ -87,7 +87,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/transform/TransformerFactory.java --- a/sources/jaxp_src/src/javax/xml/transform/TransformerFactory.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/transform/TransformerFactory.java Wed Sep 28 17:54:25 2011 +0100 @@ -35,13 +35,14 @@ * This property names a concrete subclass of the * TransformerFactory abstract class. If the property is not * defined, a platform default is be used.

- * + * * @author Jeff Suttor * @author Neeraj Bajaj * + * @since 1.5 */ public abstract class TransformerFactory { - + /** * Default constructor is protected on purpose. */ @@ -66,7 +67,7 @@ * format and contains the fully qualified name of the * implementation class with the key being the system property defined * above. - * + * * The jaxp.properties file is read only once by the JAXP implementation * and it's values are then cached for future use. If the file does not exist * when the first attempt is made to read from it, no further attempts are @@ -123,22 +124,22 @@ *

Setting the jaxp.debug system property will cause * this method to print a lot of debug messages * to System.err about what it is doing and where it is looking at.

- * + * *

If you have problems try:

*
      * java -Djaxp.debug=1 YourProgram ....
      * 
+ * + * @param factoryClassName fully qualified factory class name that provides implementation of javax.xml.transform.TransformerFactory. * - * @param factoryClassName fully qualified factory class name that provides implementation of javax.xml.transform.TransformerFactory. - * - * @param classLoader ClassLoader used to load the factory class. If null + * @param classLoader ClassLoader used to load the factory class. If null * current Thread's context classLoader is used to load the factory class. * * @return new TransformerFactory instance, never null. * - * @throws TransformerFactoryConfigurationError - * if factoryClassName is null, or - * the factory class cannot be loaded, instantiated. + * @throws TransformerFactoryConfigurationError + * if factoryClassName is null, or + * the factory class cannot be loaded, instantiated. * * @see #newInstance() * @@ -153,7 +154,7 @@ throw new TransformerFactoryConfigurationError( e.getException(), e.getMessage()); - } + } } /** *

Process the Source into a Transformer @@ -179,7 +180,7 @@ * @throws TransformerConfigurationException Thrown if there are errors when * parsing the Source or it is not possible to create a * Transformer instance. - * + * * @see * XSL Transformations (XSLT) Version 1.0 */ @@ -236,11 +237,11 @@ * * @return A Source Object suitable for passing * to the TransformerFactory. - * + * * @throws TransformerConfigurationException An Exception * is thrown if an error occurings during parsing of the * source. - * + * * @see * Associating Style Sheets with XML documents Version 1.0 */ @@ -270,60 +271,60 @@ //======= CONFIGURATION METHODS ======= - /** - *

Set a feature for this TransformerFactory and Transformers - * or Templates created by this factory.

- * - *

- * Feature names are fully qualified {@link java.net.URI}s. - * Implementations may define their own features. - * An {@link TransformerConfigurationException} is thrown if this TransformerFactory or the - * Transformers or Templates it creates cannot support the feature. - * It is possible for an TransformerFactory to expose a feature value but be unable to change its state. - *

- * - *

All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. - * When the feature is:

- *
    - *
  • - * true: the implementation will limit XML processing to conform to implementation limits - * and behave in a secure fashion as defined by the implementation. - * Examples include resolving user defined style sheets and functions. - * If XML processing is limited for security reasons, it will be reported via a call to the registered - * {@link ErrorListener#fatalError(TransformerException exception)}. - * See {@link #setErrorListener(ErrorListener listener)}. - *
  • - *
  • - * false: the implementation will processing XML according to the XML specifications without - * regard to possible implementation limits. - *
  • - *
- * - * @param name Feature name. - * @param value Is feature state true or false. - * - * @throws TransformerConfigurationException if this TransformerFactory - * or the Transformers or Templates it creates cannot support this feature. + /** + *

Set a feature for this TransformerFactory and Transformers + * or Templates created by this factory.

+ * + *

+ * Feature names are fully qualified {@link java.net.URI}s. + * Implementations may define their own features. + * An {@link TransformerConfigurationException} is thrown if this TransformerFactory or the + * Transformers or Templates it creates cannot support the feature. + * It is possible for an TransformerFactory to expose a feature value but be unable to change its state. + *

+ * + *

All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. + * When the feature is:

+ *
    + *
  • + * true: the implementation will limit XML processing to conform to implementation limits + * and behave in a secure fashion as defined by the implementation. + * Examples include resolving user defined style sheets and functions. + * If XML processing is limited for security reasons, it will be reported via a call to the registered + * {@link ErrorListener#fatalError(TransformerException exception)}. + * See {@link #setErrorListener(ErrorListener listener)}. + *
  • + *
  • + * false: the implementation will processing XML according to the XML specifications without + * regard to possible implementation limits. + *
  • + *
+ * + * @param name Feature name. + * @param value Is feature state true or false. + * + * @throws TransformerConfigurationException if this TransformerFactory + * or the Transformers or Templates it creates cannot support this feature. * @throws NullPointerException If the name parameter is null. - */ - public abstract void setFeature(String name, boolean value) - throws TransformerConfigurationException; + */ + public abstract void setFeature(String name, boolean value) + throws TransformerConfigurationException; /** * Look up the value of a feature. * - *

- * Feature names are fully qualified {@link java.net.URI}s. - * Implementations may define their own features. - * false is returned if this TransformerFactory or the - * Transformers or Templates it creates cannot support the feature. - * It is possible for an TransformerFactory to expose a feature value but be unable to change its state. - *

- * - * @param name Feature name. - * + *

+ * Feature names are fully qualified {@link java.net.URI}s. + * Implementations may define their own features. + * false is returned if this TransformerFactory or the + * Transformers or Templates it creates cannot support the feature. + * It is possible for an TransformerFactory to expose a feature value but be unable to change its state. + *

+ * + * @param name Feature name. + * * @return The current state of the feature, true or false. - * + * * @throws NullPointerException If the name parameter is null. */ public abstract boolean getFeature(String name); @@ -337,7 +338,7 @@ * * @param name The name of the attribute. * @param value The value of the attribute. - * + * * @throws IllegalArgumentException When implementation does not * recognize the attribute. */ @@ -366,7 +367,7 @@ * ErrorListener listener is null. * * @param listener The new error listener. - * + * * @throws IllegalArgumentException When listener is * null */ @@ -380,3 +381,4 @@ public abstract ErrorListener getErrorListener(); } + diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/validation/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/validation/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/validation/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -41,7 +41,7 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { @@ -58,7 +58,7 @@ } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -69,31 +69,31 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getURLInputStream(final URL url) throws IOException { - try { + try { return (InputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { return url.openStream(); } }); - } catch (PrivilegedActionException e) { - throw (IOException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (IOException)e.getException(); + } } URL getResourceAsURL(final ClassLoader cl, @@ -104,7 +104,7 @@ public Object run() { URL url; if (cl == null) { - url = ClassLoader.getSystemResource(name); + url = Object.class.getResource(name); } else { url = cl.getResource(name); } @@ -133,7 +133,7 @@ throw (IOException)e.getException(); } } - + InputStream getResourceAsStream(final ClassLoader cl, final String name) { @@ -142,7 +142,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } diff -r b68688478d61 -r eece170ba62e sources/jaxp_src/src/javax/xml/xpath/SecuritySupport.java --- a/sources/jaxp_src/src/javax/xml/xpath/SecuritySupport.java Wed Sep 28 17:49:24 2011 +0100 +++ b/sources/jaxp_src/src/javax/xml/xpath/SecuritySupport.java Wed Sep 28 17:54:25 2011 +0100 @@ -40,22 +40,22 @@ */ class SecuritySupport { - + ClassLoader getContextClassLoader() { - return (ClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - ClassLoader cl = null; - try { - cl = Thread.currentThread().getContextClassLoader(); - } catch (SecurityException ex) { } - return cl; - } - }); + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ClassLoader cl = null; + try { + cl = Thread.currentThread().getContextClassLoader(); + } catch (SecurityException ex) { } + return cl; + } + }); } String getSystemProperty(final String propName) { - return (String) + return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); @@ -66,31 +66,31 @@ FileInputStream getFileInputStream(final File file) throws FileNotFoundException { - try { + try { return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); - } catch (PrivilegedActionException e) { - throw (FileNotFoundException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } } InputStream getURLInputStream(final URL url) throws IOException { - try { + try { return (InputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { return url.openStream(); } }); - } catch (PrivilegedActionException e) { - throw (IOException)e.getException(); - } + } catch (PrivilegedActionException e) { + throw (IOException)e.getException(); + } } URL getResourceAsURL(final ClassLoader cl, @@ -101,7 +101,7 @@ public Object run() { URL url; if (cl == null) { - url = ClassLoader.getSystemResource(name); + url = Object.class.getResource(name); } else { url = cl.getResource(name); } @@ -130,7 +130,7 @@ throw (IOException)e.getException(); } } - + InputStream getResourceAsStream(final ClassLoader cl, final String name) { @@ -139,7 +139,7 @@ public Object run() { InputStream ris; if (cl == null) { - ris = ClassLoader.getSystemResourceAsStream(name); + ris = Object.class.getResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); }