changeset 1385:80897e67a1b3 icedtea-2.7.0pre07

Merge jdk7u111-b01
author andrew
date Wed, 07 Sep 2016 06:06:32 +0100
parents 887a572ef17a (current diff) b198ece212c1 (diff)
children 36695a562f29
files .hgtags src/com/sun/org/apache/xalan/internal/XalanConstants.java src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java src/com/sun/org/apache/xalan/internal/lib/Extensions.java src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java src/com/sun/org/apache/xalan/internal/xsltc/DOM.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/UnsupportedElement.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslAttribute.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ko.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MultiHashtable.java src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMWSFilter.java src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java src/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java src/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java src/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXEvent2SAX.java src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java src/com/sun/org/apache/xerces/internal/dom/LCount.java src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java src/com/sun/org/apache/xerces/internal/dom/ParentNode.java src/com/sun/org/apache/xerces/internal/impl/Constants.java src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammarBucket.java src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java src/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties src/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java src/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java src/com/sun/org/apache/xerces/internal/util/DOMErrorHandlerWrapper.java src/com/sun/org/apache/xerces/internal/util/DOMUtil.java src/com/sun/org/apache/xerces/internal/util/EncodingMap.java src/com/sun/org/apache/xerces/internal/util/SymbolHash.java src/com/sun/org/apache/xerces/internal/util/SymbolTable.java src/com/sun/org/apache/xerces/internal/util/TypeInfoImpl.java src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java src/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java src/com/sun/org/apache/xml/internal/dtm/ref/CustomStringPool.java src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java src/com/sun/org/apache/xml/internal/resolver/Catalog.java src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java src/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java src/com/sun/org/apache/xml/internal/serialize/ElementState.java src/com/sun/org/apache/xml/internal/serialize/Encodings.java src/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java src/com/sun/org/apache/xml/internal/serializer/AttributesImplSerializer.java src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java src/com/sun/org/apache/xml/internal/serializer/Utils.java src/com/sun/org/apache/xml/internal/serializer/utils/Utils.java src/com/sun/org/apache/xml/internal/utils/DOMHelper.java src/com/sun/org/apache/xml/internal/utils/ElemDesc.java src/com/sun/org/apache/xml/internal/utils/NamespaceSupport2.java src/com/sun/org/apache/xml/internal/utils/TreeWalker.java src/com/sun/org/apache/xpath/internal/compiler/Keywords.java src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java src/com/sun/xml/internal/stream/Entity.java src/com/sun/xml/internal/stream/XMLEntityStorage.java src/com/sun/xml/internal/stream/dtd/nonvalidating/DTDGrammar.java src/org/xml/sax/helpers/NamespaceSupport.java
diffstat 157 files changed, 5665 insertions(+), 6705 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Jul 29 04:24:19 2016 +0100
+++ b/.hgtags	Wed Sep 07 06:06:32 2016 +0100
@@ -648,3 +648,11 @@
 3cc8e02e66bc361c2076580a71499ce2ddc63caa icedtea-2.7.0pre04
 4b0a1c2134169a6584b21a7bcf2396c9fa943805 icedtea-2.7.0pre05
 a2cd36a76d222deaffbf7e3751b524949a9c5b03 icedtea-2.7.0pre06
+e95e9042c8f31c5fe3149afdbe114592a3e32e91 jdk7u91-b00
+9f5bcd95c8d54f8cf5ab922b0b9e94f7ea6cdeb8 jdk7u91-b01
+6d9a192976332443bb3be46d49d5b255d9781fe9 jdk7u91-b02
+7c422316234f10b327fdbc181aedd5e74f31fd38 jdk7u95-b00
+c029d7572a67cb2fb3f9f2d8e91cbdda3beab95e jdk7u99-b00
+dcdbebfaf4b42da4927d3d0c682205a23cd7cdb8 jdk7u101-b00
+be2127cf0435d141d8072a94dbe75a527ceda453 jdk7u111-b00
+cd13b280e8247904509c28ee8aa9b45326185dd7 jdk7u111-b01
--- a/src/com/sun/org/apache/xalan/internal/XalanConstants.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/XalanConstants.java	Wed Sep 07 06:06:32 2016 +0100
@@ -81,6 +81,14 @@
      */
     public static final String JDK_GENEAL_ENTITY_SIZE_LIMIT =
             ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String JDK_ENTITY_REPLACEMENT_LIMIT =
+            ORACLE_JAXP_PROPERTY_PREFIX + "entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
@@ -137,6 +145,13 @@
      * JDK maximum general entity size limit
      */
     public static final String SP_GENEAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String SP_ENTITY_REPLACEMENT_LIMIT = "jdk.xml.entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
--- a/src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,10 +22,10 @@
  */
 package com.sun.org.apache.xalan.internal.lib;
 
-import java.util.Hashtable;
-
 import com.sun.org.apache.xml.internal.utils.DOMHelper;
 import com.sun.org.apache.xpath.internal.NodeSet;
+import java.util.HashMap;
+import java.util.Map;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -192,7 +192,7 @@
     NodeSet dist = new NodeSet();
     dist.setShouldCacheNodes(true);
 
-    Hashtable stringTable = new Hashtable();
+    Map<String, Node> stringTable = new HashMap<>();
 
     for (int i = 0; i < nl.getLength(); i++)
     {
--- a/src/com/sun/org/apache/xalan/internal/lib/Extensions.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/lib/Extensions.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,28 +22,24 @@
  */
 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.utils.ObjectFactory;
 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 java.util.Hashtable;
+import java.util.Map;
+import java.util.StringTokenizer;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 import org.w3c.dom.traversal.NodeIterator;
-
 import org.xml.sax.SAXNotSupportedException;
 
 /**
@@ -313,7 +309,7 @@
 
       // If reflection failed, fallback to our internal EnvironmentCheck
       EnvironmentCheck envChecker = new EnvironmentCheck();
-      Hashtable h = envChecker.getEnvironmentHash();
+      Map<String, Object> h = envChecker.getEnvironmentHash();
       resultNode = factoryDocument.createElement("checkEnvironmentExtension");
       envChecker.appendEnvironmentReport(resultNode, factoryDocument, h);
       envChecker = null;
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1359,10 +1359,10 @@
   { "optionLXCIN", "   [-LXCIN compiledStylesheetFileNameIn]"},
   { "optionLXCOUT", "   [-LXCOUT compiledStylesheetFileNameOutOut]"},
   { "optionPARSER", "   [-PARSER fully qualified class name of parser liaison]"},
-  {  "optionE", "   [-E (Entit\u00E4tsreferenzen nicht einblenden)]"},
-  {  "optionV",  "   [-E (Entit\u00E4tsreferenzen nicht einblenden)]"},
+  {  "optionE", "   [-E (Entityreferenzen nicht einblenden)]"},
+  {  "optionV",  "   [-E (Entityreferenzen nicht einblenden)]"},
   {  "optionQC", "   [-QC (Stille Musterkonfliktwarnungen)]"},
-  {  "optionQ", "   [-Q  (Stiller Modus)]"},
+  {  "optionQ", "   [-Q  (Silent-Modus)]"},
   {  "optionLF", "   [-LF (Nur Zeilenvorsch\u00FCbe bei Ausgabe verwenden {Standard ist CR/LF})]"},
   {  "optionCR", "   [-CR (Nur Zeilenschaltungen bei Ausgabe verwenden {Standard ist CR/LF})]"},
   { "optionESCAPE", "   [-ESCAPE (Escapezeichen {Standard ist <>&\"'\r\n}]"},
@@ -1384,7 +1384,7 @@
   { "noParsermsg4", "Wenn Sie nicht \u00FCber den XML-Parser f\u00FCr Java von IBM verf\u00FCgen, k\u00F6nnen Sie ihn hier herunterladen:"},
   { "noParsermsg5", "IBMs AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"},
   { "optionURIRESOLVER", "   [-URIRESOLVER full class name (URIResolver f\u00FCr die Aufl\u00F6sung von URIs)]"},
-  { "optionENTITYRESOLVER",  "   [-ENTITYRESOLVER full class name (EntityResolver f\u00FCr die Aufl\u00F6sung von Entit\u00E4ten)]"},
+  { "optionENTITYRESOLVER",  "   [-ENTITYRESOLVER full class name (EntityResolver f\u00FCr die Aufl\u00F6sung von Entitys)]"},
   { "optionCONTENTHANDLER",  "   [-CONTENTHANDLER full class name (ContentHandler f\u00FCr die Serialisierung der Ausgabe)]"},
   {  "optionLINENUMBERS",  "   [-L use line numbers for source document]"},
   { "optionSECUREPROCESSING", "   [-SECURE (Feature f\u00FCr die sichere Verarbeitung auf \"true\" setzen.)]"},
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1213,7 +1213,7 @@
       "Le nom de fonction ne peut pas \u00EAtre NULL."},
 
     { ER_XPATH_RESOLVER_NEGATIVE_ARITY,
-      "Le nombre d'arguments ne peut pas \u00EAtre n\u00E9gatif."},
+      "L'arit\u00E9 ne peut pas \u00EAtre n\u00E9gative."},
   // Warnings...
 
     { WG_FOUND_CURLYBRACE,
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java	Wed Sep 07 06:06:32 2016 +0100
@@ -591,7 +591,7 @@
      "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"},
 
     { ER_IOEXCEPTION,
-      "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC5D0 IO \uC608\uC678 \uC0AC\uD56D \uBC1C\uC0DD: {0}"},
+      "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC5D0 IO \uC608\uC678\uC0AC\uD56D \uBC1C\uC0DD: {0}"},
 
     { ER_NO_HREF_ATTRIB,
       "(StylesheetHandler) {0}\uC5D0 \uB300\uD55C href \uC18D\uC131\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
@@ -717,7 +717,7 @@
       "processStylesheet\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4!"},
 
     { ER_SAX_EXCEPTION,
-     "SAX \uC608\uC678 \uC0AC\uD56D"},
+     "SAX \uC608\uC678\uC0AC\uD56D"},
 
 //  add this message to fix bug 21478
     { ER_FUNCTION_NOT_SUPPORTED,
@@ -1325,7 +1325,7 @@
   {  "help_language",  "ko" },
   {  "language",  "ko" },
   { "BAD_CODE", "createMessage\uC5D0 \uB300\uD55C \uB9E4\uAC1C\uBCC0\uC218\uAC00 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4."},
-  {  "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678 \uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
+  {  "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
   {  "version", ">>>>>>> Xalan \uBC84\uC804 "},
   {  "version2",  "<<<<<<<"},
   {  "yes", "\uC608"},
--- a/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1268,7 +1268,7 @@
       "\u627E\u4E0D\u5230\u5341\u9032\u4F4D\u683C\u5F0F\u7684\u5BA3\u544A: {0}"},
 
     { WG_OLD_XSLT_NS,
-     "\u907A\u6F0F\u6216\u4E0D\u6B63\u78BA\u7684 XSLT \u547D\u540D\u7A7A\u9593\u3002 "},
+     "\u907A\u6F0F\u6216\u4E0D\u6B63\u78BA\u7684 XSLT \u547D\u540D\u7A7A\u9593\u3002"},
 
     { WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED,
       "\u53EA\u5141\u8A31\u4E00\u500B\u9810\u8A2D\u7684 xsl:decimal-format \u5BA3\u544A\u3002"},
--- a/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -65,27 +65,33 @@
      */
     public static enum Limit {
 
-        ENTITY_EXPANSION_LIMIT(XalanConstants.JDK_ENTITY_EXPANSION_LIMIT,
+        ENTITY_EXPANSION_LIMIT("EntityExpansionLimit", XalanConstants.JDK_ENTITY_EXPANSION_LIMIT,
                 XalanConstants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
-        MAX_OCCUR_NODE_LIMIT(XalanConstants.JDK_MAX_OCCUR_LIMIT,
+        MAX_OCCUR_NODE_LIMIT("MaxOccurLimit", XalanConstants.JDK_MAX_OCCUR_LIMIT,
                 XalanConstants.SP_MAX_OCCUR_LIMIT, 0, 5000),
-        ELEMENT_ATTRIBUTE_LIMIT(XalanConstants.JDK_ELEMENT_ATTRIBUTE_LIMIT,
+        ELEMENT_ATTRIBUTE_LIMIT("ElementAttributeLimit", XalanConstants.JDK_ELEMENT_ATTRIBUTE_LIMIT,
                 XalanConstants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
-        TOTAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_TOTAL_ENTITY_SIZE_LIMIT,
+        TOTAL_ENTITY_SIZE_LIMIT("TotalEntitySizeLimit", XalanConstants.JDK_TOTAL_ENTITY_SIZE_LIMIT,
                 XalanConstants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
-        GENEAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_GENEAL_ENTITY_SIZE_LIMIT,
+        GENEAL_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit", XalanConstants.JDK_GENEAL_ENTITY_SIZE_LIMIT,
                 XalanConstants.SP_GENEAL_ENTITY_SIZE_LIMIT, 0, 0),
-        PARAMETER_ENTITY_SIZE_LIMIT(XalanConstants.JDK_PARAMETER_ENTITY_SIZE_LIMIT,
+        PARAMETER_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit", XalanConstants.JDK_PARAMETER_ENTITY_SIZE_LIMIT,
                 XalanConstants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000),
-        MAX_ELEMENT_DEPTH_LIMIT(XalanConstants.JDK_MAX_ELEMENT_DEPTH,
-                XalanConstants.SP_MAX_ELEMENT_DEPTH, 0, 0);
+        MAX_ELEMENT_DEPTH_LIMIT("MaxElementDepthLimit", XalanConstants.JDK_MAX_ELEMENT_DEPTH,
+                XalanConstants.SP_MAX_ELEMENT_DEPTH, 0, 0),
+        MAX_NAME_LIMIT("MaxXMLNameLimit", XalanConstants.JDK_XML_NAME_LIMIT,
+                XalanConstants.SP_XML_NAME_LIMIT, 1000, 1000),
+        ENTITY_REPLACEMENT_LIMIT("EntityReplacementLimit", XalanConstants.JDK_ENTITY_REPLACEMENT_LIMIT,
+                XalanConstants.SP_ENTITY_REPLACEMENT_LIMIT, 0, 3000000);
 
+        final String key;
         final String apiProperty;
         final String systemProperty;
         final int defaultValue;
         final int secureValue;
 
-        Limit(String apiProperty, String systemProperty, int value, int secureValue) {
+        Limit(String key, String apiProperty, String systemProperty, int value, int secureValue) {
+            this.key = key;
             this.apiProperty = apiProperty;
             this.systemProperty = systemProperty;
             this.defaultValue = value;
@@ -100,6 +106,10 @@
             return (propertyName == null) ? false : systemProperty.equals(propertyName);
         }
 
+        public String key() {
+            return key;
+        }
+
         public String apiProperty() {
             return apiProperty;
         }
@@ -108,7 +118,7 @@
             return systemProperty;
         }
 
-        int defaultValue() {
+        public int defaultValue() {
             return defaultValue;
         }
 
@@ -160,7 +170,7 @@
     /**
      * Index of the special entityCountInfo property
      */
-    private int indexEntityCountInfo = 10000;
+    private final int indexEntityCountInfo = 10000;
     private String printEntityCountInfo = "";
 
     /**
--- a/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -24,17 +24,17 @@
 
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
 import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.Vector;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -171,7 +171,7 @@
       outWriter = pw;
 
     // Setup a hash to store various environment information in
-    Hashtable hash = getEnvironmentHash();
+    Map<String, Object> hash = getEnvironmentHash();
 
     // Check for ERROR keys in the hashtable, and print report
     boolean environmentHasErrors = writeEnvironmentReport(hash);
@@ -214,13 +214,13 @@
    * point out the most common classpath and system property
    * problems that we've seen.</p>
    *
-   * @return Hashtable full of useful environment info about Xalan
-   * and related system properties, etc.
+   * @return Map full of useful environment info about Xalan and related
+   * system properties, etc.
    */
-  public Hashtable getEnvironmentHash()
+  public Map<String, Object> getEnvironmentHash()
   {
     // Setup a hash to store various environment information in
-    Hashtable hash = new Hashtable();
+    Map<String, Object> hash = new HashMap<>();
 
     // Call various worker methods to fill in the hash
     //  These are explicitly separate for maintenance and so
@@ -242,22 +242,22 @@
    * Dump a basic Xalan environment report to outWriter.
    *
    * <p>This dumps a simple header and then each of the entries in
-   * the Hashtable to our PrintWriter; it does special processing
+   * the Map to our PrintWriter; it does special processing
    * for entries that are .jars found in the classpath.</p>
    *
-   * @param h Hashtable of items to report on; presumably
+   * @param h Map of items to report on; presumably
    * filled in by our various check*() methods
    * @return true if your environment appears to have no major
    * problems; false if potential environment problems found
-   * @see #appendEnvironmentReport(Node, Document, Hashtable)
+   * @see #appendEnvironmentReport(Node, Document, Map)
    * for an equivalent that appends to a Node instead
    */
-  protected boolean writeEnvironmentReport(Hashtable h)
+  protected boolean writeEnvironmentReport(Map<String, Object> h)
   {
 
     if (null == h)
     {
-      logMsg("# ERROR: writeEnvironmentReport called with null Hashtable");
+      logMsg("# ERROR: writeEnvironmentReport called with null Map");
       return false;
     }
 
@@ -267,39 +267,28 @@
       "#---- BEGIN writeEnvironmentReport($Revision: 1.10 $): Useful stuff found: ----");
 
     // Fake the Properties-like output
-    for (Enumeration keys = h.keys();
-         keys.hasMoreElements();
-        /* no increment portion */
-        )
-    {
-      Object key = keys.nextElement();
-      String keyStr = (String) key;
-      try
-      {
-        // Special processing for classes found..
-        if (keyStr.startsWith(FOUNDCLASSES))
-        {
-          Vector v = (Vector) h.get(keyStr);
-          errors |= logFoundJars(v, keyStr);
+    for (Map.Entry<String, Object> entry : h.entrySet()) {
+        String keyStr = entry.getKey();
+        try {
+            // Special processing for classes found..
+            if (keyStr.startsWith(FOUNDCLASSES)) {
+                List<Map> v = (ArrayList<Map>)entry.getValue();
+                errors |= logFoundJars(v, keyStr);
+            }
+            // ..normal processing for all other entries
+            else {
+                // Note: we could just check for the ERROR key by itself,
+                //    since we now set that, but since we have to go
+                //    through the whole hash anyway, do it this way,
+                //    which is safer for maintenance
+                if (keyStr.startsWith(ERROR)) {
+                    errors = true;
+                }
+                logMsg(keyStr + "=" + h.get(keyStr));
+            }
+        } catch (Exception e) {
+            logMsg("Reading-" + keyStr + "= threw: " + e.toString());
         }
-        // ..normal processing for all other entries
-        else
-        {
-          // Note: we could just check for the ERROR key by itself,
-          //    since we now set that, but since we have to go
-          //    through the whole hash anyway, do it this way,
-          //    which is safer for maintenance
-          if (keyStr.startsWith(ERROR))
-          {
-            errors = true;
-          }
-          logMsg(keyStr + "=" + h.get(keyStr));
-        }
-      }
-      catch (Exception e)
-      {
-        logMsg("Reading-" + key + "= threw: " + e.toString());
-      }
     }
 
     logMsg(
@@ -350,14 +339,14 @@
    * Takes the information encoded from a checkPathForJars()
    * call and dumps it out to our PrintWriter.
    *
-   * @param v Vector of Hashtables of .jar file info
+   * @param v List of Maps of .jar file info
    * @param desc description to print out in header
    *
    * @return false if OK, true if any .jars were reported
    * as having errors
    * @see #checkPathForJars(String, String[])
    */
-  protected boolean logFoundJars(Vector v, String desc)
+  protected boolean logFoundJars(List<Map> v, String desc)
   {
 
     if ((null == v) || (v.size() < 1))
@@ -367,32 +356,20 @@
 
     logMsg("#---- BEGIN Listing XML-related jars in: " + desc + " ----");
 
-    for (int i = 0; i < v.size(); i++)
-    {
-      Hashtable subhash = (Hashtable) v.elementAt(i);
+    for (Map<String, String> v1 : v) {
+        for (Map.Entry<String, String> entry : v1.entrySet()) {
+            String keyStr = entry.getKey();
+            try {
+                if (keyStr.startsWith(ERROR)) {
+                    errors = true;
+                }
+                logMsg(keyStr + "=" + entry.getValue());
 
-      for (Enumeration keys = subhash.keys();
-           keys.hasMoreElements();
-           /* no increment portion */
-          )
-      {
-        Object key = keys.nextElement();
-        String keyStr = (String) key;
-        try
-        {
-          if (keyStr.startsWith(ERROR))
-          {
-            errors = true;
-          }
-          logMsg(keyStr + "=" + subhash.get(keyStr));
-
+            } catch (Exception e) {
+                errors = true;
+                logMsg("Reading-" + keyStr + "= threw: " + e.toString());
+            }
         }
-        catch (Exception e)
-        {
-          errors = true;
-          logMsg("Reading-" + key + "= threw: " + e.toString());
-        }
-      }
     }
 
     logMsg("#----- END Listing XML-related jars in: " + desc + " -----");
@@ -410,10 +387,10 @@
    * @param container Node to append our report to
    * @param factory Document providing createElement, etc. services
    * @param h Hash presumably from {@link #getEnvironmentHash()}
-   * @see #writeEnvironmentReport(Hashtable)
+   * @see #writeEnvironmentReport(Map)
    * for an equivalent that writes to a PrintWriter instead
    */
-  public void appendEnvironmentReport(Node container, Document factory, Hashtable h)
+  public void appendEnvironmentReport(Node container, Document factory, Map<String, Object> h)
   {
     if ((null == container) || (null == factory))
     {
@@ -430,7 +407,7 @@
       {
         Element statusNode = factory.createElement("status");
         statusNode.setAttribute("result", "ERROR");
-        statusNode.appendChild(factory.createTextNode("appendEnvironmentReport called with null Hashtable!"));
+        statusNode.appendChild(factory.createTextNode("appendEnvironmentReport called with null Map!"));
         envCheckNode.appendChild(statusNode);
         return;
       }
@@ -440,47 +417,35 @@
       Element hashNode = factory.createElement("environment");
       envCheckNode.appendChild(hashNode);
 
-      for (Enumeration keys = h.keys();
-           keys.hasMoreElements();
-          /* no increment portion */
-          )
-      {
-        Object key = keys.nextElement();
-        String keyStr = (String) key;
-        try
-        {
-          // Special processing for classes found..
-          if (keyStr.startsWith(FOUNDCLASSES))
-          {
-            Vector v = (Vector) h.get(keyStr);
-            // errors |= logFoundJars(v, keyStr);
-            errors |= appendFoundJars(hashNode, factory, v, keyStr);
+      for (Map.Entry<String, Object> entry : h.entrySet()) {
+          String keyStr = entry.getKey();
+          try {
+              // Special processing for classes found..
+              if (keyStr.startsWith(FOUNDCLASSES)) {
+                  List<Map> v = (List<Map>)entry.getValue();
+                  // errors |= logFoundJars(v, keyStr);
+                  errors |= appendFoundJars(hashNode, factory, v, keyStr);
+              } // ..normal processing for all other entries
+              else {
+                  // Note: we could just check for the ERROR key by itself,
+                  //    since we now set that, but since we have to go
+                  //    through the whole hash anyway, do it this way,
+                  //    which is safer for maintenance
+                  if (keyStr.startsWith(ERROR)) {
+                      errors = true;
+                  }
+                  Element node = factory.createElement("item");
+                  node.setAttribute("key", keyStr);
+                  node.appendChild(factory.createTextNode((String) h.get(keyStr)));
+                  hashNode.appendChild(node);
+              }
+          } catch (Exception e) {
+              errors = true;
+              Element node = factory.createElement("item");
+              node.setAttribute("key", keyStr);
+              node.appendChild(factory.createTextNode(ERROR + " Reading " + keyStr + " threw: " + e.toString()));
+              hashNode.appendChild(node);
           }
-          // ..normal processing for all other entries
-          else
-          {
-            // Note: we could just check for the ERROR key by itself,
-            //    since we now set that, but since we have to go
-            //    through the whole hash anyway, do it this way,
-            //    which is safer for maintenance
-            if (keyStr.startsWith(ERROR))
-            {
-              errors = true;
-            }
-            Element node = factory.createElement("item");
-            node.setAttribute("key", keyStr);
-            node.appendChild(factory.createTextNode((String)h.get(keyStr)));
-            hashNode.appendChild(node);
-          }
-        }
-        catch (Exception e)
-        {
-          errors = true;
-          Element node = factory.createElement("item");
-          node.setAttribute("key", keyStr);
-          node.appendChild(factory.createTextNode(ERROR + " Reading " + key + " threw: " + e.toString()));
-          hashNode.appendChild(node);
-        }
       } // end of for...
 
       Element statusNode = factory.createElement("status");
@@ -502,7 +467,7 @@
    *
    * @param container Node to append our report to
    * @param factory Document providing createElement, etc. services
-   * @param v Vector of Hashtables of .jar file info
+   * @param v Map of Maps of .jar file info
    * @param desc description to print out in header
    *
    * @return false if OK, true if any .jars were reported
@@ -510,7 +475,7 @@
    * @see #checkPathForJars(String, String[])
    */
   protected boolean appendFoundJars(Node container, Document factory,
-        Vector v, String desc)
+        List<Map> v, String desc)
   {
 
     if ((null == v) || (v.size() < 1))
@@ -518,37 +483,25 @@
 
     boolean errors = false;
 
-    for (int i = 0; i < v.size(); i++)
-    {
-      Hashtable subhash = (Hashtable) v.elementAt(i);
-
-      for (Enumeration keys = subhash.keys();
-           keys.hasMoreElements();
-           /* no increment portion */
-          )
-      {
-        Object key = keys.nextElement();
-        try
-        {
-          String keyStr = (String) key;
-          if (keyStr.startsWith(ERROR))
-          {
-            errors = true;
-          }
-          Element node = factory.createElement("foundJar");
-          node.setAttribute("name", keyStr.substring(0, keyStr.indexOf("-")));
-          node.setAttribute("desc", keyStr.substring(keyStr.indexOf("-") + 1));
-          node.appendChild(factory.createTextNode((String)subhash.get(keyStr)));
-          container.appendChild(node);
+    for (Map<String, String> v1 : v) {
+        for (Map.Entry<String, String> entry : v1.entrySet()) {
+            String keyStr = entry.getKey();
+            try {
+                if (keyStr.startsWith(ERROR)) {
+                    errors = true;
+                }
+                Element node = factory.createElement("foundJar");
+                node.setAttribute("name", keyStr.substring(0, keyStr.indexOf("-")));
+                node.setAttribute("desc", keyStr.substring(keyStr.indexOf("-") + 1));
+                node.appendChild(factory.createTextNode(entry.getValue()));
+                container.appendChild(node);
+            } catch (Exception e) {
+                errors = true;
+                Element node = factory.createElement("foundJar");
+                node.appendChild(factory.createTextNode(ERROR + " Reading " + keyStr + " threw: " + e.toString()));
+                container.appendChild(node);
+            }
         }
-        catch (Exception e)
-        {
-          errors = true;
-          Element node = factory.createElement("foundJar");
-          node.appendChild(factory.createTextNode(ERROR + " Reading " + key + " threw: " + e.toString()));
-          container.appendChild(node);
-        }
-      }
     }
     return errors;
   }
@@ -562,15 +515,15 @@
    * //@todo NOTE: We don't actually search java.ext.dirs for
    * //  *.jar files therein! This should be updated
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    * @see #jarNames
    * @see #checkPathForJars(String, String[])
    */
-  protected void checkSystemProperties(Hashtable h)
+  protected void checkSystemProperties(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     // Grab java version for later use
     try
@@ -598,22 +551,22 @@
 
       h.put("java.class.path", cp);
 
-      Vector classpathJars = checkPathForJars(cp, jarNames);
+      List<Map> classpathJars = checkPathForJars(cp, jarNames);
 
-      if (null != classpathJars)
-        h.put(FOUNDCLASSES + "java.class.path", classpathJars);
+      if (null != classpathJars) {
+          h.put(FOUNDCLASSES + "java.class.path", classpathJars);
+      }
 
       // Also check for JDK 1.2+ type classpaths
       String othercp = SecuritySupport.getSystemProperty("sun.boot.class.path");
 
-      if (null != othercp)
-      {
-        h.put("sun.boot.class.path", othercp);
+      if (null != othercp) {
+          h.put("sun.boot.class.path", othercp);
+          classpathJars = checkPathForJars(othercp, jarNames);
 
-        classpathJars = checkPathForJars(othercp, jarNames);
-
-        if (null != classpathJars)
-          h.put(FOUNDCLASSES + "sun.boot.class.path", classpathJars);
+          if (null != classpathJars) {
+              h.put(FOUNDCLASSES + "sun.boot.class.path", classpathJars);
+          }
       }
 
       //@todo NOTE: We don't actually search java.ext.dirs for
@@ -654,20 +607,20 @@
    * @param cp classpath to search
    * @param jars array of .jar base filenames to look for
    *
-   * @return Vector of Hashtables filled with info about found .jars
+   * @return List of Maps filled with info about found .jars
    * @see #jarNames
-   * @see #logFoundJars(Vector, String)
-   * @see #appendFoundJars(Node, Document, Vector, String )
+   * @see #logFoundJars(Map, String)
+   * @see #appendFoundJars(Node, Document, Map, String )
    * @see #getApparentVersion(String, long)
    */
-  protected Vector checkPathForJars(String cp, String[] jars)
+  protected List<Map> checkPathForJars(String cp, String[] jars)
   {
 
     if ((null == cp) || (null == jars) || (0 == cp.length())
             || (0 == jars.length))
       return null;
 
-    Vector v = new Vector();
+    List<Map> v = new ArrayList<>();
     StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);
 
     while (st.hasMoreTokens())
@@ -687,37 +640,32 @@
 
             // If any requested jarName exists, report on
             //  the details of that .jar file
-            try
-            {
-              Hashtable h = new Hashtable(2);
-              // Note "-" char is looked for in appendFoundJars
-              h.put(jars[i] + "-path", f.getAbsolutePath());
+            try {
+                Map<String, String> h = new HashMap<>(2);
+                // Note "-" char is looked for in appendFoundJars
+                h.put(jars[i] + "-path", f.getAbsolutePath());
 
-              // We won't bother reporting on the xalan.jar apparent version
-              // since this requires knowing the jar size of the xalan.jar
-              // before we build it.
-              // For other jars, eg. xml-apis.jar and xercesImpl.jar, we
-              // report the apparent version of the file we've found
-              if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
-                h.put(jars[i] + "-apparent.version",
-                    getApparentVersion(jars[i], f.length()));
-              }
-              v.addElement(h);
+                // We won't bother reporting on the xalan.jar apparent version
+                // since this requires knowing the jar size of the xalan.jar
+                // before we build it.
+                // For other jars, eg. xml-apis.jar and xercesImpl.jar, we
+                // report the apparent version of the file we've found
+                if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
+                    h.put(jars[i] + "-apparent.version",
+                            getApparentVersion(jars[i], f.length()));
+                }
+                v.add(h);
+            } catch (Exception e) {
+
+                /* no-op, don't add it  */
             }
-            catch (Exception e)
-            {
-
-              /* no-op, don't add it  */
-            }
-          }
-          else
-          {
-            Hashtable h = new Hashtable(2);
+          } else {
+            Map<String, String> h = new HashMap<>(2);
             // Note "-" char is looked for in appendFoundJars
             h.put(jars[i] + "-path", WARNING + " Classpath entry: "
-                  + filename + " does not exist");
+                    + filename + " does not exist");
             h.put(jars[i] + "-apparent.version", CLASS_NOTPRESENT);
-            v.addElement(h);
+            v.add(h);
           }
         }
       }
@@ -748,8 +696,8 @@
   {
     // If we found a matching size and it's for our
     //  jar, then return it's description
-    // Lookup in static jarVersions Hashtable
-    String foundSize = (String) jarVersions.get(new Long(jarSize));
+    // Lookup in static JARVERSIONS Map
+    String foundSize = JARVERSIONS.get(new Long(jarSize));
 
     if ((null != foundSize) && (foundSize.startsWith(jarName)))
     {
@@ -783,13 +731,13 @@
    * and not found; only tests the interfaces, and does not
    * check for reference implementation versions.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkJAXPVersion(Hashtable h)
+  protected void checkJAXPVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     Class clazz = null;
 
@@ -814,13 +762,13 @@
    *
    * Looks for version info in xalan.jar from Xalan-J products.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkProcessorVersion(Hashtable h)
+  protected void checkProcessorVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     try
     {
@@ -900,13 +848,13 @@
    *
    * //@todo actually look up version info in crimson manifest
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkParserVersion(Hashtable h)
+  protected void checkParserVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     try
     {
@@ -961,13 +909,13 @@
   /**
    * Report product version information from Ant.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkAntVersion(Hashtable h)
+  protected void checkAntVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     try
     {
@@ -991,13 +939,13 @@
   /**
    * Report version info from DOM interfaces.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected boolean checkDOML3(Hashtable h)
+  protected boolean checkDOML3(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     final String DOM_CLASS = "org.w3c.dom.Document";
     final String DOM_LEVEL3_METHOD = "getDoctype";  // no parameter
@@ -1026,13 +974,13 @@
    * level 2 working draft, the DOM level 2 final draft,
    * and not found.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkDOMVersion(Hashtable h)
+  protected void checkDOMVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     final String DOM_LEVEL2_CLASS = "org.w3c.dom.Document";
     final String DOM_LEVEL2_METHOD = "createElementNS";  // String, String
@@ -1102,13 +1050,13 @@
    * Currently distinguishes between SAX 2, SAX 2.0beta2,
    * SAX1, and not found.
    *
-   * @param h Hashtable to put information in
+   * @param h Map to put information in
    */
-  protected void checkSAXVersion(Hashtable h)
+  protected void checkSAXVersion(Map<String, Object> h)
   {
 
     if (null == h)
-      h = new Hashtable();
+      h = new HashMap<>();
 
     final String SAX_VERSION1_CLASS = "org.xml.sax.Parser";
     final String SAX_VERSION1_METHOD = "parse";  // String
@@ -1188,17 +1136,17 @@
    *
    * @see #getApparentVersion(String, long)
    */
-  private static Hashtable jarVersions = new Hashtable();
+  private static final Map<Long, String> JARVERSIONS;
 
   /**
-   * Static initializer for jarVersions table.
+   * Static initializer for JARVERSIONS table.
    * Doing this just once saves time and space.
    *
    * @see #getApparentVersion(String, long)
    */
   static
   {
-    // Note: hackish Hashtable, this could use improvement
+    Map<Long, String> jarVersions = new HashMap<>();
     jarVersions.put(new Long(857192), "xalan.jar from xalan-j_1_1");
     jarVersions.put(new Long(440237), "xalan.jar from xalan-j_1_2");
     jarVersions.put(new Long(436094), "xalan.jar from xalan-j_1_2_1");
@@ -1287,6 +1235,8 @@
     // jakarta-ant: since many people use ant these days
     jarVersions.put(new Long(136198), "parser.jar from jakarta-ant-1.3 or 1.2");
     jarVersions.put(new Long(5537), "jaxp.jar from jakarta-ant-1.3 or 1.2");
+
+    JARVERSIONS = Collections.unmodifiableMap(jarVersions);
   }
 
   /** Simple PrintWriter we send output to; defaults to System.out.  */
--- a/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,14 +23,12 @@
 
 package com.sun.org.apache.xalan.internal.xsltc;
 
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
-
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import java.util.Map;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-
 /**
  * @author Jacek Ambroziak
  * @author Santiago Pericas-Geertsen
@@ -103,5 +101,5 @@
     public int getNSType(int node);
     public int getDocument();
     public String getUnparsedEntityURI(String name);
-    public Hashtable getElementsWithIDs();
+    public Map<String, Integer> getElementsWithIDs();
 }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,9 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
@@ -41,6 +38,8 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
+import java.util.Iterator;
+import java.util.Vector;
 
 /**
  * @author Jacek Ambroziak
@@ -122,9 +121,9 @@
 
         // check if sorting nodes is required
         final Vector sortObjects = new Vector();
-        final Enumeration children = elements();
-        while (children.hasMoreElements()) {
-            final Object child = children.nextElement();
+        final Iterator<SyntaxTreeNode> children = elements();
+        while (children.hasNext()) {
+            final SyntaxTreeNode child = children.next();
             if (child instanceof Sort) {
                 sortObjects.addElement(child);
             }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,9 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
@@ -37,6 +34,8 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Jacek Ambroziak
@@ -111,10 +110,10 @@
 
         // Parse the contents of this node. All child elements must be
         // <xsl:attribute> elements. Other elements cause an error.
-        final Vector contents = getContents();
+        final List<SyntaxTreeNode> contents = getContents();
         final int count = contents.size();
         for (int i=0; i<count; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
+            SyntaxTreeNode child = contents.get(i);
             if (child instanceof XslAttribute) {
                 parser.getSymbolTable().setCurrentNode(child);
                 child.parseContents(parser);
@@ -181,9 +180,9 @@
         if (_useSets != null) _useSets.translate(classGen, methodGen);
 
         // Translate all local attributes
-        final Enumeration attributes = elements();
-        while (attributes.hasMoreElements()) {
-            SyntaxTreeNode element = (SyntaxTreeNode)attributes.nextElement();
+        final Iterator<SyntaxTreeNode> attributes = elements();
+        while (attributes.hasNext()) {
+            SyntaxTreeNode element = attributes.next();
             if (element instanceof XslAttribute) {
                 final XslAttribute attribute = (XslAttribute)element;
                 attribute.translate(classGen, methodGen);
@@ -198,10 +197,10 @@
     public String toString() {
         StringBuffer buf = new StringBuffer("attribute-set: ");
         // Translate all local attributes
-        final Enumeration attributes = elements();
-        while (attributes.hasMoreElements()) {
+        final Iterator<SyntaxTreeNode> attributes = elements();
+        while (attributes.hasNext()) {
             final XslAttribute attribute =
-                (XslAttribute)attributes.nextElement();
+                (XslAttribute)attributes.next();
             buf.append(attribute);
         }
         return(buf.toString());
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,11 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Vector;
-import java.util.StringTokenizer;
-import java.util.NoSuchElementException;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
@@ -39,6 +34,10 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
 
 /**
  * @author Jacek Ambroziak
@@ -206,12 +205,12 @@
     }
 
     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
-        final Vector contents = getContents();
+        final List<SyntaxTreeNode> contents = getContents();
         final int n = contents.size();
         for (int i = 0; i < n; i++) {
-            final Expression exp = (Expression)contents.elementAt(i);
+            final Expression exp = (Expression)contents.get(i);
             if (!exp.typeCheck(stable).identicalTo(Type.String)) {
-                contents.setElementAt(new CastExpr(exp, Type.String), i);
+                contents.set(i, new CastExpr(exp, Type.String));
             }
         }
         return _type = Type.String;
@@ -251,9 +250,9 @@
             il.append(DUP);
             il.append(new INVOKESPECIAL(initBuffer));
             // StringBuffer is on the stack
-            final Enumeration elements = elements();
-            while (elements.hasMoreElements()) {
-                final Expression exp = (Expression)elements.nextElement();
+            final Iterator<SyntaxTreeNode> elements = elements();
+            while (elements.hasNext()) {
+                final Expression exp = (Expression)elements.next();
                 exp.translate(classGen, methodGen);
                 il.append(append);
             }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -51,7 +51,7 @@
     /**
      * Legal conversions between internal types.
      */
-    static private MultiHashtable InternalTypeMap = new MultiHashtable();
+    private static final MultiHashtable<Type, Type> InternalTypeMap = new MultiHashtable<>();
 
     static {
         // Possible type conversions between internal types
@@ -118,6 +118,8 @@
         InternalTypeMap.put(Type.Object, Type.String);
 
         InternalTypeMap.put(Type.Void, Type.String);
+
+        InternalTypeMap.makeUnmodifiable();
     }
 
     private boolean _typeTest = false;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,9 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.BranchHandle;
 import com.sun.org.apache.bcel.internal.generic.GOTO;
 import com.sun.org.apache.bcel.internal.generic.IFEQ;
@@ -37,6 +34,9 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Vector;
 
 /**
  * @author Jacek Ambroziak
@@ -62,15 +62,15 @@
     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
         final Vector whenElements = new Vector();
         Otherwise otherwise = null;
-        Enumeration elements = elements();
+        Iterator<SyntaxTreeNode> elements = elements();
 
         // These two are for reporting errors only
         ErrorMsg error = null;
         final int line = getLineNumber();
 
         // Traverse all child nodes - must be either When or Otherwise
-        while (elements.hasMoreElements()) {
-            Object element = elements.nextElement();
+        while (elements.hasNext()) {
+            SyntaxTreeNode element = elements.next();
             // Add a When child element
             if (element instanceof When) {
                 whenElements.addElement(element);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,9 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.BranchHandle;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.GOTO;
@@ -42,6 +39,8 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
+import java.util.Iterator;
+import java.util.Vector;
 
 /**
  * @author Jacek Ambroziak
@@ -97,9 +96,9 @@
 
         // Collect sort objects associated with this instruction
         final Vector sortObjects = new Vector();
-        Enumeration children = elements();
-        while (children.hasMoreElements()) {
-            final Object child = children.nextElement();
+        Iterator<SyntaxTreeNode> children = elements();
+        while (children.hasNext()) {
+            final SyntaxTreeNode child = children.next();
             if (child instanceof Sort) {
                 sortObjects.addElement(child);
             }
@@ -187,7 +186,7 @@
                                    MethodGenerator methodGen) {
         final int n = elementCount();
         for (int i = 0; i < n; i++) {
-            final Object child = getContents().elementAt(i);
+            final SyntaxTreeNode child = getContents().get(i);
             if (child instanceof Variable) {
                 Variable var = (Variable)child;
                 var.initialize(classGen, methodGen);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,13 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.IFEQ;
 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
@@ -43,6 +36,8 @@
 import com.sun.org.apache.bcel.internal.generic.NEW;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
 import com.sun.org.apache.xalan.internal.utils.FeatureManager;
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.Objects;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
@@ -54,8 +49,14 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.Objects;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
 
 /**
  * @author Jacek Ambroziak
@@ -138,23 +139,23 @@
     private boolean       _isStatic = false;
 
     // Legal conversions between internal and Java types.
-    private static final MultiHashtable _internal2Java = new MultiHashtable();
+    private static final MultiHashtable<Type, JavaType> _internal2Java = new MultiHashtable<>();
 
     // Legal conversions between Java and internal types.
-    private static final Hashtable _java2Internal = new Hashtable();
+    private static final Map<Class<?>, Type> JAVA2INTERNAL;
 
     // The mappings between EXSLT extension namespaces and implementation classes
-    private static final Hashtable _extensionNamespaceTable = new Hashtable();
+    private static final Map<String, String> EXTENSIONNAMESPACE;
 
     // Extension functions that are implemented in BasisLibrary
-    private static final Hashtable _extensionFunctionTable = new Hashtable();
+    private static final Map<String, String> EXTENSIONFUNCTION;
     /**
      * inner class to used in internal2Java mappings, contains
      * the Java type and the distance between the internal type and
      * the Java type.
      */
     static class JavaType {
-        public Class  type;
+        public Class<?>  type;
         public int distance;
 
         public JavaType(Class type, int distance){
@@ -168,8 +169,15 @@
         }
 
         @Override
-        public boolean equals(Object query){
-            return query != null && query.equals(type);
+        public boolean equals(Object query) {
+            if (query == null) {
+                return false;
+            }
+            if (query.getClass().isAssignableFrom(JavaType.class)) {
+                return ((JavaType)query).type.equals(type);
+            } else {
+                return query.equals(type);
+            }
         }
     }
 
@@ -180,99 +188,112 @@
      * These two tables are used when calling external (Java) functions.
      */
     static {
+        final Class<?> nodeClass, nodeListClass;
         try {
-            final Class nodeClass     = Class.forName("org.w3c.dom.Node");
-            final Class nodeListClass = Class.forName("org.w3c.dom.NodeList");
-
-            // -- Internal to Java --------------------------------------------
-
-            // Type.Boolean -> { boolean(0), Boolean(1), Object(2) }
-            _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0));
-            _internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1));
-            _internal2Java.put(Type.Boolean, new JavaType(Object.class, 2));
-
-            // Type.Real -> { double(0), Double(1), float(2), long(3), int(4),
-            //                short(5), byte(6), char(7), Object(8) }
-            _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
-            _internal2Java.put(Type.Real, new JavaType(Double.class, 1));
-            _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2));
-            _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3));
-            _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4));
-            _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5));
-            _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6));
-            _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7));
-            _internal2Java.put(Type.Real, new JavaType(Object.class, 8));
-
-            // Type.Int must be the same as Type.Real
-            _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0));
-            _internal2Java.put(Type.Int, new JavaType(Double.class, 1));
-            _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
-            _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3));
-            _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4));
-            _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5));
-            _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6));
-            _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7));
-            _internal2Java.put(Type.Int, new JavaType(Object.class, 8));
-
-            // Type.String -> { String(0), Object(1) }
-            _internal2Java.put(Type.String, new JavaType(String.class, 0));
-            _internal2Java.put(Type.String, new JavaType(Object.class, 1));
-
-            // Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) }
-            _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0));
-            _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1));
-            _internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2));
-            _internal2Java.put(Type.NodeSet, new JavaType(String.class, 3));
-
-            // Type.Node -> { Node(0), NodeList(1), Object(2), String(3) }
-            _internal2Java.put(Type.Node, new JavaType(nodeListClass, 0));
-            _internal2Java.put(Type.Node, new JavaType(nodeClass, 1));
-            _internal2Java.put(Type.Node, new JavaType(Object.class, 2));
-            _internal2Java.put(Type.Node, new JavaType(String.class, 3));
-
-            // Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) }
-            _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0));
-            _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1));
-            _internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2));
-            _internal2Java.put(Type.ResultTree, new JavaType(String.class, 3));
-
-            _internal2Java.put(Type.Reference, new JavaType(Object.class, 0));
-
-            // Possible conversions between Java and internal types
-            _java2Internal.put(Boolean.TYPE, Type.Boolean);
-            _java2Internal.put(Void.TYPE, Type.Void);
-            _java2Internal.put(Character.TYPE, Type.Real);
-            _java2Internal.put(Byte.TYPE, Type.Real);
-            _java2Internal.put(Short.TYPE, Type.Real);
-            _java2Internal.put(Integer.TYPE, Type.Real);
-            _java2Internal.put(Long.TYPE, Type.Real);
-            _java2Internal.put(Float.TYPE, Type.Real);
-            _java2Internal.put(Double.TYPE, Type.Real);
-
-            _java2Internal.put(String.class, Type.String);
-
-            _java2Internal.put(Object.class, Type.Reference);
-
-            // Conversions from org.w3c.dom.Node/NodeList to internal NodeSet
-            _java2Internal.put(nodeListClass, Type.NodeSet);
-            _java2Internal.put(nodeClass, Type.NodeSet);
-
-            // Initialize the extension namespace table
-            _extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions");
-            _extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon");
-            _extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath");
-            _extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets");
-            _extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime");
-            _extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings");
-
-            // Initialize the extension function table
-            _extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset");
-            _extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType");
-            _extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset");
+            nodeClass     = Class.forName("org.w3c.dom.Node");
+            nodeListClass = Class.forName("org.w3c.dom.NodeList");
         }
         catch (ClassNotFoundException e) {
-            System.err.println(e);
+            ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR,"org.w3c.dom.Node or NodeList");
+            throw new ExceptionInInitializerError(err.toString());
         }
+
+        // -- Internal to Java --------------------------------------------
+
+        // Type.Boolean -> { boolean(0), Boolean(1), Object(2) }
+        _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0));
+        _internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1));
+        _internal2Java.put(Type.Boolean, new JavaType(Object.class, 2));
+
+        // Type.Real -> { double(0), Double(1), float(2), long(3), int(4),
+        //                short(5), byte(6), char(7), Object(8) }
+        _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
+        _internal2Java.put(Type.Real, new JavaType(Double.class, 1));
+        _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2));
+        _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3));
+        _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4));
+        _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5));
+        _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6));
+        _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7));
+        _internal2Java.put(Type.Real, new JavaType(Object.class, 8));
+
+        // Type.Int must be the same as Type.Real
+        _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0));
+        _internal2Java.put(Type.Int, new JavaType(Double.class, 1));
+        _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
+        _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3));
+        _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4));
+        _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5));
+        _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6));
+        _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7));
+        _internal2Java.put(Type.Int, new JavaType(Object.class, 8));
+
+        // Type.String -> { String(0), Object(1) }
+        _internal2Java.put(Type.String, new JavaType(String.class, 0));
+        _internal2Java.put(Type.String, new JavaType(Object.class, 1));
+
+        // Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) }
+        _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0));
+        _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1));
+        _internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2));
+        _internal2Java.put(Type.NodeSet, new JavaType(String.class, 3));
+
+        // Type.Node -> { Node(0), NodeList(1), Object(2), String(3) }
+        _internal2Java.put(Type.Node, new JavaType(nodeListClass, 0));
+        _internal2Java.put(Type.Node, new JavaType(nodeClass, 1));
+        _internal2Java.put(Type.Node, new JavaType(Object.class, 2));
+        _internal2Java.put(Type.Node, new JavaType(String.class, 3));
+
+        // Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) }
+        _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0));
+        _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1));
+        _internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2));
+        _internal2Java.put(Type.ResultTree, new JavaType(String.class, 3));
+
+        _internal2Java.put(Type.Reference, new JavaType(Object.class, 0));
+
+        _internal2Java.makeUnmodifiable();
+
+        Map<Class<?>, Type> java2Internal = new HashMap<>();
+        Map<String, String> extensionNamespaceTable = new HashMap<>();
+        Map<String, String> extensionFunctionTable = new HashMap<>();
+
+        // Possible conversions between Java and internal types
+        java2Internal.put(Boolean.TYPE, Type.Boolean);
+        java2Internal.put(Void.TYPE, Type.Void);
+        java2Internal.put(Character.TYPE, Type.Real);
+        java2Internal.put(Byte.TYPE, Type.Real);
+        java2Internal.put(Short.TYPE, Type.Real);
+        java2Internal.put(Integer.TYPE, Type.Real);
+        java2Internal.put(Long.TYPE, Type.Real);
+        java2Internal.put(Float.TYPE, Type.Real);
+        java2Internal.put(Double.TYPE, Type.Real);
+
+        java2Internal.put(String.class, Type.String);
+
+        java2Internal.put(Object.class, Type.Reference);
+
+        // Conversions from org.w3c.dom.Node/NodeList to internal NodeSet
+        java2Internal.put(nodeListClass, Type.NodeSet);
+        java2Internal.put(nodeClass, Type.NodeSet);
+
+        // Initialize the extension namespace table
+        extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions");
+        extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon");
+        extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath");
+        extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets");
+        extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime");
+        extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings");
+
+        // Initialize the extension function table
+        extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset");
+        extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType");
+        extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset");
+
+        JAVA2INTERNAL = Collections.unmodifiableMap(java2Internal);
+        EXTENSIONNAMESPACE = Collections.unmodifiableMap(extensionNamespaceTable);
+        EXTENSIONFUNCTION = Collections.unmodifiableMap(extensionFunctionTable);
+
     }
 
     public FunctionCall(QName fname, Vector arguments) {
@@ -304,7 +325,7 @@
 
     public String getClassNameFromUri(String uri)
     {
-        String className = (String)_extensionNamespaceTable.get(uri);
+        String className = EXTENSIONNAMESPACE.get(uri);
 
         if (className != null)
             return className;
@@ -384,7 +405,7 @@
                         local = replaceDash(local);
                     }
 
-                    String extFunction = (String)_extensionFunctionTable.get(namespace + ":" + local);
+                    String extFunction = EXTENSIONFUNCTION.get(namespace + ":" + local);
                     if (extFunction != null) {
                         _fname = new QName(null, null, extFunction);
                         return typeCheckStandard(stable);
@@ -464,15 +485,15 @@
                 (Constructor)constructors.elementAt(i);
             final Class[] paramTypes = constructor.getParameterTypes();
 
-            Class extType = null;
+            Class<?> extType;
             int currConstrDistance = 0;
             for (j = 0; j < nArgs; j++) {
                 // Convert from internal (translet) type to external (Java) type
                 extType = paramTypes[j];
                 final Type intType = (Type)argsType.elementAt(j);
-                Object match = _internal2Java.maps(intType, extType);
+                JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
                 if (match != null) {
-                    currConstrDistance += ((JavaType)match).distance;
+                    currConstrDistance += match.distance;
                 }
                 else if (intType instanceof ObjectType) {
                     ObjectType objectType = (ObjectType)intType;
@@ -597,9 +618,9 @@
                 // Convert from internal (translet) type to external (Java) type
                 extType = paramTypes[j];
                 final Type intType = (Type)argsType.elementAt(j);
-                Object match = _internal2Java.maps(intType, extType);
+                JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
                 if (match != null) {
-                    currMethodDistance += ((JavaType)match).distance;
+                    currMethodDistance += match.distance;
                 }
                 else {
                     // no mapping available
@@ -631,7 +652,7 @@
                   // Check if the return type can be converted
                   extType = method.getReturnType();
 
-                  _type = (Type) _java2Internal.get(extType);
+                  _type = JAVA2INTERNAL.get(extType);
                   if (_type == null) {
                       _type = Type.newObjectType(extType);
                   }
@@ -911,9 +932,9 @@
                     //Check if FSP and SM - only then proceed with loading
                     if (namespace != null && isSecureProcessing
                             && isExtensionFunctionEnabled
-                            && (namespace.equals(JAVA_EXT_XALAN)
-                            || namespace.equals(JAVA_EXT_XSLTC)
-                            || namespace.equals(JAVA_EXT_XALAN_OLD)
+                            && (namespace.startsWith(JAVA_EXT_XALAN)
+                            || namespace.startsWith(JAVA_EXT_XSLTC)
+                            || namespace.startsWith(JAVA_EXT_XALAN_OLD)
                             || namespace.startsWith(XALAN_CLASSPACKAGE_NAMESPACE))) {
                         _clazz = getXSLTC().loadExternalFunction(_className);
                     } else {
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -31,10 +31,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
-import java.io.File;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.Enumeration;
+import java.util.Iterator;
 import javax.xml.XMLConstants;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
@@ -133,10 +130,10 @@
             parser.setCurrentStylesheet(_imported);
             _imported.parseContents(parser);
 
-            final Enumeration elements = _imported.elements();
+            final Iterator<SyntaxTreeNode> elements = _imported.elements();
             final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
-            while (elements.hasMoreElements()) {
-                final Object element = elements.nextElement();
+            while (elements.hasNext()) {
+                final SyntaxTreeNode element = elements.next();
                 if (element instanceof TopLevelElement) {
                     if (element instanceof Variable) {
                         topStylesheet.addVariable((Variable) element);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -31,11 +31,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
+import java.util.Iterator;
 import javax.xml.XMLConstants;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
@@ -133,10 +129,10 @@
             parser.setCurrentStylesheet(_included);
             _included.parseContents(parser);
 
-            final Enumeration elements = _included.elements();
+            final Iterator<SyntaxTreeNode> elements = _included.elements();
             final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
-            while (elements.hasMoreElements()) {
-                final Object element = elements.nextElement();
+            while (elements.hasNext()) {
+                final SyntaxTreeNode element = elements.next();
                 if (element instanceof TopLevelElement) {
                     if (element instanceof Variable) {
                         topStylesheet.addVariable((Variable) element);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,8 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.BranchHandle;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.GOTO;
@@ -226,7 +224,7 @@
         // AbstractTranslet.buildKeyIndex(name,node_id,value) => void
         final int key = cpg.addMethodref(TRANSLET_CLASS,
                                          "buildKeyIndex",
-                                         "("+STRING_SIG+"I"+OBJECT_SIG+")V");
+                                         "("+STRING_SIG+"I"+STRING_SIG+")V");
 
         // AbstractTranslet.SetKeyIndexDom(name, Dom) => void
         final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,10 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
@@ -36,9 +32,14 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
-
 import com.sun.org.apache.xml.internal.serializer.ElemDesc;
 import com.sun.org.apache.xml.internal.serializer.ToHTMLStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Jacek Ambroziak
@@ -49,8 +50,8 @@
 
     private String _name;
     private LiteralElement _literalElemParent = null;
-    private Vector _attributeElements = null;
-    private Hashtable _accessedPrefixes = null;
+    private List<SyntaxTreeNode> _attributeElements = null;
+    private Map<String, String> _accessedPrefixes = null;
 
     // True if all attributes of this LRE are unique, i.e. they all have
     // different names. This flag is set to false if some attribute
@@ -85,14 +86,13 @@
                 return result;
             }
         }
-        return _accessedPrefixes != null ?
-            (String) _accessedPrefixes.get(prefix) : null;
+        return _accessedPrefixes != null ? _accessedPrefixes.get(prefix) : null;
     }
 
     /**
      * Method used to keep track of what namespaces that are references by
      * this literal element and its attributes. The output must contain a
-     * definition for each namespace, so we stuff them in a hashtable.
+     * definition for each namespace, so we stuff them in a map.
      */
     public void registerNamespace(String prefix, String uri,
                                   SymbolTable stable, boolean declared) {
@@ -105,14 +105,14 @@
             }
         }
 
-        // Check if we have any declared namesaces
+        // Check if we have any declared namespaces
         if (_accessedPrefixes == null) {
-            _accessedPrefixes = new Hashtable();
+            _accessedPrefixes = new Hashtable<>();
         }
         else {
             if (!declared) {
                 // Check if this node has a declaration for this namespace
-                final String old = (String)_accessedPrefixes.get(prefix);
+                final String old = _accessedPrefixes.get(prefix);
                 if (old != null) {
                     if (old.equals(uri))
                         return;
@@ -169,7 +169,7 @@
      */
     public void addAttribute(SyntaxTreeNode attribute) {
         if (_attributeElements == null) {
-            _attributeElements = new Vector(2);
+            _attributeElements = new ArrayList<>(2);
         }
         _attributeElements.add(attribute);
     }
@@ -179,9 +179,9 @@
      */
     public void setFirstAttribute(SyntaxTreeNode attribute) {
         if (_attributeElements == null) {
-            _attributeElements = new Vector(2);
+            _attributeElements = new ArrayList<>(2);
         }
-        _attributeElements.insertElementAt(attribute,0);
+        _attributeElements.add(0, attribute);
     }
 
     /**
@@ -191,10 +191,7 @@
     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
         // Type-check all attributes
         if (_attributeElements != null) {
-            final int count = _attributeElements.size();
-            for (int i = 0; i < count; i++) {
-                SyntaxTreeNode node =
-                    (SyntaxTreeNode)_attributeElements.elementAt(i);
+            for (SyntaxTreeNode node : _attributeElements) {
                 node.typeCheck(stable);
             }
         }
@@ -207,15 +204,13 @@
      * and assembles a list of all prefixes that (for the given node) maps
      * to _ANY_ namespace URI. Used by literal result elements to determine
      */
-    public Enumeration getNamespaceScope(SyntaxTreeNode node) {
-        Hashtable all = new Hashtable();
+    public Set<Map.Entry<String, String>> getNamespaceScope(SyntaxTreeNode node) {
+        Map<String, String> all = new HashMap<>();
 
         while (node != null) {
-            Hashtable mapping = node.getPrefixMapping();
+            Map<String, String> mapping = node.getPrefixMapping();
             if (mapping != null) {
-                Enumeration prefixes = mapping.keys();
-                while (prefixes.hasMoreElements()) {
-                    String prefix = (String)prefixes.nextElement();
+                for( String prefix : mapping.keySet()) {
                     if (!all.containsKey(prefix)) {
                         all.put(prefix, mapping.get(prefix));
                     }
@@ -223,7 +218,7 @@
             }
             node = node.getParent();
         }
-        return(all.keys());
+        return all.entrySet();
     }
 
     /**
@@ -288,9 +283,9 @@
 
         // Register all namespaces that are in scope, except for those that
         // are listed in the xsl:stylesheet element's *-prefixes attributes
-        final Enumeration include = getNamespaceScope(this);
-        while (include.hasMoreElements()) {
-            final String prefix = (String)include.nextElement();
+        Set<Map.Entry<String, String>> include = getNamespaceScope(this);
+        for (Map.Entry<String, String> entry : include) {
+            final String prefix = entry.getKey();
             if (!prefix.equals("xml")) {
                 final String uri = lookupNamespace(prefix);
                 if (uri != null && !stable.isExcludedNamespace(uri)) {
@@ -356,11 +351,10 @@
         // Compile code to emit namespace attributes
         if (_accessedPrefixes != null) {
             boolean declaresDefaultNS = false;
-            Enumeration e = _accessedPrefixes.keys();
 
-            while (e.hasMoreElements()) {
-                final String prefix = (String)e.nextElement();
-                final String uri = (String)_accessedPrefixes.get(prefix);
+            for (Map.Entry<String, String> entry : _accessedPrefixes.entrySet()) {
+                final String prefix = entry.getKey();
+                final String uri = entry.getValue();
 
                 if (uri != Constants.EMPTYSTRING ||
                         prefix != Constants.EMPTYSTRING)
@@ -391,10 +385,7 @@
 
         // Output all attributes
         if (_attributeElements != null) {
-            final int count = _attributeElements.size();
-            for (int i = 0; i < count; i++) {
-                SyntaxTreeNode node =
-                    (SyntaxTreeNode)_attributeElements.elementAt(i);
+            for (SyntaxTreeNode node : _attributeElements) {
                 if (!(node instanceof XslAttribute)) {
                     node.translate(classGen, methodGen);
                 }
@@ -445,18 +436,18 @@
 
          if (_attributeElements != null) {
              int numAttrs = _attributeElements.size();
-             Hashtable attrsTable = null;
+             Map<String, SyntaxTreeNode> attrsTable = null;
              for (int i = 0; i < numAttrs; i++) {
-                 SyntaxTreeNode node = (SyntaxTreeNode)_attributeElements.elementAt(i);
+                 SyntaxTreeNode node = _attributeElements.get(i);
 
                  if (node instanceof UseAttributeSets) {
                      return false;
                  }
                  else if (node instanceof XslAttribute) {
                      if (attrsTable == null) {
-                        attrsTable = new Hashtable();
+                        attrsTable = new HashMap<>();
                          for (int k = 0; k < i; k++) {
-                             SyntaxTreeNode n = (SyntaxTreeNode)_attributeElements.elementAt(k);
+                             SyntaxTreeNode n = _attributeElements.get(k);
                              if (n instanceof LiteralAttribute) {
                                  LiteralAttribute literalAttr = (LiteralAttribute)n;
                                  attrsTable.put(literalAttr.getName(), literalAttr);
@@ -491,10 +482,8 @@
      * <xsl:attribute> children of the current node are not included in the check.
      */
     private boolean canProduceAttributeNodes(SyntaxTreeNode node, boolean ignoreXslAttribute) {
-        Vector contents = node.getContents();
-        int size = contents.size();
-        for (int i = 0; i < size; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
+        List<SyntaxTreeNode> contents = node.getContents();
+        for (SyntaxTreeNode child : contents) {
             if (child instanceof Text) {
                 Text text = (Text)child;
                 if (text.isIgnore())
@@ -532,10 +521,8 @@
                 return true;
             }
             else if (child instanceof Choose) {
-                Vector chooseContents = child.getContents();
-                int num = chooseContents.size();
-                for (int k = 0; k < num; k++) {
-                    SyntaxTreeNode chooseChild = (SyntaxTreeNode)chooseContents.elementAt(k);
+                List<SyntaxTreeNode> chooseContents = child.getContents();
+                for (SyntaxTreeNode chooseChild : chooseContents) {
                     if (chooseChild instanceof When || chooseChild instanceof Otherwise) {
                         if (canProduceAttributeNodes(chooseChild, false))
                             return true;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,12 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import com.sun.org.apache.bcel.internal.generic.Instruction;
 import com.sun.org.apache.bcel.internal.generic.BranchHandle;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.DUP;
@@ -38,6 +32,7 @@
 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.ISTORE;
+import com.sun.org.apache.bcel.internal.generic.Instruction;
 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
@@ -51,6 +46,12 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTM;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
 
 /**
  * Mode gathers all the templates belonging to a given mode;
@@ -128,22 +129,22 @@
     /**
      * A mapping between templates and test sequences.
      */
-    private Hashtable _neededTemplates = new Hashtable();
+    private Map<Template, Object> _neededTemplates = new HashMap<>();
 
     /**
      * A mapping between named templates and Mode objects.
      */
-    private Hashtable _namedTemplates = new Hashtable();
+    private Map<Template, Mode> _namedTemplates = new HashMap<>();
 
     /**
      * A mapping between templates and instruction handles.
      */
-    private Hashtable _templateIHs = new Hashtable();
+    private Map<Template, InstructionHandle> _templateIHs = new HashMap<>();
 
     /**
      * A mapping between templates and instruction lists.
      */
-    private Hashtable _templateILs = new Hashtable();
+    private Map<Template, InstructionList> _templateILs = new HashMap<>();
 
     /**
      * A reference to the pattern matching the root node.
@@ -152,14 +153,14 @@
 
     /**
      * Stores ranges of template precendences for the compilation
-     * of apply-imports (a Hashtable for historical reasons).
+     * of apply-imports.
      */
-    private Hashtable _importLevels = null;
+    private Map<Integer, Integer> _importLevels = null;
 
     /**
      * A mapping between key names and keys.
      */
-    private Hashtable _keys = null;
+    private Map<String, Key> _keys = null;
 
     /**
      * Variable index for the current node used in code generation.
@@ -195,9 +196,9 @@
 
     public String functionName(int min, int max) {
         if (_importLevels == null) {
-            _importLevels = new Hashtable();
+            _importLevels = new HashMap<>();
         }
-        _importLevels.put(new Integer(max), new Integer(min));
+        _importLevels.put(max, min);
         return _methodName + '_' + max;
     }
 
@@ -244,7 +245,7 @@
     /**
      * Process all the test patterns in this mode
      */
-    public void processPatterns(Hashtable keys) {
+    public void processPatterns(Map<String, Key> keys) {
         _keys = keys;
 
 /*
@@ -300,7 +301,7 @@
      */
     private void flattenAlternative(Pattern pattern,
                                     Template template,
-                                    Hashtable keys) {
+                                    Map<String, Key> keys) {
         // Patterns on type id() and key() are special since they do not have
         // any kernel node type (it can be anything as long as the node is in
         // the id's or key's index).
@@ -560,15 +561,13 @@
                                   MethodGenerator methodGen,
                                   InstructionHandle next)
     {
-        Enumeration templates = _namedTemplates.keys();
-        while (templates.hasMoreElements()) {
-            final Template template = (Template)templates.nextElement();
+        Set<Template> templates = _namedTemplates.keySet();
+        for (Template template : templates) {
             compileNamedTemplate(template, classGen);
         }
 
-        templates = _neededTemplates.keys();
-        while (templates.hasMoreElements()) {
-            final Template template = (Template)templates.nextElement();
+        templates = _neededTemplates.keySet();
+        for (Template template : templates) {
             if (template.hasContents()) {
                 // !!! TODO templates both named and matched
                 InstructionList til = template.compile(classGen, methodGen);
@@ -584,13 +583,12 @@
     }
 
     private void appendTemplateCode(InstructionList body) {
-        final Enumeration templates = _neededTemplates.keys();
-        while (templates.hasMoreElements()) {
-            final Object iList =
-                _templateILs.get(templates.nextElement());
+        for (Template template : _neededTemplates.keySet()) {
+            final InstructionList iList = _templateILs.get(template);
             if (iList != null) {
-                body.append((InstructionList)iList);
+                body.append(iList);
             }
+
         }
     }
 
@@ -1043,11 +1041,8 @@
 
         // Compile method(s) for <xsl:apply-imports/> for this mode
         if (_importLevels != null) {
-            Enumeration levels = _importLevels.keys();
-            while (levels.hasMoreElements()) {
-                Integer max = (Integer)levels.nextElement();
-                Integer min = (Integer)_importLevels.get(max);
-                compileApplyImports(classGen, min.intValue(), max.intValue());
+            for (Map.Entry<Integer, Integer> entry : _importLevels.entrySet()) {
+                compileApplyImports(classGen, entry.getValue(), entry.getKey());
             }
         }
     }
@@ -1055,9 +1050,7 @@
     private void compileTemplateCalls(ClassGenerator classGen,
                                       MethodGenerator methodGen,
                                       InstructionHandle next, int min, int max){
-        Enumeration templates = _neededTemplates.keys();
-        while (templates.hasMoreElements()) {
-            final Template template = (Template)templates.nextElement();
+        for (Template template : _neededTemplates.keySet()) {
             final int prec = template.getImportPrecedence();
             if ((prec >= min) && (prec < max)) {
                 if (template.hasContents()) {
@@ -1081,10 +1074,10 @@
         final Vector names      = xsltc.getNamesIndex();
 
         // Clear some datastructures
-        _namedTemplates = new Hashtable();
-        _neededTemplates = new Hashtable();
-        _templateIHs = new Hashtable();
-        _templateILs = new Hashtable();
+        _namedTemplates = new HashMap<>();
+        _neededTemplates = new HashMap<>();
+        _templateIHs = new HashMap<>();
+        _templateILs = new HashMap<>();
         _patternGroups = new Vector[32];
         _rootPattern = null;
 
@@ -1503,7 +1496,7 @@
     }
 
     public InstructionHandle getTemplateInstructionHandle(Template template) {
-        return (InstructionHandle)_templateIHs.get(template);
+        return _templateIHs.get(template);
     }
 
     /**
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -37,9 +37,10 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Stack;
 import java.util.StringTokenizer;
@@ -77,14 +78,14 @@
     private Vector _errors;           // Contains all compilation errors
     private Vector _warnings;         // Contains all compilation errors
 
-    private Hashtable   _instructionClasses; // Maps instructions to classes
-    private Hashtable   _instructionAttrs;;  // reqd and opt attrs
-    private Hashtable   _qNames;
-    private Hashtable   _namespaces;
+    private Map<String, String>   _instructionClasses; // Maps instructions to classes
+    private Map<String, String[]> _instructionAttrs;  // reqd and opt attrs
+    private Map<String, QName>   _qNames;
+    private Map<String, Map>     _namespaces;
     private QName       _useAttributeSets;
     private QName       _excludeResultPrefixes;
     private QName       _extensionElementPrefixes;
-    private Hashtable   _variableScope;
+    private Map<String, Object>   _variableScope;
     private Stylesheet  _currentStylesheet;
     private SymbolTable _symbolTable; // Maps QNames to syntax-tree nodes
     private Output      _output;
@@ -106,11 +107,11 @@
     }
 
     public void init() {
-        _qNames              = new Hashtable(512);
-        _namespaces          = new Hashtable();
-        _instructionClasses  = new Hashtable();
-        _instructionAttrs    = new Hashtable();
-        _variableScope       = new Hashtable();
+        _qNames              = new HashMap<>(512);
+        _namespaces          = new HashMap<>();
+        _instructionClasses  = new HashMap<>();
+        _instructionAttrs    = new HashMap<>();
+        _variableScope       = new HashMap<>();
         _template            = null;
         _errors              = new Vector();
         _warnings            = new Vector();
@@ -169,7 +170,7 @@
     }
 
     private void addVariableOrParam(VariableBase var) {
-        Object existing = _variableScope.get(var.getName());
+        Object existing = _variableScope.get(var.getName().getStringRep());
         if (existing != null) {
             if (existing instanceof Stack) {
                 Stack stack = (Stack)existing;
@@ -179,26 +180,26 @@
                 Stack stack = new Stack();
                 stack.push(existing);
                 stack.push(var);
-                _variableScope.put(var.getName(), stack);
+                _variableScope.put(var.getName().getStringRep(), stack);
             }
         }
         else {
-            _variableScope.put(var.getName(), var);
+            _variableScope.put(var.getName().getStringRep(), var);
         }
     }
 
     public void removeVariable(QName name) {
-        Object existing = _variableScope.get(name);
+        Object existing = _variableScope.get(name.getStringRep());
         if (existing instanceof Stack) {
             Stack stack = (Stack)existing;
             if (!stack.isEmpty()) stack.pop();
             if (!stack.isEmpty()) return;
         }
-        _variableScope.remove(name);
+        _variableScope.remove(name.getStringRep());
     }
 
     public VariableBase lookupVariable(QName name) {
-        Object existing = _variableScope.get(name);
+        Object existing = _variableScope.get(name.getStringRep());
         if (existing instanceof VariableBase) {
             return((VariableBase)existing);
         }
@@ -305,7 +306,7 @@
 
     public QName getQName(String namespace, String prefix, String localname) {
         if (namespace == null || namespace.equals(EMPTYSTRING)) {
-            QName name = (QName)_qNames.get(localname);
+            QName name = _qNames.get(localname);
             if (name == null) {
                 name = new QName(null, prefix, localname);
                 _qNames.put(localname, name);
@@ -313,7 +314,7 @@
             return name;
         }
         else {
-            Dictionary space = (Dictionary)_namespaces.get(namespace);
+            Map<String, QName> space = _namespaces.get(namespace);
             String lexicalQName =
                        (prefix == null || prefix.length() == 0)
                             ? localname
@@ -321,12 +322,12 @@
 
             if (space == null) {
                 final QName name = new QName(namespace, prefix, localname);
-                _namespaces.put(namespace, space = new Hashtable());
+                _namespaces.put(namespace, space = new HashMap<>());
                 space.put(lexicalQName, name);
                 return name;
             }
             else {
-                QName name = (QName)space.get(lexicalQName);
+                QName name = space.get(lexicalQName);
                 if (name == null) {
                     name = new QName(namespace, prefix, localname);
                     space.put(lexicalQName, name);
@@ -397,9 +398,9 @@
             if (stylesheet != null) {
                 stylesheet.parseContents(this);
                 final int precedence = stylesheet.getImportPrecedence();
-                final Enumeration elements = stylesheet.elements();
-                while (elements.hasMoreElements()) {
-                    Object child = elements.nextElement();
+                final Iterator<SyntaxTreeNode> elements = stylesheet.elements();
+                while (elements.hasNext()) {
+                    SyntaxTreeNode child = elements.next();
                     if (child instanceof Text) {
                         final int l = getLineNumber();
                         ErrorMsg err =
@@ -609,11 +610,11 @@
             String id = root.getAttribute("id");
             if (id.equals(href)) return root;
         }
-        Vector children = root.getContents();
+        List<SyntaxTreeNode> children = root.getContents();
         if (children != null) {
             final int count = children.size();
             for (int i = 0; i < count; i++) {
-                SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i);
+                SyntaxTreeNode child = children.get(i);
                 SyntaxTreeNode node = findStylesheet(child, href);
                 if (node != null) return node;
             }
@@ -640,7 +641,7 @@
     }
 
     private void initAttrTable(String elementName, String[] attrs) {
-        _instructionAttrs.put(getQName(XSLT_URI, XSL, elementName),
+        _instructionAttrs.put(getQName(XSLT_URI, XSL, elementName).getStringRep(),
                                 attrs);
     }
 
@@ -704,7 +705,7 @@
 
 
     /**
-     * Initialize the _instructionClasses Hashtable, which maps XSL element
+     * Initialize the _instructionClasses map, which maps XSL element
      * names to Java classes in this package.
      */
     private void initStdClasses() {
@@ -746,12 +747,12 @@
     }
 
     private void initStdClass(String elementName, String className) {
-        _instructionClasses.put(getQName(XSLT_URI, XSL, elementName),
+        _instructionClasses.put(getQName(XSLT_URI, XSL, elementName).getStringRep(),
                                 COMPILER_PACKAGE + '.' + className);
     }
 
     public boolean elementSupported(String namespace, String localName) {
-        return(_instructionClasses.get(getQName(namespace, XSL, localName)) != null);
+        return(_instructionClasses.get(getQName(namespace, XSL, localName).getStringRep()) != null);
     }
 
     public boolean functionSupported(String fname) {
@@ -764,12 +765,12 @@
     }
 
     private void initExtClass(String elementName, String className) {
-        _instructionClasses.put(getQName(TRANSLET_URI, TRANSLET, elementName),
+        _instructionClasses.put(getQName(TRANSLET_URI, TRANSLET, elementName).getStringRep(),
                                 COMPILER_PACKAGE + '.' + className);
     }
 
     private void initExtClass(String namespace, String elementName, String className) {
-        _instructionClasses.put(getQName(namespace, TRANSLET, elementName),
+        _instructionClasses.put(getQName(namespace, TRANSLET, elementName).getStringRep(),
                                 COMPILER_PACKAGE + '.' + className);
     }
 
@@ -969,7 +970,7 @@
     {
         SyntaxTreeNode node = null;
         QName  qname = getQName(uri, prefix, local);
-        String className = (String)_instructionClasses.get(qname);
+        String className = _instructionClasses.get(qname.getStringRep());
 
         if (className != null) {
             try {
@@ -1052,7 +1053,7 @@
     {
         QName qname = node.getQName();
         boolean isStylesheet = (node instanceof Stylesheet);
-        String[] legal = (String[]) _instructionAttrs.get(qname);
+        String[] legal = _instructionAttrs.get(qname.getStringRep());
         if (versionIsOne && legal != null) {
             int j;
             final int n = attrs.getLength();
@@ -1250,7 +1251,7 @@
     /************************ SAX2 ContentHandler INTERFACE *****************/
 
     private Stack _parentStack = null;
-    private Hashtable _prefixMapping = null;
+    private Map<String, String> _prefixMapping = null;
 
     /**
      * SAX2: Receive notification of the beginning of a document.
@@ -1274,7 +1275,7 @@
      */
     public void startPrefixMapping(String prefix, String uri) {
         if (_prefixMapping == null) {
-            _prefixMapping = new Hashtable();
+            _prefixMapping = new HashMap<>();
         }
         _prefixMapping.put(prefix, uri);
     }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,14 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
 import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
 import com.sun.org.apache.bcel.internal.generic.BasicType;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
@@ -59,6 +51,14 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
 import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
 
 /**
  * @author Jacek Ambroziak
@@ -121,7 +121,7 @@
     /**
      * Mapping between mode names and Mode instances.
      */
-    private final Hashtable _modes = new Hashtable();
+    private final Map<String, Mode> _modes = new HashMap<>();
 
     /**
      * A reference to the default Mode object.
@@ -131,7 +131,7 @@
     /**
      * Mapping between extension URIs and their prefixes.
      */
-    private final Hashtable _extensions = new Hashtable();
+    private final Map<String, String> _extensions = new HashMap<>();
 
     /**
      * Reference to the stylesheet from which this stylesheet was
@@ -164,7 +164,7 @@
     /**
      * Mapping between key names and Key objects (needed by Key/IdPattern).
      */
-    private Hashtable _keys = new Hashtable();
+    private Map<String, Key> _keys = new HashMap<>();
 
     /**
      * A reference to the SourceLoader set by the user (a URIResolver
@@ -323,9 +323,9 @@
         _importPrecedence = precedence;
 
         // Set import precedence for all included stylesheets
-        final Enumeration elements = elements();
-        while (elements.hasMoreElements()) {
-            SyntaxTreeNode child = (SyntaxTreeNode)elements.nextElement();
+        final Iterator<SyntaxTreeNode> elements = elements();
+        while (elements.hasNext()) {
+            SyntaxTreeNode child = elements.next();
             if (child instanceof Include) {
                 Stylesheet included = ((Include)child).getIncludedStylesheet();
                 if (included != null && included._includedFrom == this) {
@@ -573,13 +573,13 @@
         stable.excludeNamespaces(excludePrefixes);
         stable.excludeNamespaces(extensionPrefixes);
 
-        final Vector contents = getContents();
+        final List<SyntaxTreeNode> contents = getContents();
         final int count = contents.size();
 
         // We have to scan the stylesheet element's top-level elements for
         // variables and/or parameters before we parse the other elements
         for (int i = 0; i < count; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
+            SyntaxTreeNode child = contents.get(i);
             if ((child instanceof VariableBase) ||
                 (child instanceof NamespaceAlias)) {
                 parser.getSymbolTable().setCurrentNode(child);
@@ -589,7 +589,7 @@
 
         // Now go through all the other top-level elements...
         for (int i = 0; i < count; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
+            SyntaxTreeNode child = contents.get(i);
             if (!(child instanceof VariableBase) &&
                 !(child instanceof NamespaceAlias)) {
                 parser.getSymbolTable().setCurrentNode(child);
@@ -612,18 +612,14 @@
         if (_defaultMode == null)
             _defaultMode = new Mode(null, this, Constants.EMPTYSTRING);
         _defaultMode.processPatterns(_keys);
-        final Enumeration modes = _modes.elements();
-        while (modes.hasMoreElements()) {
-            final Mode mode = (Mode)modes.nextElement();
+        for (Mode mode : _modes.values()) {
             mode.processPatterns(_keys);
         }
     }
 
     private void compileModes(ClassGenerator classGen) {
         _defaultMode.compileApplyTemplates(classGen);
-        final Enumeration modes = _modes.elements();
-        while (modes.hasMoreElements()) {
-            final Mode mode = (Mode)modes.nextElement();
+        for (Mode mode : _modes.values()) {
             mode.compileApplyTemplates(classGen);
         }
     }
@@ -636,10 +632,10 @@
             return _defaultMode;
         }
         else {
-            Mode mode = (Mode)_modes.get(modeName);
+            Mode mode = _modes.get(modeName.getStringRep());
             if (mode == null) {
                 final String suffix = Integer.toString(_nextModeSerial++);
-                _modes.put(modeName, mode = new Mode(modeName, this, suffix));
+                _modes.put(modeName.getStringRep(), mode = new Mode(modeName, this, suffix));
             }
             return mode;
         }
@@ -707,9 +703,9 @@
         compileTransform(classGen);
 
         // Translate all non-template elements and filter out all templates
-        final Enumeration elements = elements();
-        while (elements.hasMoreElements()) {
-            Object element = elements.nextElement();
+        final Iterator<SyntaxTreeNode> elements = elements();
+        while (elements.hasNext()) {
+            SyntaxTreeNode element = elements.next();
             // xsl:template
             if (element instanceof Template) {
                 // Separate templates by modes
@@ -1054,9 +1050,9 @@
 
         // Create a new list containing variables/params + keys
         Vector varDepElements = new Vector(_globals);
-        Enumeration elements = elements();
-        while (elements.hasMoreElements()) {
-            final Object element = elements.nextElement();
+        Iterator<SyntaxTreeNode> elements = elements();
+        while (elements.hasNext()) {
+            SyntaxTreeNode element = elements.next();
             if (element instanceof Key) {
                 varDepElements.add(element);
             }
@@ -1079,8 +1075,8 @@
         // Compile code for other top-level elements
         Vector whitespaceRules = new Vector();
         elements = elements();
-        while (elements.hasMoreElements()) {
-            final Object element = elements.nextElement();
+        while (elements.hasNext()) {
+            SyntaxTreeNode element = elements.next();
             // xsl:decimal-format
             if (element instanceof DecimalFormatting) {
                 ((DecimalFormatting)element).translate(classGen,toplevel);
@@ -1198,10 +1194,10 @@
 
         buildKeys.addException("com.sun.org.apache.xalan.internal.xsltc.TransletException");
 
-        final Enumeration elements = elements();
-        while (elements.hasMoreElements()) {
+        final Iterator<SyntaxTreeNode> elements = elements();
+        while (elements.hasNext()) {
             // xsl:key
-            final Object element = elements.nextElement();
+            final SyntaxTreeNode element = elements.next();
             if (element instanceof Key) {
                 final Key key = (Key)element;
                 key.translate(classGen, buildKeys);
@@ -1325,8 +1321,8 @@
                                                "buildKeys", keySig);
 
         // Look for top-level elements that need handling
-        final Enumeration toplevel = elements();
-        if (_globals.size() > 0 || toplevel.hasMoreElements()) {
+        final Iterator<SyntaxTreeNode> toplevel = elements();
+        if (_globals.size() > 0 || toplevel.hasNext()) {
             // Compile method for handling top-level elements
             final String topLevelSig = compileTopLevel(classGen);
             // Get a reference to that method
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,13 +23,13 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Stack;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
-
 /**
  * @author Jacek Ambroziak
  * @author Santiago Pericas-Geertsen
@@ -37,67 +37,67 @@
  */
 final class SymbolTable {
 
-    // These hashtables are used for all stylesheets
-    private final Hashtable _stylesheets = new Hashtable();
-    private final Hashtable _primops     = new Hashtable();
+    // These maps are used for all stylesheets
+    private final Map<String, Stylesheet> _stylesheets = new HashMap<>();
+    private final Map<String, Vector> _primops     = new HashMap<>();
 
-    // These hashtables are used for some stylesheets
-    private Hashtable _variables = null;
-    private Hashtable _templates = null;
-    private Hashtable _attributeSets = null;
-    private Hashtable _aliases = null;
-    private Hashtable _excludedURI = null;
-    private Stack     _excludedURIStack = null;
-    private Hashtable _decimalFormats = null;
-    private Hashtable _keys = null;
+    // These maps are used for some stylesheets
+    private Map<String, VariableBase> _variables = null;
+    private Map<String, Template> _templates = null;
+    private Map<String, AttributeSet> _attributeSets = null;
+    private Map<String, String> _aliases = null;
+    private Map<String, Integer> _excludedURI = null;
+    private Stack<Map<String, Integer>>     _excludedURIStack = null;
+    private Map<String, DecimalFormatting> _decimalFormats = null;
+    private Map<String, Key> _keys = null;
 
     public DecimalFormatting getDecimalFormatting(QName name) {
         if (_decimalFormats == null) return null;
-        return((DecimalFormatting)_decimalFormats.get(name));
+        return(_decimalFormats.get(name.getStringRep()));
     }
 
     public void addDecimalFormatting(QName name, DecimalFormatting symbols) {
-        if (_decimalFormats == null) _decimalFormats = new Hashtable();
-        _decimalFormats.put(name, symbols);
+        if (_decimalFormats == null) _decimalFormats = new HashMap<>();
+        _decimalFormats.put(name.getStringRep(), symbols);
     }
 
     public Key getKey(QName name) {
         if (_keys == null) return null;
-        return (Key) _keys.get(name);
+        return _keys.get(name.getStringRep());
     }
 
     public void addKey(QName name, Key key) {
-        if (_keys == null) _keys = new Hashtable();
-        _keys.put(name, key);
+        if (_keys == null) _keys = new HashMap<>();
+        _keys.put(name.getStringRep(), key);
     }
 
     public Stylesheet addStylesheet(QName name, Stylesheet node) {
-        return (Stylesheet)_stylesheets.put(name, node);
+        return _stylesheets.put(name.getStringRep(), node);
     }
 
     public Stylesheet lookupStylesheet(QName name) {
-        return (Stylesheet)_stylesheets.get(name);
+        return _stylesheets.get(name.getStringRep());
     }
 
     public Template addTemplate(Template template) {
         final QName name = template.getName();
-        if (_templates == null) _templates = new Hashtable();
-        return (Template)_templates.put(name, template);
+        if (_templates == null) _templates = new HashMap<>();
+        return _templates.put(name.getStringRep(), template);
     }
 
     public Template lookupTemplate(QName name) {
         if (_templates == null) return null;
-        return (Template)_templates.get(name);
+        return _templates.get(name.getStringRep());
     }
 
     public Variable addVariable(Variable variable) {
-        if (_variables == null) _variables = new Hashtable();
+        if (_variables == null) _variables = new HashMap<>();
         final String name = variable.getName().getStringRep();
         return (Variable)_variables.put(name, variable);
     }
 
     public Param addParam(Param parameter) {
-        if (_variables == null) _variables = new Hashtable();
+        if (_variables == null) _variables = new HashMap<>();
         final String name = parameter.getName().getStringRep();
         return (Param)_variables.put(name, parameter);
     }
@@ -105,14 +105,14 @@
     public Variable lookupVariable(QName qname) {
         if (_variables == null) return null;
         final String name = qname.getStringRep();
-        final Object obj = _variables.get(name);
+        final VariableBase obj = _variables.get(name);
         return obj instanceof Variable ? (Variable)obj : null;
     }
 
     public Param lookupParam(QName qname) {
         if (_variables == null) return null;
         final String name = qname.getStringRep();
-        final Object obj = _variables.get(name);
+        final VariableBase obj = _variables.get(name);
         return obj instanceof Param ? (Param)obj : null;
     }
 
@@ -123,13 +123,13 @@
     }
 
     public AttributeSet addAttributeSet(AttributeSet atts) {
-        if (_attributeSets == null) _attributeSets = new Hashtable();
-        return (AttributeSet)_attributeSets.put(atts.getName(), atts);
+        if (_attributeSets == null) _attributeSets = new HashMap<>();
+        return _attributeSets.put(atts.getName().getStringRep(), atts);
     }
 
     public AttributeSet lookupAttributeSet(QName name) {
         if (_attributeSets == null) return null;
-        return (AttributeSet)_attributeSets.get(name);
+        return _attributeSets.get(name.getStringRep());
     }
 
     /**
@@ -138,7 +138,7 @@
      * is prepended.
      */
     public void addPrimop(String name, MethodType mtype) {
-        Vector methods = (Vector)_primops.get(name);
+        Vector methods = _primops.get(name);
         if (methods == null) {
             _primops.put(name, methods = new Vector());
         }
@@ -150,7 +150,7 @@
      * prepending the prefix <tt>PrimopPrefix</tt>.
      */
     public Vector lookupPrimop(String name) {
-        return (Vector)_primops.get(name);
+        return _primops.get(name);
     }
 
     /**
@@ -181,7 +181,7 @@
      * Adds an alias for a namespace prefix
      */
     public void addPrefixAlias(String prefix, String alias) {
-        if (_aliases == null) _aliases = new Hashtable();
+        if (_aliases == null) _aliases = new HashMap<>();
         _aliases.put(prefix,alias);
     }
 
@@ -190,7 +190,7 @@
      */
     public String lookupPrefixAlias(String prefix) {
         if (_aliases == null) return null;
-        return (String)_aliases.get(prefix);
+        return _aliases.get(prefix);
     }
 
     /**
@@ -201,15 +201,15 @@
         // The null-namespace cannot be excluded
         if (uri == null) return;
 
-        // Create new hashtable of exlcuded URIs if none exists
-        if (_excludedURI == null) _excludedURI = new Hashtable();
+        // Create a new map of exlcuded URIs if none exists
+        if (_excludedURI == null) _excludedURI = new HashMap<>();
 
         // Register the namespace URI
-        Integer refcnt = (Integer)_excludedURI.get(uri);
+        Integer refcnt = _excludedURI.get(uri);
         if (refcnt == null)
-            refcnt = new Integer(1);
+            refcnt = 1;
         else
-            refcnt = new Integer(refcnt.intValue() + 1);
+            refcnt = refcnt + 1;
         _excludedURI.put(uri,refcnt);
     }
 
@@ -237,8 +237,8 @@
      */
     public boolean isExcludedNamespace(String uri) {
         if (uri != null && _excludedURI != null) {
-            final Integer refcnt = (Integer)_excludedURI.get(uri);
-            return (refcnt != null && refcnt.intValue() > 0);
+            final Integer refcnt = _excludedURI.get(uri);
+            return (refcnt != null && refcnt > 0);
         }
         return false;
     }
@@ -257,9 +257,9 @@
                     uri = lookupNamespace(Constants.EMPTYSTRING);
                 else
                     uri = lookupNamespace(prefix);
-                Integer refcnt = (Integer)_excludedURI.get(uri);
+                Integer refcnt = _excludedURI.get(uri);
                 if (refcnt != null)
-                    _excludedURI.put(uri, new Integer(refcnt.intValue() - 1));
+                    _excludedURI.put(uri, refcnt - 1);
             }
         }
     }
@@ -286,7 +286,7 @@
      * the current stylesheet.
      */
     public void popExcludedNamespacesContext() {
-        _excludedURI = (Hashtable) _excludedURIStack.pop();
+        _excludedURI = _excludedURIStack.pop();
         if (_excludedURIStack.isEmpty()) {
             _excludedURIStack = null;
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,10 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
 import com.sun.org.apache.bcel.internal.generic.BasicType;
 import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
@@ -41,14 +37,18 @@
 import com.sun.org.apache.bcel.internal.generic.NEW;
 import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
+import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
-import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
-
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import org.xml.sax.Attributes;
 import org.xml.sax.helpers.AttributesImpl;
 
@@ -70,13 +70,13 @@
     protected SyntaxTreeNode _parent;          // Parent node
     private Stylesheet       _stylesheet;      // Stylesheet ancestor node
     private Template         _template;        // Template ancestor node
-    private final Vector _contents = new Vector(2); // Child nodes
+    private final List<SyntaxTreeNode> _contents = new ArrayList<>(2); // Child nodes
 
     // Element description data
     protected QName _qname;                    // The element QName
     private int _line;                         // Source file line number
     protected AttributesImpl _attributes = null;   // Attributes of this element
-    private   Hashtable _prefixMapping = null; // Namespace declarations
+    private   Map<String, String> _prefixMapping = null; // Namespace declarations
 
     // Sentinel - used to denote unrecognised syntaxt tree nodes.
     protected static final SyntaxTreeNode Dummy = new AbsolutePathPattern(null);
@@ -217,22 +217,22 @@
      * Sets the prefix mapping for the namespaces that were declared in this
      * element. This does not include all prefix mappings in scope, so one
      * may have to check ancestor elements to get all mappings that are in
-     * in scope. The prefixes must be passed in as a Hashtable that maps
+     * in scope. The prefixes must be passed in as a Map that maps
      * namespace prefixes (String objects) to namespace URIs (also String).
-     * @param mapping The Hashtable containing the mappings.
+     * @param mapping The Map containing the mappings.
      */
-    protected void setPrefixMapping(Hashtable mapping) {
+    protected void setPrefixMapping(Map<String, String> mapping) {
         _prefixMapping = mapping;
     }
 
     /**
-     * Returns a Hashtable containing the prefix mappings that were declared
+     * Returns a Map containing the prefix mappings that were declared
      * for this element. This does not include all prefix mappings in scope,
      * so one may have to check ancestor elements to get all mappings that are
      * in in scope.
      * @return Prefix mappings (for this element only).
      */
-    protected Hashtable getPrefixMapping() {
+    protected Map<String, String> getPrefixMapping() {
         return _prefixMapping;
     }
 
@@ -243,7 +243,7 @@
      */
     protected void addPrefixMapping(String prefix, String uri) {
         if (_prefixMapping == null)
-            _prefixMapping = new Hashtable();
+            _prefixMapping = new HashMap<>();
         _prefixMapping.put(prefix, uri);
     }
 
@@ -259,9 +259,9 @@
         // Initialise the output (default is 'null' for undefined)
         String uri = null;
 
-        // First look up the prefix/uri mapping in our own hashtable...
+        // First look up the prefix/uri mapping in our own map...
         if (_prefixMapping != null)
-            uri = (String)_prefixMapping.get(prefix);
+            uri = _prefixMapping.get(prefix);
         // ... but if we can't find it there we ask our parent for the mapping
         if ((uri == null) && (_parent != null)) {
             uri = _parent.lookupNamespace(prefix);
@@ -286,13 +286,12 @@
         // Initialise the output (default is 'null' for undefined)
         String prefix = null;
 
-        // First look up the prefix/uri mapping in our own hashtable...
+        // First look up the prefix/uri mapping in our own map...
         if ((_prefixMapping != null) &&
-            (_prefixMapping.contains(uri))) {
-            Enumeration prefixes = _prefixMapping.keys();
-            while (prefixes.hasMoreElements()) {
-                prefix = (String)prefixes.nextElement();
-                String mapsTo = (String)_prefixMapping.get(prefix);
+            (_prefixMapping.containsValue(uri))) {
+            for (Map.Entry<String, String> entry : _prefixMapping.entrySet()) {
+                prefix = entry.getKey();
+                String mapsTo = entry.getValue();
                 if (mapsTo.equals(uri)) return(prefix);
             }
         }
@@ -427,20 +426,18 @@
      */
     protected final void parseChildren(Parser parser) {
 
-        Vector locals = null;   // only create when needed
+        List<QName> locals = null;   // only create when needed
 
-        final int count = _contents.size();
-        for (int i=0; i<count; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)_contents.elementAt(i);
+        for (SyntaxTreeNode child : _contents) {
             parser.getSymbolTable().setCurrentNode(child);
             child.parseContents(parser);
             // if variable or parameter, add it to scope
             final QName varOrParamName = updateScope(parser, child);
             if (varOrParamName != null) {
                 if (locals == null) {
-                    locals = new Vector(2);
+                    locals = new ArrayList<>(2);
                 }
-                locals.addElement(varOrParamName);
+                locals.add(varOrParamName);
             }
         }
 
@@ -448,9 +445,8 @@
 
         // after the last element, remove any locals from scope
         if (locals != null) {
-            final int nLocals = locals.size();
-            for (int i = 0; i < nLocals; i++) {
-                parser.removeVariable((QName)locals.elementAt(i));
+            for (QName varOrParamName : locals) {
+                parser.removeVariable(varOrParamName);
             }
         }
     }
@@ -487,9 +483,7 @@
      * @param stable The compiler/parser's symbol table
      */
     protected Type typeCheckContents(SymbolTable stable) throws TypeCheckError {
-        final int n = elementCount();
-        for (int i = 0; i < n; i++) {
-            SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
+        for (SyntaxTreeNode item : _contents) {
             item.typeCheck(stable);
         }
         return Type.Void;
@@ -513,9 +507,8 @@
         // Call translate() on all child nodes
         final int n = elementCount();
 
-        for (int i = 0; i < n; i++) {
+        for (SyntaxTreeNode item : _contents) {
             methodGen.markChunkStart();
-            final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
             item.translate(classGen, methodGen);
             methodGen.markChunkEnd();
         }
@@ -526,8 +519,8 @@
         // references falling out-of-scope inside the for-each element.
         // (the cause of which being 'lazy' register allocation for references)
         for (int i = 0; i < n; i++) {
-            if( _contents.elementAt(i) instanceof VariableBase) {
-                final VariableBase var = (VariableBase)_contents.elementAt(i);
+            if( _contents.get(i) instanceof VariableBase) {
+                final VariableBase var = (VariableBase)_contents.get(i);
                 var.unmapRegister(methodGen);
             }
         }
@@ -543,9 +536,8 @@
      */
     private boolean isSimpleRTF(SyntaxTreeNode node) {
 
-        Vector contents = node.getContents();
-        for (int i = 0; i < contents.size(); i++) {
-            SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
+        List<SyntaxTreeNode> contents = node.getContents();
+        for (SyntaxTreeNode item : contents) {
             if (!isTextElement(item, false))
                 return false;
         }
@@ -564,9 +556,8 @@
      */
     private boolean isAdaptiveRTF(SyntaxTreeNode node) {
 
-        Vector contents = node.getContents();
-        for (int i = 0; i < contents.size(); i++) {
-            SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
+        List<SyntaxTreeNode> contents = node.getContents();
+        for (SyntaxTreeNode item : contents) {
             if (!isTextElement(item, true))
                 return false;
         }
@@ -600,9 +591,8 @@
             return doExtendedCheck ? isAdaptiveRTF(node) : isSimpleRTF(node);
         }
         else if (node instanceof Choose) {
-            Vector contents = node.getContents();
-            for (int i = 0; i < contents.size(); i++) {
-                SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
+            List<SyntaxTreeNode> contents = node.getContents();
+            for (SyntaxTreeNode item : contents) {
                 if (item instanceof Text ||
                      ((item instanceof When || item instanceof Otherwise)
                      && ((doExtendedCheck && isAdaptiveRTF(item))
@@ -769,9 +759,7 @@
      * @return 'true' if the contents of this node is context dependent.
      */
     protected boolean dependentContents() {
-        final int n = elementCount();
-        for (int i = 0; i < n; i++) {
-            final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
+        for (SyntaxTreeNode item : _contents) {
             if (item.contextDependent()) {
                 return true;
             }
@@ -784,7 +772,7 @@
      * @param element is the new child node.
      */
     protected final void addElement(SyntaxTreeNode element) {
-        _contents.addElement(element);
+        _contents.add(element);
         element.setParent(this);
     }
 
@@ -794,7 +782,7 @@
      * @param element is the new child node.
      */
     protected final void setFirstElement(SyntaxTreeNode element) {
-        _contents.insertElementAt(element,0);
+        _contents.add(0, element);
         element.setParent(this);
     }
 
@@ -808,10 +796,10 @@
     }
 
     /**
-     * Returns a Vector containing all the child nodes of this node.
-     * @return A Vector containing all the child nodes of this node.
+     * Returns a List containing all the child nodes of this node.
+     * @return A List containing all the child nodes of this node.
      */
-    protected final Vector getContents() {
+    protected final List<SyntaxTreeNode> getContents() {
         return _contents;
     }
 
@@ -832,11 +820,11 @@
     }
 
     /**
-     * Returns an Enumeration of all child nodes of this node.
-     * @return An Enumeration of all child nodes of this node.
+     * Returns an Iterator of all child nodes of this node.
+     * @return An Iterator of all child nodes of this node.
      */
-    protected final Enumeration elements() {
-        return _contents.elements();
+    protected final Iterator<SyntaxTreeNode> elements() {
+        return _contents.iterator();
     }
 
     /**
@@ -845,7 +833,7 @@
      * @return The child node.
      */
     protected final Object elementAt(int pos) {
-        return _contents.elementAt(pos);
+        return _contents.get(pos);
     }
 
     /**
@@ -853,8 +841,8 @@
      * @return The child node.
      */
     protected final SyntaxTreeNode lastChild() {
-        if (_contents.size() == 0) return null;
-        return (SyntaxTreeNode)_contents.lastElement();
+        if (_contents.isEmpty()) return null;
+        return _contents.get(_contents.size() - 1);
     }
 
     /**
@@ -873,9 +861,7 @@
      * @param indent Indentation level for syntax tree levels.
      */
     protected void displayContents(int indent) {
-        final int n = elementCount();
-        for (int i = 0; i < n; i++) {
-            SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
+        for (SyntaxTreeNode item : _contents) {
             item.display(indent);
         }
     }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,11 +23,8 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
-import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
@@ -37,6 +34,8 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
+import java.util.List;
+import java.util.Vector;
 
 
 /**
@@ -274,8 +273,8 @@
         _priority = Double.NaN;
         _pattern = parser.parsePattern(this, "/");
 
-        final Vector contents = _stylesheet.getContents();
-        final SyntaxTreeNode root = (SyntaxTreeNode)contents.elementAt(0);
+        final List<SyntaxTreeNode> contents = _stylesheet.getContents();
+        final SyntaxTreeNode root = contents.get(0);
 
         if (root instanceof LiteralElement) {
             addElement(root);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,14 +23,13 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Dictionary;
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.GOTO_W;
 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
+import java.util.Map;
+import java.util.Vector;
 
 /**
  * A test sequence is a sequence of patterns that
@@ -179,7 +178,7 @@
      * this test sequence. Note that a single template can occur
      * in several test sequences if its pattern is a union.
      */
-    public void findTemplates(Dictionary templates) {
+    public void findTemplates(Map<Template, Object> templates) {
         if (_default != null) {
             templates.put(_default, this);
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/UnsupportedElement.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/UnsupportedElement.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,19 +23,18 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
-
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
+import java.util.List;
+import java.util.Vector;
 
 /**
  * @author Morten Jorgensen
@@ -83,11 +82,11 @@
      */
     private void processFallbacks(Parser parser) {
 
-        Vector children = getContents();
+        List<SyntaxTreeNode> children = getContents();
         if (children != null) {
             final int count = children.size();
             for (int i = 0; i < count; i++) {
-                SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i);
+                SyntaxTreeNode child = children.get(i);
                 if (child instanceof Fallback) {
                     Fallback fallback = (Fallback)child;
                     fallback.activate();
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -39,13 +39,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Vector;
@@ -90,14 +87,14 @@
     // Name index tables
     private int       _nextGType;  // Next available element type
     private Vector    _namesIndex; // Index of all registered QNames
-    private Hashtable _elements;   // Hashtable of all registered elements
-    private Hashtable _attributes; // Hashtable of all registered attributes
+    private Map<String, Integer> _elements;   // Map of all registered elements
+    private Map<String, Integer> _attributes; // Map of all registered attributes
 
     // Namespace index tables
     private int       _nextNSType; // Next available namespace type
     private Vector    _namespaceIndex; // Index of all registered namespaces
-    private Hashtable _namespaces; // Hashtable of all registered namespaces
-    private Hashtable _namespacePrefixes;// Hashtable of all registered namespace prefixes
+    private Map<String, Integer> _namespaces; // Map of all registered namespaces
+    private Map<String, Integer> _namespacePrefixes;// Map of all registered namespace prefixes
 
 
     // All literal text in the stylesheet
@@ -319,13 +316,13 @@
      */
     private void reset() {
         _nextGType      = DTM.NTYPES;
-        _elements       = new Hashtable();
-        _attributes     = new Hashtable();
-        _namespaces     = new Hashtable();
+        _elements       = new HashMap<>();
+        _attributes     = new HashMap<>();
+        _namespaces     = new HashMap<>();
         _namespaces.put("",new Integer(_nextNSType));
         _namesIndex     = new Vector(128);
         _namespaceIndex = new Vector(32);
-        _namespacePrefixes = new Hashtable();
+        _namespacePrefixes = new HashMap<>();
         _stylesheet     = null;
         _parser.init();
         //_variableSerial     = 1;
@@ -765,9 +762,9 @@
      * DOM attribute types at run-time.
      */
     public int registerAttribute(QName name) {
-        Integer code = (Integer)_attributes.get(name.toString());
+        Integer code = _attributes.get(name.toString());
         if (code == null) {
-            code = new Integer(_nextGType++);
+            code = _nextGType++;
             _attributes.put(name.toString(), code);
             final String uri = name.getNamespace();
             final String local = "@"+name.getLocalPart();
@@ -788,9 +785,9 @@
      */
     public int registerElement(QName name) {
         // Register element (full QName)
-        Integer code = (Integer)_elements.get(name.toString());
+        Integer code = _elements.get(name.toString());
         if (code == null) {
-            _elements.put(name.toString(), code = new Integer(_nextGType++));
+            _elements.put(name.toString(), code = _nextGType++);
             _namesIndex.addElement(name.toString());
         }
         if (name.getLocalPart().equals("*")) {
@@ -806,9 +803,9 @@
 
     public int registerNamespacePrefix(QName name) {
 
-    Integer code = (Integer)_namespacePrefixes.get(name.toString());
+    Integer code = _namespacePrefixes.get(name.toString());
     if (code == null) {
-        code = new Integer(_nextGType++);
+        code = _nextGType++;
         _namespacePrefixes.put(name.toString(), code);
         final String uri = name.getNamespace();
         if ((uri != null) && (!uri.equals(""))){
@@ -826,9 +823,9 @@
      * DOM namespace types at run-time.
      */
     public int registerNamespace(String namespaceURI) {
-        Integer code = (Integer)_namespaces.get(namespaceURI);
+        Integer code = _namespaces.get(namespaceURI);
         if (code == null) {
-            code = new Integer(_nextNSType++);
+            code = _nextNSType++;
             _namespaces.put(namespaceURI,code);
             _namespaceIndex.addElement(namespaceURI);
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslAttribute.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslAttribute.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,8 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.util.Vector;
-
 import com.sun.org.apache.bcel.internal.generic.ALOAD;
 import com.sun.org.apache.bcel.internal.generic.ASTORE;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
@@ -40,10 +38,10 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
-
 import com.sun.org.apache.xml.internal.serializer.ElemDesc;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
+import java.util.List;
 
 /**
  * @author Jacek Ambroziak
@@ -103,9 +101,9 @@
 
         // Ignore attribute if preceeded by some other type of element
         final SyntaxTreeNode parent = getParent();
-        final Vector siblings = parent.getContents();
+        final List<SyntaxTreeNode> siblings = parent.getContents();
         for (int i = 0; i < parent.elementCount(); i++) {
-            SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i);
+            SyntaxTreeNode item = siblings.get(i);
             if (item == this) break;
 
             // These three objects result in one or more attribute output
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -26,7 +26,6 @@
 import com.sun.org.apache.bcel.internal.generic.ALOAD;
 import com.sun.org.apache.bcel.internal.generic.ASTORE;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
-import com.sun.org.apache.bcel.internal.generic.ICONST;
 import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
@@ -285,8 +284,7 @@
                                   MethodGenerator methodGen) {
         final int n = elementCount();
         for (int i = 0; i < n; i++) {
-            final SyntaxTreeNode item =
-                (SyntaxTreeNode)getContents().elementAt(i);
+            final SyntaxTreeNode item = getContents().get(i);
             if (_ignore && item instanceof XslAttribute) continue;
             item.translate(classGen, methodGen);
         }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ko.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ko.java	Wed Sep 07 06:06:32 2016 +0100
@@ -303,7 +303,7 @@
          * not recognized.
          */
         {ErrorMsg.ILLEGAL_BINARY_OP_ERR,
-        "\uC774\uC9C4 \uD45C\uD604\uC2DD\uC5D0 \uB300\uD574 \uC54C \uC218 \uC5C6\uB294 \uC5F0\uC0B0\uC790\uC785\uB2C8\uB2E4."},
+        "\uBC14\uC774\uB108\uB9AC \uD45C\uD604\uC2DD\uC5D0 \uB300\uD574 \uC54C \uC218 \uC5C6\uB294 \uC5F0\uC0B0\uC790\uC785\uB2C8\uB2E4."},
 
         /*
          * Note to translators:  This message is produced if a reference to a
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java	Wed Sep 07 06:06:32 2016 +0100
@@ -685,7 +685,7 @@
          * documentation.
          */
         {ErrorMsg.COMPILE_USAGE_STR,
-        "\u6982\u8981\n   java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile [-o <output>]\n      [-d <directory>] [-j <jarfile>] [-p <package>]\n      [-n] [-x] [-u] [-v] [-h] { <stylesheet> | -i }\n\n\u9078\u9805\n   -o <output>    \u6307\u6D3E\u540D\u7A31 <output> \u81F3\u7522\u751F\u7684\n                  translet\u3002\u6839\u64DA\u9810\u8A2D\uFF0Ctranslet \u540D\u7A31\n                  \u884D\u751F\u81EA <stylesheet> \u540D\u7A31\u3002  \u82E5\u7DE8\u8B6F\n                  \u591A\u500B\u6A23\u5F0F\u8868\uFF0C\u5C07\u5FFD\u7565\u6B64\u9078\u9805\u3002\n   -d <directory> \u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304\n   -j <jarfile>   \u5C01\u88DD translet \u985E\u5225\u6210\u70BA jar \u6A94\u6848\uFF0C\n                  \u540D\u7A31\u6307\u5B9A\u70BA <jarfile>\n   -p <package>   \u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\n                  \u540D\u7A31\u524D\u7F6E\u78BC\u3002\n   -n             \u555F\u7528\u6A23\u677F\u5167\u5D4C (\u9810\u8A2D\u884C\u70BA\u4E00\u822C\u800C\u8A00\n                  \u8F03\u4F73)\u3002\n   -x             \u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA\n   -u             \u89E3\u8B6F <stylesheet> \u5F15\u6578\u70BA URL\n   -i             \u5F37\u5236\u7DE8\u8B6F\u5668\u5F9E stdin \u8B80\u53D6\u6A23\u5F0F\u8868\n   -v             \u5217\u5370\u7DE8\u8B6F\u5668\u7248\u672C\n   -h             \u5217\u5370\u6B64\u7528\u6CD5\u6558\u8FF0\n"},
+        "\u6982\u8981\n   java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile [-o <output>]\n      [-d <directory>] [-j <jarfile>] [-p <package>]\n      [-n] [-x] [-u] [-v] [-h] { <stylesheet> | -i }\n\n\u9078\u9805\n   -o <output>    \u6307\u6D3E\u540D\u7A31 <output> \u81F3\u7522\u751F\u7684\n                  translet\u3002\u6839\u64DA\u9810\u8A2D\uFF0Ctranslet \u540D\u7A31\n                  \u884D\u751F\u81EA <stylesheet> \u540D\u7A31\u3002\u82E5\u7DE8\u8B6F\n                  \u591A\u500B\u6A23\u5F0F\u8868\uFF0C\u5C07\u5FFD\u7565\u6B64\u9078\u9805\u3002\n   -d <directory> \u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304\n   -j <jarfile>   \u5C01\u88DD translet \u985E\u5225\u6210\u70BA jar \u6A94\u6848\uFF0C\n                  \u540D\u7A31\u6307\u5B9A\u70BA <jarfile>\n   -p <package>   \u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\n                  \u540D\u7A31\u524D\u7F6E\u78BC\u3002\n   -n             \u555F\u7528\u6A23\u677F\u5167\u5D4C (\u9810\u8A2D\u884C\u70BA\u4E00\u822C\u800C\u8A00\n                  \u8F03\u4F73)\u3002\n   -x             \u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA\n   -u             \u89E3\u8B6F <stylesheet> \u5F15\u6578\u70BA URL\n   -i             \u5F37\u5236\u7DE8\u8B6F\u5668\u5F9E stdin \u8B80\u53D6\u6A23\u5F0F\u8868\n   -v             \u5217\u5370\u7DE8\u8B6F\u5668\u7248\u672C\n   -h             \u5217\u5370\u6B64\u7528\u6CD5\u6558\u8FF0\n"},
 
         /*
          * Note to translators:  This message contains usage information for a
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,15 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
- import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Stack;
-
-
 import com.sun.org.apache.bcel.internal.Constants;
 import com.sun.org.apache.bcel.internal.classfile.Field;
 import com.sun.org.apache.bcel.internal.classfile.Method;
@@ -47,23 +38,23 @@
 import com.sun.org.apache.bcel.internal.generic.GETFIELD;
 import com.sun.org.apache.bcel.internal.generic.GOTO;
 import com.sun.org.apache.bcel.internal.generic.ICONST;
-import com.sun.org.apache.bcel.internal.generic.IfInstruction;
 import com.sun.org.apache.bcel.internal.generic.ILOAD;
-import com.sun.org.apache.bcel.internal.generic.IndexedInstruction;
 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
 import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.ISTORE;
+import com.sun.org.apache.bcel.internal.generic.IfInstruction;
+import com.sun.org.apache.bcel.internal.generic.IndexedInstruction;
 import com.sun.org.apache.bcel.internal.generic.Instruction;
 import com.sun.org.apache.bcel.internal.generic.InstructionConstants;
 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.InstructionTargeter;
+import com.sun.org.apache.bcel.internal.generic.LLOAD;
+import com.sun.org.apache.bcel.internal.generic.LSTORE;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction;
-import com.sun.org.apache.bcel.internal.generic.LLOAD;
-import com.sun.org.apache.bcel.internal.generic.LSTORE;
 import com.sun.org.apache.bcel.internal.generic.MethodGen;
 import com.sun.org.apache.bcel.internal.generic.NEW;
 import com.sun.org.apache.bcel.internal.generic.PUTFIELD;
@@ -71,9 +62,14 @@
 import com.sun.org.apache.bcel.internal.generic.Select;
 import com.sun.org.apache.bcel.internal.generic.TargetLostException;
 import com.sun.org.apache.bcel.internal.generic.Type;
-
 import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Stack;
 
 /**
  * @author Jacek Ambroziak
@@ -131,7 +127,7 @@
                  * times. Note that patterns whose kernels are "*", "node()"
                  * and "@*" can between shared by test sequences.
                  */
-        private Hashtable _preCompiled = new Hashtable();
+        private Map<Pattern, InstructionList> _preCompiled = new HashMap<>();
 
 
     public MethodGenerator(int access_flags, Type return_type,
@@ -715,7 +711,7 @@
      * test sequences to avoid compiling patterns more than once.
      */
     public InstructionList getInstructionList(Pattern pattern) {
-        return (InstructionList) _preCompiled.get(pattern);
+        return _preCompiled.get(pattern);
     }
 
     /**
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MultiHashtable.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MultiHashtable.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -23,35 +23,72 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
 
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Jacek Ambroziak
  * @author Santiago Pericas-Geertsen
+ * @param <K>
+ * @param <V>
  */
-public final class MultiHashtable extends Hashtable {
+public final class MultiHashtable<K,V> {
     static final long serialVersionUID = -6151608290510033572L;
-    public Object put(Object key, Object value) {
-        Vector vector = (Vector)get(key);
-        if (vector == null)
-            super.put(key, vector = new Vector());
-        vector.add(value);
-        return vector;
+
+    private final Map<K, Set<V>> map = new HashMap<>();
+    private boolean modifiable = true;
+
+    /**
+     * Associates the specified key with a set of values. If the map previously
+     * contained a mapping for the key, the value is added to the set.
+     * @param key key with which the specified value is to be associated
+     * @param value value to be added to a set that is associated with the specified key
+     * @return the set that is associated with the specified key.
+     * @throw UnsupportedOperationException is the MultiHashtable is not modifiable.
+     */
+    public Set<V> put(K key, V value) {
+        if (modifiable) {
+            Set<V> set = map.get(key);
+            if (set == null) {
+                set = new HashSet<>();
+                map.put(key, set);
+            }
+            set.add(value);
+            return set;
+        }
+        throw new UnsupportedOperationException("The MultiHashtable instance is not modifiable.");
     }
 
-    public Object maps(Object from, Object to) {
-        if (from == null) return null;
-        final Vector vector = (Vector) get(from);
-        if (vector != null) {
-            final int n = vector.size();
-            for (int i = 0; i < n; i++) {
-                final Object item = vector.elementAt(i);
-                if (item.equals(to)) {
-                    return item;
+    /**
+     * Maps a key to a value in a set that is associated with the specified key.
+     * The mapping is performed by evaluating whether an item in the set equals
+     * the specified value.
+     *
+     * @param key key with which the specified value is to be associated
+     * @param value value in a set that is associated with the specified key
+     * @return the item in the set if a match is found.
+     */
+    public V maps(K key, V value) {
+        if (key == null) return null;
+        final Set<V> set = map.get(key);
+        if (set != null) {
+            for (V v : set) {
+                if (v.equals(value)) {
+                    return v;
                 }
             }
         }
         return null;
     }
+
+    /**
+     * Makes the MultiHashtable unmodifiable.  This method allows modules to set the table
+     * as "read-only" so that only query operation, that is maps, is allowed. Any attempts
+     * to modify the returned map result in an UnsupportedOperationException.
+     */
+    public void makeUnmodifiable() {
+        modifiable = false;
+    }
 }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,18 +23,15 @@
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
+import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
-import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
-
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
 import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xml.internal.utils.XMLString;
-
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-
+import java.util.Map;
 import javax.xml.transform.SourceLocator;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -556,7 +553,7 @@
         }
     }
 
-    public Hashtable getElementsWithIDs()
+    public Map<String, Integer> getElementsWithIDs()
     {
         if (_dom != null) {
             return _dom.getElementsWithIDs();
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -27,11 +27,10 @@
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-
+import java.util.Map;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -462,7 +461,7 @@
         return _dom.getUnparsedEntityURI(entity);
     }
 
-    public Hashtable getElementsWithIDs() {
+    public Map<String, Integer> getElementsWithIDs() {
         return _dom.getElementsWithIDs();
     }
 }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMWSFilter.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMWSFilter.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -26,9 +26,10 @@
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * A wrapper class that adapts the
@@ -40,8 +41,8 @@
     private AbstractTranslet m_translet;
     private StripFilter m_filter;
 
-    // The Hashtable for DTM to mapping array
-    private Hashtable m_mappings;
+    // The Map for DTM to mapping array
+    private Map<DTM, short[]> m_mappings;
 
     // Cache the DTM and mapping that are used last time
     private DTM m_currentDTM;
@@ -59,7 +60,7 @@
      */
     public DOMWSFilter(AbstractTranslet translet) {
         m_translet = translet;
-        m_mappings = new Hashtable();
+        m_mappings = new HashMap<>();
 
         if (translet instanceof StripFilter) {
             m_filter = (StripFilter) translet;
@@ -91,7 +92,7 @@
                     mapping = m_currentMapping;
                 }
                 else {
-                    mapping = (short[])m_mappings.get(dtm);
+                    mapping = m_mappings.get(dtm);
                     if (mapping == null) {
                         mapping = mappableDOM.getMapping(
                                      m_translet.getNamesArray(),
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,20 +23,6 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
-import java.io.File;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.util.Date;
-import java.util.Hashtable;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.sax.SAXSource;
-
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
@@ -45,7 +31,19 @@
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
-
+import java.io.File;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXSource;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
@@ -56,7 +54,7 @@
 public final class DocumentCache implements DOMCache {
 
     private int       _size;
-    private Hashtable _references;
+    private Map<String, CachedDocument> _references;
     private String[]  _URIs;
     private int       _count;
     private int       _current;
@@ -171,7 +169,7 @@
         _count = 0;
         _current = 0;
         _size  = size;
-        _references = new Hashtable(_size+2);
+        _references = new HashMap<>(_size+2);
         _URIs = new String[_size];
 
         try {
@@ -218,7 +216,7 @@
      *
      */
     private CachedDocument lookupDocument(String uri) {
-        return((CachedDocument)_references.get(uri));
+        return(_references.get(uri));
     }
 
     /**
@@ -231,7 +229,7 @@
             _current = 0;
         }
         else {
-            // Remove oldest URI from reference Hashtable
+            // Remove oldest URI from reference map
             _references.remove(_URIs[_current]);
             // Insert our URI in circular buffer
             _URIs[_current] = uri;
@@ -244,7 +242,6 @@
      *
      */
     private synchronized void replaceDocument(String uri, CachedDocument doc) {
-        CachedDocument old = (CachedDocument)_references.get(uri);
         if (doc == null)
             insertDocument(uri, doc);
         else
@@ -324,7 +321,7 @@
                     "<td><center><b>Last modified</b></center></td></tr>");
 
         for (int i=0; i<_count; i++) {
-            CachedDocument doc = (CachedDocument)_references.get(_URIs[i]);
+            CachedDocument doc = _references.get(_URIs[i]);
             out.print("<tr><td><a href=\""+_URIs[i]+"\">"+
                       "<font size=-1>"+_URIs[i]+"</font></a></td>");
             out.print("<td><center>"+doc.getLatency()+"ms</center></td>");
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2006 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,18 +23,17 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
-import java.util.StringTokenizer;
-
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import com.sun.org.apache.xalan.internal.xsltc.util.IntegerArray;
-
 import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
 
 /**
  * Stores mappings of key values or IDs to DTM nodes.
@@ -49,7 +48,7 @@
      * A mapping between values and nodesets for the current document.  Used
      * only while building keys.
      */
-    private Hashtable _index;
+    private Map<String, IntegerArray> _index;
 
     /**
      * The document node currently being processed.  Used only while building
@@ -60,7 +59,7 @@
     /**
      * A mapping from a document node to the mapping between values and nodesets
      */
-    private Hashtable _rootToIndexMap = new Hashtable();
+    private Map<Integer, Map> _rootToIndexMap = new HashMap<>();
 
     /**
      * The node set associated to the current value passed
@@ -91,14 +90,14 @@
      * Adds a node to the node list for a given value. Nodes will
      * always be added in document order.
      */
-    public void add(Object value, int node, int rootNode) {
+    public void add(String value, int node, int rootNode) {
         if (_currentDocumentNode != rootNode) {
             _currentDocumentNode = rootNode;
-            _index = new Hashtable();
-            _rootToIndexMap.put(new Integer(rootNode), _index);
+            _index = new HashMap<>();
+            _rootToIndexMap.put(rootNode, _index);
         }
 
-        IntegerArray nodes = (IntegerArray) _index.get(value);
+        IntegerArray nodes = _index.get(value);
 
         if (nodes == null) {
              nodes = new IntegerArray();
@@ -145,7 +144,7 @@
                                                            " \n\t");
         while (values.hasMoreElements()) {
             final String token = (String) values.nextElement();
-            IntegerArray nodes = (IntegerArray) _index.get(token);
+            IntegerArray nodes = _index.get(token);
 
             if (nodes == null && _enhancedDOM != null
                 && _enhancedDOM.hasDOMSource()) {
@@ -178,13 +177,13 @@
 
             if (ident != DTM.NULL) {
                 Integer root = new Integer(_enhancedDOM.getDocument());
-                Hashtable index = (Hashtable) _rootToIndexMap.get(root);
+                Map<String, IntegerArray> index = _rootToIndexMap.get(root);
 
                 if (index == null) {
-                    index = new Hashtable();
+                    index = new HashMap<>();
                     _rootToIndexMap.put(root, index);
                 } else {
-                    nodes = (IntegerArray) index.get(id);
+                    nodes = index.get(id);
                 }
 
                 if (nodes == null) {
@@ -207,7 +206,7 @@
      * @deprecated
      */
     public void lookupKey(Object value) {
-        IntegerArray nodes = (IntegerArray) _index.get(value);
+        IntegerArray nodes = _index.get(value);
         _nodes = (nodes != null) ? (IntegerArray) nodes.clone() : null;
         _position = 0;
     }
@@ -243,8 +242,8 @@
                                  .setStartNode(node).next();
 
         // Get the mapping table for the document containing the context node
-        Hashtable index =
-            (Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
+        Map<String, IntegerArray> index =
+            _rootToIndexMap.get(rootHandle);
 
         // Split argument to id function into XML whitespace separated tokens
         final StringTokenizer values = new StringTokenizer(string, " \n\t");
@@ -254,7 +253,7 @@
             IntegerArray nodes = null;
 
             if (index != null) {
-                nodes = (IntegerArray) index.get(token);
+                nodes = index.get(token);
             }
 
             // If input was from W3C DOM, use DOM's getElementById to do
@@ -294,13 +293,13 @@
                                  .setStartNode(node).next();
 
         // Get the mapping table for the document containing the context node
-        Hashtable index =
-                    (Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
+        Map<String,IntegerArray> index =
+                    _rootToIndexMap.get(new Integer(rootHandle));
 
         // Check whether the context node is present in the set of nodes
         // returned by the key function
         if (index != null) {
-            final IntegerArray nodes = (IntegerArray) index.get(value);
+            final IntegerArray nodes = index.get(value);
             return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
         }
 
@@ -689,7 +688,7 @@
             IntegerArray result = null;
 
             // Get mapping from key values/IDs to DTM nodes for this document
-            Hashtable index = (Hashtable)_rootToIndexMap.get(new Integer(root));
+            Map<String, IntegerArray> index = _rootToIndexMap.get(root);
 
             if (!_isKeyIterator) {
                 // For id function, tokenize argument as whitespace separated
@@ -703,7 +702,7 @@
 
                     // Does the ID map to any node in the document?
                     if (index != null) {
-                        nodes = (IntegerArray) index.get(token);
+                        nodes = index.get(token);
                     }
 
                     // If input was from W3C DOM, use DOM's getElementById to do
@@ -725,7 +724,7 @@
                 }
             } else if (index != null) {
                 // For key function, map key value to nodes
-                result = (IntegerArray) index.get(keyValue);
+                result = index.get(keyValue);
             }
 
             return result;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -25,18 +25,18 @@
 
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
+import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTM;
-import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.DTMManager;
 import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
 import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
-
+import java.util.HashMap;
+import java.util.Map;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -56,7 +56,7 @@
     private int _free;
     private int _size;
 
-    private Hashtable _documents = new Hashtable();
+    private Map<String, Integer> _documents = new HashMap<>();
 
     private final class AxisIterator extends DTMAxisIteratorBase {
         // constitutive data
@@ -326,10 +326,10 @@
             domNo = domPos;
         }
 
-        // Store reference to document (URI) in hashtable
+        // Store reference to document (URI) in the Map
         if (indexByURI) {
             String uri = adapter.getDocumentURI(0);
-            _documents.put(uri, new Integer(domNo));
+            _documents.put(uri, domNo);
         }
 
         // If the dom is an AdaptiveResultTreeImpl, we need to create a
@@ -352,7 +352,7 @@
     }
 
     public int getDocumentMask(String uri) {
-        Integer domIdx = (Integer)_documents.get(uri);
+        Integer domIdx = _documents.get(uri);
         if (domIdx == null) {
             return(-1);
         } else {
@@ -361,7 +361,7 @@
     }
 
     public DOM getDOMAdapter(String uri) {
-        Integer domIdx = (Integer)_documents.get(uri);
+        Integer domIdx = _documents.get(uri);
         if (domIdx == null) {
             return(null);
         } else {
@@ -669,7 +669,7 @@
     }
 
     // %HZ% Does this method make any sense here???
-    public Hashtable getElementsWithIDs() {
+    public Map<String, Integer> getElementsWithIDs() {
         return _main.getElementsWithIDs();
     }
 }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,40 +23,35 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.Enumeration;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
+import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTM;
-import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.DTMManager;
 import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
 import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIterNodeList;
 import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
 import com.sun.org.apache.xml.internal.dtm.ref.EmptyIterator;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
 import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM2;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler;
+import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
 import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
-import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Entity;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Entity;
-
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -119,7 +114,7 @@
     private int _namesSize = -1;
 
     // Namespace related stuff
-    private Hashtable _nsIndex = new Hashtable();
+    private Map<Integer, Integer> _nsIndex = new HashMap<>();
 
     // The initial size of the text buffer
     private int _size = 0;
@@ -134,10 +129,10 @@
     // The owner Document when the input source is DOMSource.
     private Document _document;
 
-    // The hashtable for org.w3c.dom.Node to node id mapping.
+    // The Map for org.w3c.dom.Node to node id mapping.
     // This is only used when the input is a DOMSource and the
     // buildIdIndex flag is true.
-    private Hashtable _node2Ids = null;
+    private Map<Node, Integer> _node2Ids = null;
 
     // True if the input source is a DOMSource.
     private boolean _hasDOMSource = false;
@@ -480,7 +475,7 @@
             return 0;
         }
         int eType = getIdForNamespace(s);
-        return ((Integer)_nsIndex.get(new Integer(eType))).intValue();
+        return _nsIndex.get(new Integer(eType));
     }
 
 
@@ -679,9 +674,9 @@
 
         for (i=0; i<nsLength; i++) {
             int eType = getIdForNamespace(namespaces[i]);
-            Integer type = (Integer)_nsIndex.get(new Integer(eType));
+            Integer type = _nsIndex.get(eType);
             if (type != null) {
-                result[type.intValue()] = (short)i;
+                result[type] = (short)i;
             }
         }
 
@@ -699,7 +694,7 @@
 
         for (i = 0; i < length; i++) {
             int eType = getIdForNamespace(namespaces[i]);
-            Integer type = (Integer)_nsIndex.get(new Integer(eType));
+            Integer type = _nsIndex.get(eType);
             result[i] = (type == null) ? -1 : type.shortValue();
         }
 
@@ -752,7 +747,7 @@
             else {
                 _document = node.getOwnerDocument();
             }
-            _node2Ids = new Hashtable();
+            _node2Ids = new HashMap<>();
         }
     }
 
@@ -780,8 +775,8 @@
     {
         Node node = _document.getElementById(idString);
         if (node != null) {
-            Integer id = (Integer)_node2Ids.get(node);
-            return (id != null) ? id.intValue() : DTM.NULL;
+            Integer id = _node2Ids.get(node);
+            return (id != null) ? id : DTM.NULL;
         }
         else {
             return DTM.NULL;
@@ -880,7 +875,7 @@
     {
         super.startDocument();
 
-        _nsIndex.put(new Integer(0), new Integer(_uriCount++));
+        _nsIndex.put(0, _uriCount++);
         definePrefixAndUri(XML_PREFIX, XML_URI);
     }
 
@@ -987,8 +982,8 @@
     {
         // Check if the URI already exists before pushing on stack
         Integer eType = new Integer(getIdForNamespace(uri));
-        if ((Integer)_nsIndex.get(eType) == null) {
-            _nsIndex.put(eType, new Integer(_uriCount++));
+        if (_nsIndex.get(eType) == null) {
+            _nsIndex.put(eType, _uriCount++);
         }
     }
 
@@ -1840,28 +1835,11 @@
     }
 
     /**
-     * %HZ% Need Javadoc
+     * Return the attributes map.
+     * @return the attributes map.
      */
-    public Hashtable getElementsWithIDs() {
-        if (m_idAttributes == null) {
-            return null;
-        }
-
-        // Convert a java.util.Hashtable to an xsltc.runtime.Hashtable
-        Enumeration idValues = m_idAttributes.keys();
-        if (!idValues.hasMoreElements()) {
-            return null;
-        }
-
-        Hashtable idAttrsTable = new Hashtable();
-
-        while (idValues.hasMoreElements()) {
-            Object idValue = idValues.nextElement();
-
-            idAttrsTable.put(idValue, m_idAttributes.get(idValue));
-        }
-
-        return idAttrsTable;
+    public Map<String, Integer> getElementsWithIDs() {
+        return m_idAttributes;
     }
 
     /**
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,12 +23,10 @@
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
+import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
-import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
-
+import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTM;
-import com.sun.org.apache.xml.internal.dtm.Axis;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
 import com.sun.org.apache.xml.internal.dtm.DTMManager;
@@ -38,14 +36,12 @@
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
 import com.sun.org.apache.xml.internal.utils.XMLString;
 import com.sun.org.apache.xml.internal.utils.XMLStringDefault;
-
+import java.util.Map;
+import javax.xml.transform.SourceLocator;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-
 import org.xml.sax.SAXException;
 
-import javax.xml.transform.SourceLocator;
-
 /**
  * This class represents a light-weight DOM model for simple result tree fragment(RTF).
  * A simple RTF is an RTF that has only one Text node. The Text node can be produced by a
@@ -608,7 +604,7 @@
         return null;
     }
 
-    public Hashtable getElementsWithIDs()
+    public Map<String, Integer> getElementsWithIDs()
     {
         return null;
     }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -18,6 +18,7 @@
  * limitations under the License.
  */
 /*
+/*
  * $Id: AbstractTranslet.java,v 1.6 2006/06/19 19:49:03 spericas Exp $
  */
 
@@ -25,22 +26,6 @@
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Vector;
-import javax.xml.transform.Templates;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.DOMImplementation;
-import javax.xml.parsers.ParserConfigurationException;
-
-import com.sun.org.apache.xml.internal.dtm.DTM;
-
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
@@ -49,8 +34,23 @@
 import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
 import com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
+import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Templates;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
 
 /**
  * @author Jacek Ambroziak
@@ -271,15 +271,15 @@
      ************************************************************************/
 
     // Contains decimal number formatting symbols used by FormatNumberCall
-    public Hashtable _formatSymbols = null;
+    public Map<String, DecimalFormat> _formatSymbols = null;
 
     /**
-     * Adds a DecimalFormat object to the _formatSymbols hashtable.
+     * Adds a DecimalFormat object to the _formatSymbols map.
      * The entry is created with the input DecimalFormatSymbols.
      */
     public void addDecimalFormat(String name, DecimalFormatSymbols symbols) {
-        // Instanciate hashtable for formatting symbols if needed
-        if (_formatSymbols == null) _formatSymbols = new Hashtable();
+        // Instanciate map for formatting symbols if needed
+        if (_formatSymbols == null) _formatSymbols = new HashMap<>();
 
         // The name cannot be null - use empty string instead
         if (name == null) name = EMPTYSTRING;
@@ -293,7 +293,7 @@
     }
 
     /**
-     * Retrieves a named DecimalFormat object from _formatSymbols hashtable.
+     * Retrieves a named DecimalFormat object from the _formatSymbols map.
      */
     public final DecimalFormat getDecimalFormat(String name) {
 
@@ -301,8 +301,8 @@
             // The name cannot be null - use empty string instead
             if (name == null) name = EMPTYSTRING;
 
-            DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
-            if (df == null) df = (DecimalFormat)_formatSymbols.get(EMPTYSTRING);
+            DecimalFormat df = _formatSymbols.get(name);
+            if (df == null) df = _formatSymbols.get(EMPTYSTRING);
             return df;
         }
         return(null);
@@ -338,26 +338,19 @@
                 return;
             }
             else {
-                final Hashtable elementsByID = enhancedDOM.getElementsWithIDs();
+                final Map<String, Integer> elementsByID = enhancedDOM.getElementsWithIDs();
 
                 if (elementsByID == null) {
                     return;
                 }
 
-                // Given a Hashtable of DTM nodes indexed by ID attribute values,
+                // Given a Map of DTM nodes indexed by ID attribute values,
                 // loop through the table copying information to a KeyIndex
                 // for the mapping from ID attribute value to DTM node
-                final Enumeration idValues = elementsByID.keys();
                 boolean hasIDValues = false;
-
-                while (idValues.hasMoreElements()) {
-                    final Object idValue = idValues.nextElement();
-                    final int element =
-                            document.getNodeHandle(
-                                        ((Integer)elementsByID.get(idValue))
-                                                .intValue());
-
-                    buildKeyIndex(ID_INDEX_NAME, element, idValue);
+                for (Map.Entry<String, Integer> entry : elementsByID.entrySet()) {
+                    final int element = document.getNodeHandle(entry.getValue());
+                    buildKeyIndex(ID_INDEX_NAME, element, entry.getKey());
                     hasIDValues = true;
                 }
 
@@ -425,7 +418,7 @@
      ************************************************************************/
 
     // Container for all indexes for xsl:key elements
-    private Hashtable _keyIndexes = null;
+    private Map<String, KeyIndex> _keyIndexes = null;
     private KeyIndex  _emptyKeyIndex = null;
     private int       _indexSize = 0;
     private int       _currentRootForKeys = 0;
@@ -451,13 +444,8 @@
      *   @param node is the node handle of the node to insert
      *   @param value is the value that will look up the node in the given index
      */
-    public void buildKeyIndex(String name, int node, Object value) {
-        if (_keyIndexes == null) _keyIndexes = new Hashtable();
-
-        KeyIndex index = (KeyIndex)_keyIndexes.get(name);
-        if (index == null) {
-            _keyIndexes.put(name, index = new KeyIndex(_indexSize));
-        }
+    public void buildKeyIndex(String name, int node, String value) {
+        KeyIndex index = buildKeyIndexHelper(name);
         index.add(value, node, _currentRootForKeys);
     }
 
@@ -467,18 +455,33 @@
      *   @param dom is the DOM
      */
     public void buildKeyIndex(String name, DOM dom) {
-        if (_keyIndexes == null) _keyIndexes = new Hashtable();
+        KeyIndex index = buildKeyIndexHelper(name);
+        index.setDom(dom, dom.getDocument());
+    }
 
-        KeyIndex index = (KeyIndex)_keyIndexes.get(name);
+    /**
+     * Return KeyIndex for the buildKeyIndex methods. Note the difference from the
+     * public getKeyIndex method, this method creates a new Map if keyIndexes does
+     * not exist.
+     *
+     * @param name the name of the index (the key or ##id)
+     * @return a KeyIndex.
+     */
+    private KeyIndex buildKeyIndexHelper(String name) {
+        if (_keyIndexes == null) _keyIndexes = new HashMap<>();
+
+        KeyIndex index = _keyIndexes.get(name);
         if (index == null) {
             _keyIndexes.put(name, index = new KeyIndex(_indexSize));
         }
-        index.setDom(dom, dom.getDocument());
+        return index;
     }
 
     /**
      * Returns the index for a given key (or id).
      * The index implements our internal iterator interface
+     * @param name the name of the index (the key or ##id)
+     * @return a KeyIndex.
      */
     public KeyIndex getKeyIndex(String name) {
         // Return an empty key index iterator if none are defined
@@ -489,7 +492,7 @@
         }
 
         // Look up the requested key index
-        final KeyIndex index = (KeyIndex)_keyIndexes.get(name);
+        final KeyIndex index = _keyIndexes.get(name);
 
         // Return an empty key index iterator if the requested index not found
         if (index == null) {
@@ -706,14 +709,14 @@
         }
     }
 
-    private Hashtable _auxClasses = null;
+    private Map<String, Class<?>> _auxClasses = null;
 
     public void addAuxiliaryClass(Class auxClass) {
-        if (_auxClasses == null) _auxClasses = new Hashtable();
+        if (_auxClasses == null) _auxClasses = new HashMap<>();
         _auxClasses.put(auxClass.getName(), auxClass);
     }
 
-    public void setAuxiliaryClasses(Hashtable auxClasses) {
+    public void setAuxiliaryClasses(Map<String, Class<?>> auxClasses) {
         _auxClasses = auxClasses;
     }
 
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -24,6 +24,23 @@
 package com.sun.org.apache.xalan.internal.xsltc.runtime;
 
 import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xalan.internal.xsltc.DOM;
+import com.sun.org.apache.xalan.internal.xsltc.Translet;
+import com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.ArrayNodeListIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
+import com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM;
+import com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator;
+import com.sun.org.apache.xml.internal.dtm.Axis;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
+import com.sun.org.apache.xml.internal.dtm.DTMManager;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
+import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import com.sun.org.apache.xml.internal.utils.XML11Char;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.FieldPosition;
@@ -32,31 +49,11 @@
 import java.util.Locale;
 import java.util.ResourceBundle;
 import javax.xml.transform.dom.DOMSource;
-
-import com.sun.org.apache.xalan.internal.xsltc.DOM;
-import com.sun.org.apache.xalan.internal.xsltc.Translet;
-import com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator;
-import com.sun.org.apache.xml.internal.dtm.Axis;
-import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
-import com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM;
-import com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator;
-import com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator;
-import com.sun.org.apache.xalan.internal.xsltc.dom.ArrayNodeListIterator;
-import com.sun.org.apache.xml.internal.dtm.DTM;
-import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
-import com.sun.org.apache.xml.internal.dtm.DTMManager;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
-
-import org.w3c.dom.DOMException;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
-import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-import com.sun.org.apache.xml.internal.utils.XML11Char;
 
 /**
  * Standard XSLT functions. All standard functions expect the current node
@@ -983,7 +980,7 @@
 
     /**
      * Utility function: used to format/adjust  a double to a string. The
-     * DecimalFormat object comes from the 'formatSymbols' hashtable in
+     * DecimalFormat object comes from the 'formatSymbols' map in
      * AbstractTranslet.
      */
     private static FieldPosition _fieldPosition = new FieldPosition(0);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java	Fri Jul 29 04:24:19 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +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: Hashtable.java,v 1.2.4.1 2005/09/06 11:05:18 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.runtime;
-
-import java.util.Enumeration;
-
-/**
- * IMPORTANT NOTE:
- * This code was taken from Sun's Java1.1 JDK java.util.HashTable.java
- * All "synchronized" keywords and some methods we do not need have been
- * all been removed.
- */
-
-/**
- * Object that wraps entries in the hash-table
- * @author Morten Jorgensen
- */
-class HashtableEntry {
-    int hash;
-    Object key;
-    Object value;
-    HashtableEntry next;
-
-    protected Object clone() {
-        HashtableEntry entry = new HashtableEntry();
-        entry.hash = hash;
-        entry.key = key;
-        entry.value = value;
-        entry.next = (next != null) ? (HashtableEntry)next.clone() : null;
-        return entry;
-    }
-}
-
-/**
- * The main hash-table implementation
- */
-public class Hashtable {
-
-    private transient HashtableEntry table[]; // hash-table entries
-    private transient int count;              // number of entries
-    private int threshold;                    // current size of hash-tabke
-    private float loadFactor;                 // load factor
-
-    /**
-     * Constructs a new, empty hashtable with the specified initial
-     * capacity and the specified load factor.
-     */
-    public Hashtable(int initialCapacity, float loadFactor) {
-        if (initialCapacity <= 0) initialCapacity = 11;
-        if (loadFactor <= 0.0) loadFactor = 0.75f;
-        this.loadFactor = loadFactor;
-        table = new HashtableEntry[initialCapacity];
-        threshold = (int)(initialCapacity * loadFactor);
-    }
-
-    /**
-     * Constructs a new, empty hashtable with the specified initial capacity
-     * and default load factor.
-     */
-    public Hashtable(int initialCapacity) {
-        this(initialCapacity, 0.75f);
-    }
-
-    /**
-     * Constructs a new, empty hashtable with a default capacity and load
-     * factor.
-     */
-    public Hashtable() {
-        this(101, 0.75f);
-    }
-
-    /**
-     * Returns the number of keys in this hashtable.
-     */
-    public int size() {
-        return count;
-    }
-
-    /**
-     * Tests if this hashtable maps no keys to values.
-     */
-    public boolean isEmpty() {
-        return count == 0;
-    }
-
-    /**
-     * Returns an enumeration of the keys in this hashtable.
-     */
-    public Enumeration keys() {
-        return new HashtableEnumerator(table, true);
-    }
-
-    /**
-     * Returns an enumeration of the values in this hashtable.
-     * Use the Enumeration methods on the returned object to fetch the elements
-     * sequentially.
-     */
-    public Enumeration elements() {
-        return new HashtableEnumerator(table, false);
-    }
-
-    /**
-     * Tests if some key maps into the specified value in this hashtable.
-     * This operation is more expensive than the <code>containsKey</code>
-     * method.
-     */
-    public boolean contains(Object value) {
-
-        if (value == null) throw new NullPointerException();
-
-        int i;
-        HashtableEntry e;
-        HashtableEntry tab[] = table;
-
-        for (i = tab.length ; i-- > 0 ;) {
-            for (e = tab[i] ; e != null ; e = e.next) {
-                if (e.value.equals(value)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Tests if the specified object is a key in this hashtable.
-     */
-    public boolean containsKey(Object key) {
-        HashtableEntry e;
-        HashtableEntry tab[] = table;
-        int hash = key.hashCode();
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-
-        for (e = tab[index] ; e != null ; e = e.next)
-            if ((e.hash == hash) && e.key.equals(key))
-                return true;
-
-        return false;
-    }
-
-    /**
-     * Returns the value to which the specified key is mapped in this hashtable.
-     */
-    public Object get(Object key) {
-        HashtableEntry e;
-        HashtableEntry tab[] = table;
-        int hash = key.hashCode();
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-
-        for (e = tab[index] ; e != null ; e = e.next)
-            if ((e.hash == hash) && e.key.equals(key))
-                return e.value;
-
-        return null;
-    }
-
-    /**
-     * Rehashes the contents of the hashtable into a hashtable with a
-     * larger capacity. This method is called automatically when the
-     * number of keys in the hashtable exceeds this hashtable's capacity
-     * and load factor.
-     */
-    protected void rehash() {
-        HashtableEntry e, old;
-        int i, index;
-        int oldCapacity = table.length;
-        HashtableEntry oldTable[] = table;
-
-        int newCapacity = oldCapacity * 2 + 1;
-        HashtableEntry newTable[] = new HashtableEntry[newCapacity];
-
-        threshold = (int)(newCapacity * loadFactor);
-        table = newTable;
-
-        for (i = oldCapacity ; i-- > 0 ;) {
-            for (old = oldTable[i] ; old != null ; ) {
-                e = old;
-                old = old.next;
-                index = (e.hash & 0x7FFFFFFF) % newCapacity;
-                e.next = newTable[index];
-                newTable[index] = e;
-            }
-        }
-    }
-
-    /**
-     * Maps the specified <code>key</code> to the specified
-     * <code>value</code> in this hashtable. Neither the key nor the
-     * value can be <code>null</code>.
-     * <p>
-     * The value can be retrieved by calling the <code>get</code> method
-     * with a key that is equal to the original key.
-     */
-    public Object put(Object key, Object value) {
-        // Make sure the value is not null
-        if (value == null) throw new NullPointerException();
-
-        // Makes sure the key is not already in the hashtable.
-        HashtableEntry e;
-        HashtableEntry tab[] = table;
-        int hash = key.hashCode();
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-
-        for (e = tab[index] ; e != null ; e = e.next) {
-            if ((e.hash == hash) && e.key.equals(key)) {
-                Object old = e.value;
-                e.value = value;
-                return old;
-            }
-        }
-
-        // Rehash the table if the threshold is exceeded
-        if (count >= threshold) {
-            rehash();
-            return put(key, value);
-        }
-
-        // Creates the new entry.
-        e = new HashtableEntry();
-        e.hash = hash;
-        e.key = key;
-        e.value = value;
-        e.next = tab[index];
-        tab[index] = e;
-        count++;
-        return null;
-    }
-
-    /**
-     * Removes the key (and its corresponding value) from this
-     * hashtable. This method does nothing if the key is not in the hashtable.
-     */
-    public Object remove(Object key) {
-        HashtableEntry e, prev;
-        HashtableEntry tab[] = table;
-        int hash = key.hashCode();
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (e = tab[index], prev = null ; e != null ; prev = e, e = e.next) {
-            if ((e.hash == hash) && e.key.equals(key)) {
-                if (prev != null)
-                    prev.next = e.next;
-                else
-                    tab[index] = e.next;
-                count--;
-                return e.value;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Clears this hashtable so that it contains no keys.
-     */
-    public void clear() {
-        HashtableEntry tab[] = table;
-        for (int index = tab.length; --index >= 0; )
-            tab[index] = null;
-        count = 0;
-    }
-
-    /**
-     * Returns a rather long string representation of this hashtable.
-     * Handy for debugging - leave it here!!!
-     */
-    public String toString() {
-        int i;
-        int max = size() - 1;
-        StringBuffer buf = new StringBuffer();
-        Enumeration k = keys();
-        Enumeration e = elements();
-        buf.append("{");
-
-        for (i = 0; i <= max; i++) {
-            String s1 = k.nextElement().toString();
-            String s2 = e.nextElement().toString();
-            buf.append(s1).append('=').append(s2);
-            if (i < max) buf.append(", ");
-        }
-        buf.append("}");
-        return buf.toString();
-    }
-
-    /**
-     * A hashtable enumerator class.  This class should remain opaque
-     * to the client. It will use the Enumeration interface.
-     */
-    class HashtableEnumerator implements Enumeration {
-        boolean keys;
-        int index;
-        HashtableEntry table[];
-        HashtableEntry entry;
-
-        HashtableEnumerator(HashtableEntry table[], boolean keys) {
-            this.table = table;
-            this.keys = keys;
-            this.index = table.length;
-        }
-
-        public boolean hasMoreElements() {
-            if (entry != null) {
-                return true;
-            }
-            while (index-- > 0) {
-                if ((entry = table[index]) != null) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        public Object nextElement() {
-            if (entry == null) {
-                while ((index-- > 0) && ((entry = table[index]) == null));
-            }
-            if (entry != null) {
-                HashtableEntry e = entry;
-                entry = e.next;
-                return keys ? e.key : e.value;
-            }
-            return null;
-        }
-    }
-
-}
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -24,14 +24,15 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.trax;
 
+import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
+import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
 import java.io.IOException;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Stack;
 import java.util.Vector;
-
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
-
 import org.xml.sax.ContentHandler;
 import org.xml.sax.DTDHandler;
 import org.xml.sax.EntityResolver;
@@ -44,8 +45,6 @@
 import org.xml.sax.XMLReader;
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.AttributesImpl;
-import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
 
 /**
  * @author G. Todd Miller
@@ -59,7 +58,7 @@
     private ContentHandler _sax = null;
     private LexicalHandler _lex = null;
     private SAXImpl _saxImpl = null;
-    private Hashtable _nsPrefixes = new Hashtable();
+    private Map<String, Stack> _nsPrefixes = new HashMap<>();
 
     public DOM2SAX(Node root) {
         _dom = root;
@@ -91,7 +90,7 @@
         throws SAXException
     {
         boolean pushed = true;
-        Stack uriStack = (Stack) _nsPrefixes.get(prefix);
+        Stack uriStack = _nsPrefixes.get(prefix);
 
         if (uriStack != null) {
             if (uriStack.isEmpty()) {
@@ -124,7 +123,7 @@
     private void endPrefixMapping(String prefix)
         throws SAXException
     {
-        final Stack uriStack = (Stack) _nsPrefixes.get(prefix);
+        final Stack uriStack = _nsPrefixes.get(prefix);
 
         if (uriStack != null) {
             _sax.endPrefixMapping(prefix);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXEvent2SAX.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXEvent2SAX.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -75,7 +75,6 @@
     private ContentHandler _sax = null;
     private LexicalHandler _lex = null;
     private SAXImpl _saxImpl = null;
-    //private Hashtable _nsPrefixes = new Hashtable();
     private String version = null;
     private String encoding = null;
 
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,12 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.trax;
 
+import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
 import java.io.IOException;
-import java.util.Hashtable;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.Iterator;
-
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.DTDHandler;
@@ -45,22 +45,6 @@
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.ext.Locator2;
 import org.xml.sax.helpers.AttributesImpl;
-import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
-
-
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.Characters;
-import javax.xml.stream.events.EndElement;
-import javax.xml.stream.events.Namespace;
-import javax.xml.stream.events.ProcessingInstruction;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.StartDocument;
-import javax.xml.stream.events.XMLEvent;
 
 
 
@@ -80,7 +64,6 @@
     private ContentHandler _sax = null;
     private LexicalHandler _lex = null;
     private SAXImpl _saxImpl = null;
-    //private Hashtable _nsPrefixes = new Hashtable();
 
     public StAXStream2SAX(XMLStreamReader staxSrc) {
             staxStreamReader = staxSrc;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -30,13 +30,15 @@
 import com.sun.org.apache.xalan.internal.xsltc.Translet;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
 import java.io.IOException;
+import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 import javax.xml.XMLConstants;
@@ -89,7 +91,7 @@
     /**
      * Contains the list of auxiliary class definitions.
      */
-    private Hashtable _auxClasses = null;
+    private transient Map<String, Class<?>> _auxClasses = null;
 
     /**
      * Output properties of this translet.
@@ -122,19 +124,39 @@
      */
     private transient TransformerFactoryImpl _tfactory = null;
 
-    private boolean _useServicesMechanism;
+    /**
+     * A flag to determine whether the Service Mechanism is used
+     */
+    private transient boolean _useServicesMechanism;
 
     /**
      * protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
      */
-    private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
+    private transient String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
+
+    /**
+     * @serialField _name String The Name of the main class
+     * @serialField _bytecodes byte[][] Class definition
+     * @serialField _class Class[] The translet class definition(s).
+     * @serialField _transletIndex int The index of the main translet class
+     * @serialField _outputProperties Properties Output properties of this translet.
+     * @serialField _indentNumber int Number of spaces to add for output indentation.
+     */
+    private static final ObjectStreamField[] serialPersistentFields =
+        new ObjectStreamField[] {
+            new ObjectStreamField("_name", String.class),
+            new ObjectStreamField("_bytecodes", byte[][].class),
+            new ObjectStreamField("_class", Class[].class),
+            new ObjectStreamField("_transletIndex", int.class),
+            new ObjectStreamField("_outputProperties", Properties.class),
+            new ObjectStreamField("_indentNumber", int.class),
+        };
 
     static final class TransletClassLoader extends ClassLoader {
-
         private final Map<String,Class> _loadedExternalExtensionFunctions;
 
-        TransletClassLoader(ClassLoader parent) {
-            super(parent);
+         TransletClassLoader(ClassLoader parent) {
+             super(parent);
             _loadedExternalExtensionFunctions = null;
         }
 
@@ -154,7 +176,7 @@
                 ret = super.loadClass(name);
             }
             return ret;
-        }
+         }
 
         /**
          * Access to final protected superclass member from outer class.
@@ -214,6 +236,7 @@
      *  if yes then we need to deserialize the URIResolver
      *  Fix for bugzilla bug 22438
      */
+    @SuppressWarnings("unchecked")
     private void  readObject(ObjectInputStream is)
       throws IOException, ClassNotFoundException
     {
@@ -226,7 +249,16 @@
             }
         }
 
-        is.defaultReadObject();
+        // We have to read serialized fields first.
+        ObjectInputStream.GetField gf = is.readFields();
+        _name = (String)gf.get("_name", null);
+        _bytecodes = (byte[][])gf.get("_bytecodes", null);
+        _class = (Class[])gf.get("_class", null);
+        _transletIndex = gf.get("_transletIndex", -1);
+
+        _outputProperties = (Properties)gf.get("_outputProperties", null);
+        _indentNumber = gf.get("_indentNumber", 0);
+
         if (is.readBoolean()) {
             _uriResolver = (URIResolver) is.readObject();
         }
@@ -242,7 +274,22 @@
      */
     private void writeObject(ObjectOutputStream os)
         throws IOException, ClassNotFoundException {
-        os.defaultWriteObject();
+        if (_auxClasses != null) {
+            //throw with the same message as when Hashtable was used for compatibility.
+            throw new NotSerializableException(
+                    "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
+        }
+
+        // Write serialized fields
+        ObjectOutputStream.PutField pf = os.putFields();
+        pf.put("_name", _name);
+        pf.put("_bytecodes", _bytecodes);
+        pf.put("_class", _class);
+        pf.put("_transletIndex", _transletIndex);
+        pf.put("_outputProperties", _outputProperties);
+        pf.put("_indentNumber", _indentNumber);
+        os.writeFields();
+
         if (_uriResolver instanceof Serializable) {
             os.writeBoolean(true);
             os.writeObject((Serializable) _uriResolver);
@@ -360,7 +407,7 @@
             _class = new Class[classCount];
 
             if (classCount > 1) {
-                _auxClasses = new Hashtable();
+                _auxClasses = new HashMap<>();
             }
 
             for (int i = 0; i < classCount; i++) {
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -49,7 +49,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Vector;
@@ -73,7 +72,8 @@
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TemplatesHandler;
 import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stax.*;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 import org.xml.sax.InputSource;
@@ -146,13 +146,13 @@
     private String _jarFileName = null;
 
     /**
-     * This Hashtable is used to store parameters for locating
+     * This Map is used to store parameters for locating
      * <?xml-stylesheet ...?> processing instructions in XML docs.
      */
-    private Hashtable _piParams = null;
+    private Map<Source, PIParamWrapper> _piParams = null;
 
     /**
-     * The above hashtable stores objects of this class.
+     * The above Map stores objects of this class.
      */
     private static class PIParamWrapper {
         public String _media = null;
@@ -932,7 +932,7 @@
         // <?xml-stylesheet ...?> PI in an XML input document
         if ((_piParams != null) && (_piParams.get(source) != null)) {
             // Get the parameters for this Source object
-            PIParamWrapper p = (PIParamWrapper)_piParams.get(source);
+            PIParamWrapper p = _piParams.get(source);
             // Pass them on to the compiler (which will pass then to the parser)
             if (p != null) {
                 xsltc.setPIParameters(p._media, p._title, p._charset);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -26,6 +26,22 @@
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xalan.internal.xsltc.DOM;
+import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
+import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
+import com.sun.org.apache.xalan.internal.xsltc.Translet;
+import com.sun.org.apache.xalan.internal.xsltc.TransletException;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
+import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
+import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
+import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
+import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
+import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
+import com.sun.org.apache.xml.internal.utils.XMLReaderManager;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -38,11 +54,12 @@
 import java.net.URLConnection;
 import java.net.UnknownServiceException;
 import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.Vector;
-import java.lang.reflect.Constructor;
-
+import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -63,29 +80,6 @@
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
-import javax.xml.XMLConstants;
-
-import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
-
-import com.sun.org.apache.xalan.internal.xsltc.DOM;
-import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
-import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
-import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xalan.internal.xsltc.Translet;
-import com.sun.org.apache.xalan.internal.xsltc.TransletException;
-import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
-import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
-import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
-
-import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
-import com.sun.org.apache.xml.internal.utils.XMLReaderManager;
-
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -221,11 +215,11 @@
 
     private XMLSecurityManager _securityManager;
     /**
-     * A hashtable to store parameters for the identity transform. These
+     * A map to store parameters for the identity transform. These
      * are not needed during the transformation, but we must keep track of
      * them to be fully complaint with the JAXP API.
      */
-    private Hashtable _parameters = null;
+    private Map<String, Object> _parameters = null;
 
     /**
      * This class wraps an ErrorListener into a MessageHandler in order to
@@ -828,31 +822,6 @@
     }
 
     /**
-     * The translet stores all CDATA sections set in the <xsl:output> element
-     * in a Hashtable. This method will re-construct the whitespace separated
-     * list of elements given in the <xsl:output> element.
-     */
-    private String makeCDATAString(Hashtable cdata) {
-        // Return a 'null' string if no CDATA section elements were specified
-        if (cdata == null) return null;
-
-        StringBuffer result = new StringBuffer();
-
-        // Get an enumeration of all the elements in the hashtable
-        Enumeration elements = cdata.keys();
-        if (elements.hasMoreElements()) {
-            result.append((String)elements.nextElement());
-            while (elements.hasMoreElements()) {
-                String element = (String)elements.nextElement();
-                result.append(' ');
-                result.append(element);
-            }
-        }
-
-        return(result.toString());
-    }
-
-    /**
      * Implements JAXP's Transformer.getOutputProperties().
      * Returns a copy of the output properties for the transformation. This is
      * a set of layered properties. The first layer contains properties set by
@@ -1220,7 +1189,7 @@
 
         if (_isIdentity) {
             if (_parameters == null) {
-                _parameters = new Hashtable();
+                _parameters = new HashMap<>();
             }
             _parameters.put(name, value);
         }
--- a/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -17,25 +17,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.sun.org.apache.xerces.internal.dom;
 
-import java.lang.reflect.Constructor;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.util.URI;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.UserDataHandler;
+import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
-import com.sun.org.apache.xerces.internal.util.XML11Char;
-import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
+import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -50,6 +52,7 @@
 import org.w3c.dom.Notation;
 import org.w3c.dom.ProcessingInstruction;
 import org.w3c.dom.Text;
+import org.w3c.dom.UserDataHandler;
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventListener;
 import org.w3c.dom.ls.DOMImplementationLS;
@@ -82,17 +85,15 @@
  * @version $Id: CoreDocumentImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $
  * @since  PR-DOM-Level-1-19980818.
  */
-
-
 public class CoreDocumentImpl
-extends ParentNode implements Document  {
+        extends ParentNode implements Document {
 
-        /**TODO::
-         * 1. Change XML11Char method names similar to XMLChar. That will prevent lot
-         * of dirty version checking code.
-         *
-         * 2. IMO during cloneNode qname/isXMLName check should not be made.
-         */
+    /**
+     * TODO:: 1. Change XML11Char method names similar to XMLChar. That will
+     * prevent lot of dirty version checking code.
+     *
+     * 2. IMO during cloneNode qname/isXMLName check should not be made.
+     */
     //
     // Constants
     //
@@ -130,13 +131,12 @@
     /**Experimental DOM Level 3 feature: documentURI */
     protected String fDocumentURI;
 
-        //Revisit :: change to a better data structure.
+    //Revisit :: change to a better data structure.
     /** Table for user data attached to this document nodes. */
-    protected Hashtable userData;
-
+    private Map<Node, Map<String, UserDataRecord>> nodeUserData;
 
     /** Identifiers. */
-    protected Hashtable identifiers;
+    protected Map<String, Node> identifiers;
 
     // DOM Level 3: normalizeDocument
     transient DOMNormalizer domNormalizer = null;
@@ -207,7 +207,7 @@
     // document.  Node number values are negative integers.  Nodes are
     // assigned numbers on demand.
     private int nodeCounter = 0;
-    private Hashtable nodeTable;
+    private Map<Node, Integer> nodeTable;
     private boolean xml11Version = false; //by default 1.0
     //
     // Static initialization
@@ -243,6 +243,52 @@
 
     } // static
 
+    /**
+     * @serialField docType DocumentTypeImpl document type
+     * @serialField docElement ElementImpl document element
+     * @serialField fFreeNLCache NodeListCache NodeListCache free list
+     * @serialField encoding String Document encoding
+     * @serialField actualEncoding String Document actualEncoding
+     * @serialField version String Document version
+     * @serialField standalone boolean Document standalone
+     * @serialField fDocumentURI String Document URI
+     * @serialField userData Hashtable user data attached to the nodes. Note that
+     * it was original called "userData". It has been changed to nodeUserData to
+     * avoid confusion with those that are actually values of the map.
+     * @serialField identifiers Hashtable identifiers
+     * @serialField changes int flag indicates whether the node has changed
+     * @serialField allowGrammarAccess boolean Allow grammar access
+     * @serialField errorChecking boolean Bypass error checking
+     * @serialField ancestorChecking boolean Ancestor checking
+     * @serialField xmlVersionChanged boolean Indicate whether the version has changed
+     * @serialField documentNumber int Document number
+     * @serialField nodeCounter int Node counter
+     * @serialField nodeTable Hashtable Node table
+     * @serialField xml11Version boolean XML version
+     */
+    private static final ObjectStreamField[] serialPersistentFields =
+        new ObjectStreamField[] {
+            new ObjectStreamField("docType", DocumentTypeImpl.class),
+            new ObjectStreamField("docElement", ElementImpl.class),
+            new ObjectStreamField("fFreeNLCache", NodeListCache.class),
+            new ObjectStreamField("encoding", String.class),
+            new ObjectStreamField("actualEncoding", String.class),
+            new ObjectStreamField("version", String.class),
+            new ObjectStreamField("standalone", boolean.class),
+            new ObjectStreamField("fDocumentURI", String.class),
+            new ObjectStreamField("userData", Hashtable.class),
+            new ObjectStreamField("identifiers", Hashtable.class),
+            new ObjectStreamField("changes", int.class),
+            new ObjectStreamField("allowGrammarAccess", boolean.class),
+            new ObjectStreamField("errorChecking", boolean.class),
+            new ObjectStreamField("ancestorChecking", boolean.class),
+            new ObjectStreamField("xmlVersionChanged", boolean.class),
+            new ObjectStreamField("documentNumber", int.class),
+            new ObjectStreamField("nodeCounter", int.class),
+            new ObjectStreamField("nodeTable", Hashtable.class),
+            new ObjectStreamField("xml11Version", boolean.class),
+        };
+
     //
     // Constructors
     //
@@ -343,24 +389,21 @@
         }
 
         if (deep) {
-            Hashtable reversedIdentifiers = null;
+            Map<Node, String> reversedIdentifiers = null;
 
             if (identifiers != null) {
                 // Build a reverse mapping from element to identifier.
-                reversedIdentifiers = new Hashtable();
-                Enumeration elementIds = identifiers.keys();
-                while (elementIds.hasMoreElements()) {
-                    Object elementId = elementIds.nextElement();
-                    reversedIdentifiers.put(identifiers.get(elementId),
-                    elementId);
+                reversedIdentifiers = new HashMap<>(identifiers.size());
+                for (String elementId : identifiers.keySet()) {
+                    reversedIdentifiers.put(identifiers.get(elementId), elementId);
                 }
             }
 
             // Copy children into new document.
             for (ChildNode kid = firstChild; kid != null;
-            kid = kid.nextSibling) {
+                    kid = kid.nextSibling) {
                 newdoc.appendChild(newdoc.importNode(kid, true, true,
-                reversedIdentifiers));
+                        reversedIdentifiers));
             }
         }
 
@@ -385,7 +428,7 @@
      * document element nor the document type in any way
      */
     public Node insertBefore(Node newChild, Node refChild)
-    throws DOMException {
+            throws DOMException {
 
         // Only one such child permitted
         int type = newChild.getNodeType();
@@ -447,7 +490,7 @@
      * document element nor the document type in any way
      */
     public Node replaceChild(Node newChild, Node oldChild)
-    throws DOMException {
+            throws DOMException {
 
         // Adopt orphan doctypes
         if (newChild.getOwnerDocument() == null &&
@@ -463,8 +506,8 @@
             newChild.getNodeType() == Node.ELEMENT_NODE))) {
 
             throw new DOMException(
-                DOMException.HIERARCHY_REQUEST_ERR,
-                DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null));
+                    DOMException.HIERARCHY_REQUEST_ERR,
+                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null));
         }
         super.replaceChild(newChild, oldChild);
 
@@ -491,7 +534,7 @@
      * @since DOM Level 3
      */
     public void setTextContent(String textContent)
-    throws DOMException {
+            throws DOMException {
         // no-op
     }
 
@@ -508,7 +551,7 @@
         // plus, only features whose interfaces are directly castable are
         // considered.
         if ((feature.equalsIgnoreCase("+XPath"))
-            && (anyVersion || version.equals("3.0"))) {
+                && (anyVersion || version.equals("3.0"))) {
 
             // If an XPathEvaluator was created previously
             // return it otherwise create a new one.
@@ -527,7 +570,7 @@
                 Class interfaces[] = xpathClass.getInterfaces();
                 for (int i = 0; i < interfaces.length; i++) {
                     if (interfaces[i].getName().equals(
-                    "org.w3c.dom.xpath.XPathEvaluator")) {
+                            "org.w3c.dom.xpath.XPathEvaluator")) {
                         fXPathEvaluator = xpathClassConstr.newInstance(new Object[] { this });
                         return fXPathEvaluator;
                     }
@@ -557,14 +600,14 @@
      * if the attribute name is not acceptable.
      */
     public Attr createAttribute(String name)
-        throws DOMException {
+            throws DOMException {
 
         if (errorChecking && !isXMLName(name,xml11Version)) {
             String msg =
                 DOMMessageFormatter.formatMessage(
-                    DOMMessageFormatter.DOM_DOMAIN,
-                    "INVALID_CHARACTER_ERR",
-                    null);
+                            DOMMessageFormatter.DOM_DOMAIN,
+                            "INVALID_CHARACTER_ERR",
+                            null);
             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
         }
         return new AttrImpl(this, name);
@@ -581,7 +624,7 @@
      * not yet implemented.)
      */
     public CDATASection createCDATASection(String data)
-    throws DOMException {
+            throws DOMException {
         return new CDATASectionImpl(this, data);
     }
 
@@ -615,7 +658,7 @@
      * acceptable.
      */
     public Element createElement(String tagName)
-    throws DOMException {
+            throws DOMException {
 
         if (errorChecking && !isXMLName(tagName,xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
@@ -636,7 +679,7 @@
      * implemented.)
      */
     public EntityReference createEntityReference(String name)
-    throws DOMException {
+            throws DOMException {
 
         if (errorChecking && !isXMLName(name,xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
@@ -660,8 +703,8 @@
      * not yet implemented.)
      */
     public ProcessingInstruction createProcessingInstruction(String target,
-    String data)
-    throws DOMException {
+            String data)
+            throws DOMException {
 
         if (errorChecking && !isXMLName(target,xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
@@ -695,7 +738,6 @@
         return docType;
     }
 
-
     /**
      * Convenience method, allowing direct access to the child node
      * which is considered the root of the actual document content. For
@@ -787,7 +829,6 @@
         return errorChecking;
     }
 
-
     /**
      * DOM Level 3 CR - Experimental. (Was getActualEncoding)
      *
@@ -921,8 +962,8 @@
      * @since DOM Level 3
      */
     public void setXmlStandalone(boolean value)
-                                  throws DOMException {
-            standalone = value;
+            throws DOMException {
+        standalone = value;
     }
 
     /**
@@ -993,9 +1034,9 @@
                             if(colon1 != -1){
                                 String msg =
                                     DOMMessageFormatter.formatMessage(
-                                            DOMMessageFormatter.DOM_DOMAIN,
-                                            "NAMESPACE_ERR",
-                                            null);
+                                                DOMMessageFormatter.DOM_DOMAIN,
+                                                "NAMESPACE_ERR",
+                                                null);
                                 throw new DOMException(DOMException.NAMESPACE_ERR, msg);
                             }
                             if (!isXMLName(name,xml11Version)) {
@@ -1021,7 +1062,7 @@
                         copyEventListeners(el, nel);
 
                         // remove user data from old node
-                        Hashtable data = removeUserDataTable(el);
+                        Map<String, UserDataRecord> data = removeUserDataTable(el);
 
                         // remove old node from parent if any
                         Node parent = el.getParentNode();
@@ -1094,7 +1135,7 @@
                         copyEventListeners(at, nat);
 
                         // remove user data from old node
-                        Hashtable data = removeUserDataTable(at);
+                        Map<String, UserDataRecord> data = removeUserDataTable(at);
 
                         // move children to new node
                         Node child = at.getFirstChild();
@@ -1329,13 +1370,13 @@
      *   parameter is from an other document.
      */
     public String saveXML(Node node)
-    throws DOMException {
-        if ( errorChecking && node != null &&
-            this != node.getOwnerDocument() ) {
+            throws DOMException {
+        if (errorChecking && node != null
+                && this != node.getOwnerDocument()) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
             throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
         }
-        DOMImplementationLS domImplLS = (DOMImplementationLS)DOMImplementationImpl.getDOMImplementation();
+        DOMImplementationLS domImplLS = (DOMImplementationLS) DOMImplementationImpl.getDOMImplementation();
         LSSerializer xmlWriter = domImplLS.createLSSerializer();
         if (node == null) {
             node = this;
@@ -1344,8 +1385,8 @@
     }
 
     /**
-     * Sets whether the DOM implementation generates mutation events
-     * upon operations.
+     * Sets whether the DOM implementation generates mutation events upon
+     * operations.
      */
     void setMutationEvents(boolean set) {
         // does nothing by default - overidden in subclass
@@ -1359,47 +1400,40 @@
         return false;
     }
 
-
-
     // non-DOM factory methods
-
     /**
-     * NON-DOM
-     * Factory method; creates a DocumentType having this Document
-     * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
-     * DTD information unspecified.)
+     * NON-DOM Factory method; creates a DocumentType having this Document as
+     * its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
+     * information unspecified.)
      *
      * @param name The name of the Entity we wish to provide a value for.
      *
-     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
-     * DTDs are not permitted. (HTML not yet implemented.)
+     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where DTDs
+     * are not permitted. (HTML not yet implemented.)
      */
     public DocumentType createDocumentType(String qualifiedName,
-    String publicID,
-    String systemID)
-    throws DOMException {
+            String publicID,
+            String systemID)
+            throws DOMException {
 
         return new DocumentTypeImpl(this, qualifiedName, publicID, systemID);
 
     } // createDocumentType(String):DocumentType
 
     /**
-     * NON-DOM
-     * Factory method; creates an Entity having this Document
-     * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
-     * DTD information unspecified.)
+     * NON-DOM Factory method; creates an Entity having this Document as its
+     * OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
+     * information unspecified.)
      *
      * @param name The name of the Entity we wish to provide a value for.
      *
      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
-     * nonstandard entities are not permitted. (HTML not yet
-     * implemented.)
+     * nonstandard entities are not permitted. (HTML not yet implemented.)
      */
     public Entity createEntity(String name)
-    throws DOMException {
+            throws DOMException {
 
-
-        if (errorChecking && !isXMLName(name,xml11Version)) {
+        if (errorChecking && !isXMLName(name, xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
         }
@@ -1408,21 +1442,19 @@
     } // createEntity(String):Entity
 
     /**
-     * NON-DOM
-     * Factory method; creates a Notation having this Document
-     * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
-     * DTD information unspecified.)
+     * NON-DOM Factory method; creates a Notation having this Document as its
+     * OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
+     * information unspecified.)
      *
      * @param name The name of the Notation we wish to describe
      *
      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
-     * notations are not permitted. (HTML not yet
-     * implemented.)
+     * notations are not permitted. (HTML not yet implemented.)
      */
     public Notation createNotation(String name)
-    throws DOMException {
+            throws DOMException {
 
-        if (errorChecking && !isXMLName(name,xml11Version)) {
+        if (errorChecking && !isXMLName(name, xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
         }
@@ -1435,9 +1467,9 @@
      * definitions hold default attribute values.
      */
     public ElementDefinitionImpl createElementDefinition(String name)
-    throws DOMException {
+            throws DOMException {
 
-        if (errorChecking && !isXMLName(name,xml11Version)) {
+        if (errorChecking && !isXMLName(name, xml11Version)) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
         }
@@ -1446,23 +1478,23 @@
     } // createElementDefinition(String):ElementDefinitionImpl
 
     // other non-DOM methods
-
-    /** NON-DOM:  Get the number associated with this document.   Used to
-     * order documents in the implementation.
+    /**
+     * NON-DOM: Get the number associated with this document. Used to order
+     * documents in the implementation.
      */
     protected int getNodeNumber() {
-        if (documentNumber==0) {
+        if (documentNumber == 0) {
 
-            CoreDOMImplementationImpl cd = (CoreDOMImplementationImpl)CoreDOMImplementationImpl.getDOMImplementation();
+            CoreDOMImplementationImpl cd = (CoreDOMImplementationImpl) CoreDOMImplementationImpl.getDOMImplementation();
             documentNumber = cd.assignDocumentNumber();
         }
         return documentNumber;
     }
 
-
-    /** NON-DOM:  Get a number associated with a node created with respect
-     * to this document.   Needed for compareDocumentPosition when nodes
-     * are disconnected.  This is only used on demand.
+    /**
+     * NON-DOM: Get a number associated with a node created with respect to this
+     * document. Needed for compareDocumentPosition when nodes are disconnected.
+     * This is only used on demand.
      */
     protected int getNodeNumber(Node node) {
 
@@ -1472,18 +1504,17 @@
         // Node numbers are negative, from -1 to -n
         int num;
         if (nodeTable == null) {
-            nodeTable = new Hashtable();
+            nodeTable = new HashMap<>();
             num = --nodeCounter;
             nodeTable.put(node, new Integer(num));
-        }
-        else {
-            Integer n = (Integer)nodeTable.get(node);
-            if (n== null) {
+        } else {
+            Integer n = nodeTable.get(node);
+            if (n == null) {
                 num = --nodeCounter;
-                nodeTable.put(node, new Integer(num));
+                nodeTable.put(node, num);
+            } else {
+                num = n.intValue();
             }
-            else
-                num = n.intValue();
         }
         return num;
     }
@@ -1498,7 +1529,7 @@
      * and a NOT_SUPPORTED_ERR exception is thrown if attempted.
      */
     public Node importNode(Node source, boolean deep)
-    throws DOMException {
+            throws DOMException {
         return importNode(source, deep, false, null);
     } // importNode(Node,boolean):Node
 
@@ -1507,18 +1538,18 @@
      * provides the core functionality for the public importNode and cloneNode
      * methods.
      *
-     * The reversedIdentifiers parameter is provided for cloneNode to
-     * preserve the document's identifiers. The Hashtable has Elements as the
-     * keys and their identifiers as the values. When an element is being
-     * imported, a check is done for an associated identifier. If one exists,
-     * the identifier is registered with the new, imported element. If
-     * reversedIdentifiers is null, the parameter is not applied.
+     * The reversedIdentifiers parameter is provided for cloneNode to preserve
+     * the document's identifiers. The Map has Elements as the keys and
+     * their identifiers as the values. When an element is being imported, a
+     * check is done for an associated identifier. If one exists, the identifier
+     * is registered with the new, imported element. If reversedIdentifiers is
+     * null, the parameter is not applied.
      */
     private Node importNode(Node source, boolean deep, boolean cloningDoc,
-    Hashtable reversedIdentifiers)
-    throws DOMException {
-        Node newnode=null;
-                Hashtable userData = null;
+            Map<Node, String> reversedIdentifiers)
+            throws DOMException {
+        Node newnode = null;
+        Map<String, UserDataRecord> userData = null;
 
         // Sigh. This doesn't work; too many nodes have private data that
         // would have to be manually tweaked. May be able to add local
@@ -1531,8 +1562,9 @@
         //  newnode.ownerDocument=this;
         // }
         // else
-                if(source instanceof NodeImpl)
-                        userData = ((NodeImpl)source).getUserDataRecord();
+        if (source instanceof NodeImpl) {
+            userData = ((NodeImpl) source).getUserDataRecord();
+        }
         int type = source.getNodeType();
         switch (type) {
             case ELEMENT_NODE: {
@@ -1543,7 +1575,7 @@
                     newElement = createElement(source.getNodeName());
                 else
                     newElement = createElementNS(source.getNamespaceURI(),
-                    source.getNodeName());
+                            source.getNodeName());
 
                 // Copy element's attributes, if any.
                 NamedNodeMap sourceAttrs = source.getAttributes();
@@ -1558,7 +1590,7 @@
                         // But for importNode defaults should be ignored.
                         if (attr.getSpecified() || cloningDoc) {
                             Attr newAttr = (Attr)importNode(attr, true, cloningDoc,
-                            reversedIdentifiers);
+                                    reversedIdentifiers);
 
                             // Attach attribute according to namespace
                             // support/qualification.
@@ -1567,17 +1599,18 @@
                                 newElement.setAttributeNode(newAttr);
                             else
                                 newElement.setAttributeNodeNS(newAttr);
+                            }
                         }
                     }
-                }
 
                 // Register element identifier.
                 if (reversedIdentifiers != null) {
                     // Does element have an associated identifier?
-                    Object elementId = reversedIdentifiers.get(source);
+                    String elementId = reversedIdentifiers.get(source);
                     if (elementId != null) {
-                        if (identifiers == null)
-                            identifiers = new Hashtable();
+                        if (identifiers == null) {
+                            identifiers = new HashMap<>();
+                        }
 
                         identifiers.put(elementId, newElement);
                     }
@@ -1594,7 +1627,7 @@
                         newnode = createAttribute(source.getNodeName());
                     } else {
                         newnode = createAttributeNS(source.getNamespaceURI(),
-                        source.getNodeName());
+                                source.getNodeName());
                     }
                 }
                 else {
@@ -1663,7 +1696,7 @@
 
             case PROCESSING_INSTRUCTION_NODE: {
                 newnode = createProcessingInstruction(source.getNodeName(),
-                source.getNodeValue());
+                        source.getNodeValue());
                 break;
             }
 
@@ -1682,15 +1715,15 @@
                 DocumentType srcdoctype = (DocumentType)source;
                 DocumentTypeImpl newdoctype = (DocumentTypeImpl)
                 createDocumentType(srcdoctype.getNodeName(),
-                srcdoctype.getPublicId(),
-                srcdoctype.getSystemId());
+                        srcdoctype.getPublicId(),
+                        srcdoctype.getSystemId());
                 // Values are on NamedNodeMaps
                 NamedNodeMap smap = srcdoctype.getEntities();
                 NamedNodeMap tmap = newdoctype.getEntities();
                 if(smap != null) {
                     for(int i = 0; i < smap.getLength(); i++) {
                         tmap.setNamedItem(importNode(smap.item(i), true, true,
-                        reversedIdentifiers));
+                                reversedIdentifiers));
                     }
                 }
                 smap = srcdoctype.getNotations();
@@ -1698,7 +1731,7 @@
                 if (smap != null) {
                     for(int i = 0; i < smap.getLength(); i++) {
                         tmap.setNamedItem(importNode(smap.item(i), true, true,
-                        reversedIdentifiers));
+                                reversedIdentifiers));
                     }
                 }
 
@@ -1741,10 +1774,10 @@
         // If deep, replicate and attach the kids.
         if (deep) {
             for (Node srckid = source.getFirstChild();
-            srckid != null;
-            srckid = srckid.getNextSibling()) {
+                    srckid != null;
+                    srckid = srckid.getNextSibling()) {
                 newnode.appendChild(importNode(srckid, true, cloningDoc,
-                reversedIdentifiers));
+                        reversedIdentifiers));
             }
         }
         if (newnode.getNodeType() == Node.ENTITY_NODE) {
@@ -1752,7 +1785,7 @@
         }
         return newnode;
 
-    } // importNode(Node,boolean,boolean,Hashtable):Node
+    } // importNode(Node,boolean,boolean,Map):Node
 
     /**
      * DOM Level 3 WD - Experimental
@@ -1763,7 +1796,7 @@
      **/
     public Node adoptNode(Node source) {
         NodeImpl node;
-                Hashtable userData = null;
+        Map<String, UserDataRecord> userData;
         try {
             node = (NodeImpl) source;
         } catch (ClassCastException e) {
@@ -1774,8 +1807,8 @@
         // Return null if the source is null
 
         if (source == null ) {
-                return null;
-        } else if (source != null && source.getOwnerDocument() != null) {
+            return null;
+        } else if (source.getOwnerDocument() != null) {
 
             DOMImplementation thisImpl = this.getImplementation();
             DOMImplementation otherImpl = source.getOwnerDocument().getImplementation();
@@ -1795,7 +1828,7 @@
                     // Adopting between two dissimilar DOM's is not allowed
                     return null;
                 }
-                }
+            }
         }
 
         switch (node.getNodeType()) {
@@ -1808,12 +1841,13 @@
                 }
                 //2. specified flag is set to true
                 attr.isSpecified(true);
-                                userData = node.getUserDataRecord();
+                userData = node.getUserDataRecord();
 
                 //3. change ownership
                 attr.setOwnerDocument(this);
-                                if(userData != null )
-                                        setUserDataTable(node,userData);
+                if (userData != null) {
+                    setUserDataTable(node, userData);
+                }
                 break;
             }
             //entity, notation nodes are read only nodes.. so they can't be adopted.
@@ -1832,7 +1866,7 @@
                 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
             }
             case ENTITY_REFERENCE_NODE: {
-                                userData = node.getUserDataRecord();
+                userData = node.getUserDataRecord();
                 // remove node from wherever it is
                 Node parent = node.getParentNode();
                 if (parent != null) {
@@ -1845,8 +1879,9 @@
                 }
                 // change ownership
                 node.setOwnerDocument(this);
-                                if(userData != null)
-                                        setUserDataTable(node,userData);
+                if (userData != null) {
+                    setUserDataTable(node, userData);
+                }
                 // set its new replacement value if any
                 if (docType == null) {
                     break;
@@ -1857,14 +1892,14 @@
                     break;
                 }
                 for (child = entityNode.getFirstChild();
-                child != null; child = child.getNextSibling()) {
+                        child != null; child = child.getNextSibling()) {
                     Node childClone = child.cloneNode(true);
                     node.appendChild(childClone);
                 }
                 break;
             }
             case ELEMENT_NODE: {
-                                userData = node.getUserDataRecord();
+                userData = node.getUserDataRecord();
                 // remove node from wherever it is
                 Node parent = node.getParentNode();
                 if (parent != null) {
@@ -1872,14 +1907,15 @@
                 }
                 // change ownership
                 node.setOwnerDocument(this);
-                                if(userData != null)
-                                        setUserDataTable(node,userData);
+                if (userData != null) {
+                    setUserDataTable(node, userData);
+                }
                 // reconcile default attributes
                 ((ElementImpl)node).reconcileDefaultAttributes();
                 break;
             }
             default: {
-                                userData = node.getUserDataRecord();
+                userData = node.getUserDataRecord();
                 // remove node from wherever it is
                 Node parent = node.getParentNode();
                 if (parent != null) {
@@ -1887,15 +1923,17 @@
                 }
                 // change ownership
                 node.setOwnerDocument(this);
-                                if(userData != null)
-                                        setUserDataTable(node,userData);
+                if (userData != null) {
+                    setUserDataTable(node, userData);
+                }
             }
         }
 
                 //DOM L3 Core CR
-                //http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#UserDataHandler-ADOPTED
-                if(userData != null)
-                        callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED,userData);
+        //http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#UserDataHandler-ADOPTED
+        if (userData != null) {
+            callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED, userData);
+        }
 
         return node;
     }
@@ -1994,7 +2032,7 @@
         }
 
         if (identifiers == null) {
-            identifiers = new Hashtable();
+            identifiers = new HashMap<>();
         }
 
         identifiers.put(idName, element);
@@ -2052,25 +2090,9 @@
 
     } // removeIdentifier(String)
 
-    /** Returns an enumeration registered of identifier names. */
-    public Enumeration getIdentifiers() {
-
-        if (needsSyncData()) {
-            synchronizeData();
-        }
-
-        if (identifiers == null) {
-            identifiers = new Hashtable();
-        }
-
-        return identifiers.keys();
-
-    } // getIdentifiers():Enumeration
-
     //
     // DOM2: Namespace methods
     //
-
     /**
      * Introduced in DOM Level 2. <p>
      * Creates an element of the given qualified name and namespace URI.
@@ -2095,7 +2117,7 @@
      * @since WD-DOM-Level-2-19990923
      */
     public Element createElementNS(String namespaceURI, String qualifiedName)
-    throws DOMException {
+            throws DOMException {
         return new ElementNSImpl(this, namespaceURI, qualifiedName);
     }
 
@@ -2114,8 +2136,8 @@
      *                   name contains an invalid character.
      */
     public Element createElementNS(String namespaceURI, String qualifiedName,
-    String localpart)
-    throws DOMException {
+            String localpart)
+            throws DOMException {
         return new ElementNSImpl(this, namespaceURI, qualifiedName, localpart);
     }
 
@@ -2138,7 +2160,7 @@
      * @since WD-DOM-Level-2-19990923
      */
     public Attr createAttributeNS(String namespaceURI, String qualifiedName)
-    throws DOMException {
+            throws DOMException {
         return new AttrNSImpl(this, namespaceURI, qualifiedName);
     }
 
@@ -2158,8 +2180,8 @@
      * name contains an invalid character.
      */
     public Attr createAttributeNS(String namespaceURI, String qualifiedName,
-    String localpart)
-    throws DOMException {
+            String localpart)
+            throws DOMException {
         return new AttrNSImpl(this, namespaceURI, qualifiedName, localpart);
     }
 
@@ -2180,7 +2202,7 @@
      * @since WD-DOM-Level-2-19990923
      */
     public NodeList getElementsByTagNameNS(String namespaceURI,
-    String localName) {
+            String localName) {
         return new DeepNodeListImpl(this, namespaceURI, localName);
     }
 
@@ -2233,11 +2255,11 @@
 
         if (!xml11Version) {
             validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
-                && XMLChar.isValidNCName(local);
+                    && XMLChar.isValidNCName(local);
         }
         else {
             validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
-                && XML11Char.isXML11ValidNCName(local);
+                    && XML11Char.isXML11ValidNCName(local);
         }
 
         return validNCName;
@@ -2323,37 +2345,33 @@
      * REVISIT: we could use a free list of UserDataRecord here
      */
     public Object setUserData(Node n, String key,
-    Object data, UserDataHandler handler) {
+            Object data, UserDataHandler handler) {
         if (data == null) {
-            if (userData != null) {
-                Hashtable t = (Hashtable) userData.get(n);
+            if (nodeUserData != null) {
+                Map<String, UserDataRecord> t = nodeUserData.get(n);
                 if (t != null) {
-                    Object o = t.remove(key);
-                    if (o != null) {
-                        UserDataRecord r = (UserDataRecord) o;
+                    UserDataRecord r = t.remove(key);
+                    if (r != null) {
                         return r.fData;
                     }
                 }
             }
             return null;
-        }
-        else {
-            Hashtable t;
-            if (userData == null) {
-                userData = new Hashtable();
-                t = new Hashtable();
-                userData.put(n, t);
-            }
-            else {
-                t = (Hashtable) userData.get(n);
+        } else {
+            Map<String, UserDataRecord> t;
+            if (nodeUserData == null) {
+                nodeUserData = new HashMap<>();
+                t = new HashMap<>();
+                nodeUserData.put(n, t);
+            } else {
+                t = nodeUserData.get(n);
                 if (t == null) {
-                    t = new Hashtable();
-                    userData.put(n, t);
+                    t = new HashMap<>();
+                    nodeUserData.put(n, t);
                 }
             }
-            Object o = t.put(key, new UserDataRecord(data, handler));
-            if (o != null) {
-                UserDataRecord r = (UserDataRecord) o;
+            UserDataRecord r = t.put(key, new UserDataRecord(data, handler));
+            if (r != null) {
                 return r.fData;
             }
             return null;
@@ -2372,42 +2390,41 @@
      * @since DOM Level 3
      */
     public Object getUserData(Node n, String key) {
-        if (userData == null) {
+        if (nodeUserData == null) {
             return null;
         }
-        Hashtable t = (Hashtable) userData.get(n);
+        Map<String, UserDataRecord> t = nodeUserData.get(n);
         if (t == null) {
             return null;
         }
-        Object o = t.get(key);
-        if (o != null) {
-            UserDataRecord r = (UserDataRecord) o;
+        UserDataRecord r = t.get(key);
+        if (r != null) {
             return r.fData;
         }
         return null;
     }
 
-        protected Hashtable getUserDataRecord(Node n){
-        if (userData == null) {
+    protected Map<String, UserDataRecord> getUserDataRecord(Node n) {
+        if (nodeUserData == null) {
             return null;
         }
-        Hashtable t = (Hashtable) userData.get(n);
+        Map<String, UserDataRecord> t = nodeUserData.get(n);
         if (t == null) {
             return null;
         }
-                return t;
-        }
+        return t;
+    }
 
-        /**
+    /**
      * Remove user data table for the given node.
      * @param n The node this operation applies to.
      * @return The removed table.
      */
-    Hashtable removeUserDataTable(Node n) {
-        if (userData == null) {
+    Map<String, UserDataRecord> removeUserDataTable(Node n) {
+        if (nodeUserData == null) {
             return null;
         }
-        return (Hashtable) userData.get(n);
+        return nodeUserData.get(n);
     }
 
     /**
@@ -2415,11 +2432,13 @@
      * @param n The node this operation applies to.
      * @param data The user data table.
      */
-    void setUserDataTable(Node n, Hashtable data) {
-                if (userData == null)
-                        userData = new Hashtable();
+    void setUserDataTable(Node n, Map<String, UserDataRecord> data) {
+        if (nodeUserData == null) {
+            nodeUserData = new HashMap<>();
+        }
+
         if (data != null) {
-            userData.put(n, data);
+            nodeUserData.put(n, data);
         }
     }
 
@@ -2430,41 +2449,39 @@
      * @param operation The operation - import, clone, or delete.
      */
     void callUserDataHandlers(Node n, Node c, short operation) {
-        if (userData == null) {
+        if (nodeUserData == null) {
             return;
         }
-        //Hashtable t = (Hashtable) userData.get(n);
-                if(n instanceof NodeImpl){
-                        Hashtable t = ((NodeImpl)n).getUserDataRecord();
-                        if (t == null || t.isEmpty()) {
-                                return;
-                        }
-                        callUserDataHandlers(n, c, operation,t);
-                }
+
+        if (n instanceof NodeImpl) {
+            Map<String, UserDataRecord> t = ((NodeImpl) n).getUserDataRecord();
+            if (t == null || t.isEmpty()) {
+                return;
+            }
+            callUserDataHandlers(n, c, operation, t);
+        }
     }
 
-        /**
+    /**
      * Call user data handlers when a node is deleted (finalized)
      * @param n The node this operation applies to.
      * @param c The copy node or null.
      * @param operation The operation - import, clone, or delete.
-         * @param handlers Data associated with n.
-        */
-        void callUserDataHandlers(Node n, Node c, short operation,Hashtable userData) {
+     * @param handlers Data associated with n.
+     */
+    void callUserDataHandlers(Node n, Node c, short operation, Map<String, UserDataRecord> userData) {
         if (userData == null || userData.isEmpty()) {
             return;
         }
-        Enumeration keys = userData.keys();
-        while (keys.hasMoreElements()) {
-            String key = (String) keys.nextElement();
-            UserDataRecord r = (UserDataRecord) userData.get(key);
+        for (String key : userData.keySet()) {
+            UserDataRecord r = userData.get(key);
             if (r.fHandler != null) {
                 r.fHandler.handle(operation, key, r.fData, n, c);
             }
         }
     }
 
-        /**
+    /**
      * Call user data handlers to let them know the nodes they are related to
      * are being deleted. The alternative would be to do that on Node but
      * because the nodes are used as the keys we have a reference to them that
@@ -2479,29 +2496,29 @@
     // 2. It affects the performance greatly in multi-thread environment.
     // -SG
     /*public void finalize() {
-        if (userData == null) {
-            return;
-        }
-        Enumeration nodes = userData.keys();
-        while (nodes.hasMoreElements()) {
-            Object node = nodes.nextElement();
-            Hashtable t = (Hashtable) userData.get(node);
-            if (t != null && !t.isEmpty()) {
-                Enumeration keys = t.keys();
-                while (keys.hasMoreElements()) {
-                    String key = (String) keys.nextElement();
-                    UserDataRecord r = (UserDataRecord) t.get(key);
-                    if (r.fHandler != null) {
-                        r.fHandler.handle(UserDataHandler.NODE_DELETED,
-                                          key, r.fData, null, null);
-                    }
-                }
-            }
-        }
-    }*/
+     if (userData == null) {
+     return;
+     }
+     Enumeration nodes = userData.keys();
+     while (nodes.hasMoreElements()) {
+     Object node = nodes.nextElement();
+     Hashtable t = (Hashtable) userData.get(node);
+     if (t != null && !t.isEmpty()) {
+     Enumeration keys = t.keys();
+     while (keys.hasMoreElements()) {
+     String key = (String) keys.nextElement();
+     UserDataRecord r = (UserDataRecord) t.get(key);
+     if (r.fHandler != null) {
+     r.fHandler.handle(UserDataHandler.NODE_DELETED,
+     key, r.fData, null, null);
+     }
+     }
+     }
+     }
+     }*/
 
     protected final void checkNamespaceWF( String qname, int colon1,
-    int colon2) {
+            int colon2) {
 
         if (!errorChecking) {
             return;
@@ -2512,42 +2529,42 @@
         if (colon1 == 0 || colon1 == qname.length() - 1 || colon2 != colon1) {
             String msg =
             DOMMessageFormatter.formatMessage(
-            DOMMessageFormatter.DOM_DOMAIN,
-            "NAMESPACE_ERR",
-            null);
+                            DOMMessageFormatter.DOM_DOMAIN,
+                            "NAMESPACE_ERR",
+                            null);
             throw new DOMException(DOMException.NAMESPACE_ERR, msg);
         }
     }
     protected final void checkDOMNSErr(String prefix,
-    String namespace) {
+            String namespace) {
         if (errorChecking) {
             if (namespace == null) {
                 String msg =
                 DOMMessageFormatter.formatMessage(
-                DOMMessageFormatter.DOM_DOMAIN,
-                "NAMESPACE_ERR",
-                null);
+                                DOMMessageFormatter.DOM_DOMAIN,
+                                "NAMESPACE_ERR",
+                                null);
                 throw new DOMException(DOMException.NAMESPACE_ERR, msg);
             }
             else if (prefix.equals("xml")
-            && !namespace.equals(NamespaceContext.XML_URI)) {
+                    && !namespace.equals(NamespaceContext.XML_URI)) {
                 String msg =
                 DOMMessageFormatter.formatMessage(
-                DOMMessageFormatter.DOM_DOMAIN,
-                "NAMESPACE_ERR",
-                null);
+                                DOMMessageFormatter.DOM_DOMAIN,
+                                "NAMESPACE_ERR",
+                                null);
                 throw new DOMException(DOMException.NAMESPACE_ERR, msg);
             }
             else if (
             prefix.equals("xmlns")
-            && !namespace.equals(NamespaceContext.XMLNS_URI)
-            || (!prefix.equals("xmlns")
-            && namespace.equals(NamespaceContext.XMLNS_URI))) {
+                    && !namespace.equals(NamespaceContext.XMLNS_URI)
+                    || (!prefix.equals("xmlns")
+                    && namespace.equals(NamespaceContext.XMLNS_URI))) {
                 String msg =
                 DOMMessageFormatter.formatMessage(
-                DOMMessageFormatter.DOM_DOMAIN,
-                "NAMESPACE_ERR",
-                null);
+                                DOMMessageFormatter.DOM_DOMAIN,
+                                "NAMESPACE_ERR",
+                                null);
                 throw new DOMException(DOMException.NAMESPACE_ERR, msg);
             }
         }
@@ -2565,24 +2582,24 @@
             return;
         }
 
-                // check that both prefix and local part match NCName
+        // check that both prefix and local part match NCName
         boolean validNCName = false;
         if (!xml11Version) {
             validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
-                && XMLChar.isValidNCName(local);
+                    && XMLChar.isValidNCName(local);
         }
         else {
             validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
-                && XML11Char.isXML11ValidNCName(local);
+                    && XML11Char.isXML11ValidNCName(local);
         }
 
         if (!validNCName) {
             // REVISIT: add qname parameter to the message
             String msg =
             DOMMessageFormatter.formatMessage(
-            DOMMessageFormatter.DOM_DOMAIN,
-            "INVALID_CHARACTER_ERR",
-            null);
+                            DOMMessageFormatter.DOM_DOMAIN,
+                            "INVALID_CHARACTER_ERR",
+                            null);
             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
         }
     }
@@ -2629,14 +2646,14 @@
     // Event related methods overidden in subclass
 
     protected void addEventListener(NodeImpl node, String type,
-    EventListener listener,
-    boolean useCapture) {
+            EventListener listener,
+            boolean useCapture) {
         // does nothing by default - overidden in subclass
     }
 
     protected void removeEventListener(NodeImpl node, String type,
-    EventListener listener,
-    boolean useCapture) {
+            EventListener listener,
+            boolean useCapture) {
         // does nothing by default - overidden in subclass
     }
 
@@ -2763,4 +2780,91 @@
     void renamedElement(Element oldEl, Element newEl) {
     }
 
+    /**
+     * @serialData Serialized fields. Convert Maps to Hashtables for backward
+     * compatibility.
+     */
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        // Convert Maps to Hashtables
+        Hashtable<Node, Hashtable<String, UserDataRecord>> nud = null;
+        if (nodeUserData != null) {
+            nud = new Hashtable<>();
+            for (Map.Entry<Node, Map<String, UserDataRecord>> e : nodeUserData.entrySet()) {
+                //e.getValue() will not be null since an entry is always put with a non-null value
+                nud.put(e.getKey(), new Hashtable<>(e.getValue()));
+            }
+        }
+
+        Hashtable<String, Node> ids = (identifiers == null)? null : new Hashtable<>(identifiers);
+        Hashtable<Node, Integer> nt = (nodeTable == null)? null : new Hashtable<>(nodeTable);
+
+        // Write serialized fields
+        ObjectOutputStream.PutField pf = out.putFields();
+        pf.put("docType", docType);
+        pf.put("docElement", docElement);
+        pf.put("fFreeNLCache", fFreeNLCache);
+        pf.put("encoding", encoding);
+        pf.put("actualEncoding", actualEncoding);
+        pf.put("version", version);
+        pf.put("standalone", standalone);
+        pf.put("fDocumentURI", fDocumentURI);
+
+        //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
+        pf.put("userData", nud);
+        pf.put("identifiers", ids);
+        pf.put("changes", changes);
+        pf.put("allowGrammarAccess", allowGrammarAccess);
+        pf.put("errorChecking", errorChecking);
+        pf.put("ancestorChecking", ancestorChecking);
+        pf.put("xmlVersionChanged", xmlVersionChanged);
+        pf.put("documentNumber", documentNumber);
+        pf.put("nodeCounter", nodeCounter);
+        pf.put("nodeTable", nt);
+        pf.put("xml11Version", xml11Version);
+        out.writeFields();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void readObject(ObjectInputStream in)
+                        throws IOException, ClassNotFoundException {
+        // We have to read serialized fields first.
+        ObjectInputStream.GetField gf = in.readFields();
+        docType = (DocumentTypeImpl)gf.get("docType", null);
+        docElement = (ElementImpl)gf.get("docElement", null);
+        fFreeNLCache = (NodeListCache)gf.get("fFreeNLCache", null);
+        encoding = (String)gf.get("encoding", null);
+        actualEncoding = (String)gf.get("actualEncoding", null);
+        version = (String)gf.get("version", null);
+        standalone = gf.get("standalone", false);
+        fDocumentURI = (String)gf.get("fDocumentURI", null);
+
+        //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
+        Hashtable<Node, Hashtable<String, UserDataRecord>> nud =
+                (Hashtable<Node, Hashtable<String, UserDataRecord>>)gf.get("userData", null);
+
+        Hashtable<String, Node> ids = (Hashtable<String, Node>)gf.get("identifiers", null);
+
+        changes = gf.get("changes", 0);
+        allowGrammarAccess = gf.get("allowGrammarAccess", false);
+        errorChecking = gf.get("errorChecking", true);
+        ancestorChecking = gf.get("ancestorChecking", true);
+        xmlVersionChanged = gf.get("xmlVersionChanged", false);
+        documentNumber = gf.get("documentNumber", 0);
+        nodeCounter = gf.get("nodeCounter", 0);
+
+        Hashtable<Node, Integer> nt = (Hashtable<Node, Integer>)gf.get("nodeTable", null);
+
+        xml11Version = gf.get("xml11Version", false);
+
+        //convert Hashtables back to HashMaps
+        if (nud != null) {
+            nodeUserData = new HashMap<>();
+            for (Map.Entry<Node, Hashtable<String, UserDataRecord>> e : nud.entrySet()) {
+                nodeUserData.put(e.getKey(), new HashMap<>(e.getValue()));
+            }
+        }
+
+        if (ids != null) identifiers = new HashMap<>(ids);
+        if (nt != null) nodeTable = new HashMap<>(nt);
+    }
 } // class CoreDocumentImpl
--- a/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -21,7 +21,7 @@
 package com.sun.org.apache.xerces.internal.dom;
 
 import java.util.ArrayList;
-
+import java.util.HashMap;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -2057,9 +2057,9 @@
                                element+')');
         }
 
-        // create hashtable
+        // create Map
         if (identifiers == null) {
-            identifiers = new java.util.Hashtable();
+            identifiers = new HashMap<>();
         }
 
         // save ID and its associated element
--- a/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001,2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,13 +20,19 @@
 
 package com.sun.org.apache.xerces.internal.dom;
 
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Vector;
-
 import com.sun.org.apache.xerces.internal.dom.events.EventImpl;
 import com.sun.org.apache.xerces.internal.dom.events.MutationEventImpl;
-import org.w3c.dom.UserDataHandler;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
@@ -34,6 +40,7 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.UserDataHandler;
 import org.w3c.dom.events.DocumentEvent;
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventException;
@@ -96,18 +103,33 @@
 
     /** Iterators */
     // REVISIT: Should this be transient? -Ac
-    protected Vector iterators;
+    protected List<NodeIterator> iterators;
 
      /** Ranges */
     // REVISIT: Should this be transient? -Ac
-    protected Vector ranges;
+    protected List<Range> ranges;
 
     /** Table for event listeners registered to this document nodes. */
-    protected Hashtable eventListeners;
+    protected Map<NodeImpl, List<LEntry>> eventListeners;
 
     /** Bypass mutation events firing. */
     protected boolean mutationEvents = false;
 
+
+    /**
+     * @serialField iterators Vector Node iterators
+     * @serialField ranges Vector ranges
+     * @serialField eventListeners Hashtable Event listeners
+     * @serialField mutationEvents boolean Bypass mutation events firing
+     */
+    private static final ObjectStreamField[] serialPersistentFields =
+        new ObjectStreamField[] {
+            new ObjectStreamField("iterators", Vector.class),
+            new ObjectStreamField("ranges", Vector.class),
+            new ObjectStreamField("eventListeners", Hashtable.class),
+            new ObjectStreamField("mutationEvents", boolean.class),
+        };
+
     //
     // Constructors
     //
@@ -227,10 +249,10 @@
                                                      filter,
                                                      entityReferenceExpansion);
         if (iterators == null) {
-            iterators = new Vector();
+            iterators = new ArrayList<>();
         }
 
-        iterators.addElement(iterator);
+        iterators.add(iterator);
 
         return iterator;
     }
@@ -287,7 +309,7 @@
         if (nodeIterator == null) return;
         if (iterators == null) return;
 
-        iterators.removeElement(nodeIterator);
+        iterators.remove(nodeIterator);
     }
 
     //
@@ -298,12 +320,11 @@
     public Range createRange() {
 
         if (ranges == null) {
-            ranges = new Vector();
+            ranges = new ArrayList<>();
         }
 
         Range range = new RangeImpl(this);
-
-        ranges.addElement(range);
+        ranges.add(range);
 
         return range;
 
@@ -318,7 +339,7 @@
         if (range == null) return;
         if (ranges == null) return;
 
-        ranges.removeElement(range);
+        ranges.remove(range);
     }
 
     /**
@@ -330,7 +351,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).receiveReplacedText(node);
+                ((RangeImpl)ranges.get(i)).receiveReplacedText(node);
             }
         }
     }
@@ -344,7 +365,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).receiveDeletedText(node,
+                ((RangeImpl)ranges.get(i)).receiveDeletedText(node,
                                                                 offset, count);
             }
         }
@@ -359,7 +380,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).receiveInsertedText(node,
+                ((RangeImpl)ranges.get(i)).receiveInsertedText(node,
                                                                 offset, count);
             }
         }
@@ -374,7 +395,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).receiveSplitData(node,
+                ((RangeImpl)ranges.get(i)).receiveSplitData(node,
                                                               newNode, offset);
             }
         }
@@ -437,9 +458,9 @@
      * node here won't be GC'ed as long as some listener is registered on it,
      * since the eventsListeners table will have a reference to the node.
      */
-    protected void setEventListeners(NodeImpl n, Vector listeners) {
+    private void setEventListeners(NodeImpl n, List<LEntry> listeners) {
         if (eventListeners == null) {
-            eventListeners = new Hashtable();
+            eventListeners = new HashMap<>();
         }
         if (listeners == null) {
             eventListeners.remove(n);
@@ -457,11 +478,11 @@
     /**
      * Retreive event listener registered on a given node
      */
-    protected Vector getEventListeners(NodeImpl n) {
+    private List<LEntry> getEventListeners(NodeImpl n) {
         if (eventListeners == null) {
             return null;
         }
-        return (Vector) eventListeners.get(n);
+        return eventListeners.get(n);
     }
 
     //
@@ -515,6 +536,7 @@
      * @param useCapture True iff listener is registered on
      *  capturing phase rather than at-target or bubbling
      */
+    @Override
     protected void addEventListener(NodeImpl node, String type,
                                     EventListener listener, boolean useCapture)
     {
@@ -527,12 +549,12 @@
         // Simplest way to code that is to zap the previous entry, if any.
         removeEventListener(node, type, listener, useCapture);
 
-        Vector nodeListeners = getEventListeners(node);
+        List<LEntry> nodeListeners = getEventListeners(node);
         if(nodeListeners == null) {
-            nodeListeners = new Vector();
+            nodeListeners = new ArrayList<>();
             setEventListeners(node, nodeListeners);
         }
-        nodeListeners.addElement(new LEntry(type, listener, useCapture));
+        nodeListeners.add(new LEntry(type, listener, useCapture));
 
         // Record active listener
         LCount lc = LCount.lookup(type);
@@ -558,6 +580,7 @@
      * @param useCapture True iff listener is registered on
      *  capturing phase rather than at-target or bubbling
      */
+    @Override
     protected void removeEventListener(NodeImpl node, String type,
                                        EventListener listener,
                                        boolean useCapture)
@@ -565,7 +588,7 @@
         // If this couldn't be a valid listener registration, ignore request
         if (type == null || type.equals("") || listener == null)
             return;
-        Vector nodeListeners = getEventListeners(node);
+        List<LEntry> nodeListeners = getEventListeners(node);
         if (nodeListeners == null)
             return;
 
@@ -573,12 +596,12 @@
         // each listener may be registered only once per type per phase.
         // count-down is OK for deletions!
         for (int i = nodeListeners.size() - 1; i >= 0; --i) {
-            LEntry le = (LEntry) nodeListeners.elementAt(i);
+            LEntry le = nodeListeners.get(i);
             if (le.useCapture == useCapture && le.listener == listener &&
                 le.type.equals(type)) {
-                nodeListeners.removeElementAt(i);
+                nodeListeners.remove(i);
                 // Storage management: Discard empty listener lists
-                if (nodeListeners.size() == 0)
+                if (nodeListeners.isEmpty())
                     setEventListeners(node, null);
 
                 // Remove active listener
@@ -597,12 +620,13 @@
         }
     } // removeEventListener(NodeImpl,String,EventListener,boolean) :void
 
+    @Override
     protected void copyEventListeners(NodeImpl src, NodeImpl tgt) {
-        Vector nodeListeners = getEventListeners(src);
+        List<LEntry> nodeListeners = getEventListeners(src);
         if (nodeListeners == null) {
             return;
         }
-        setEventListeners(tgt, (Vector) nodeListeners.clone());
+        setEventListeners(tgt, new ArrayList<>(nodeListeners));
     }
 
     /**
@@ -655,6 +679,7 @@
      * @return true if the event's <code>preventDefault()</code>
      *              method was invoked by an EventListener; otherwise false.
     */
+    @Override
     protected boolean dispatchEvent(NodeImpl node, Event event) {
         if (event == null) return false;
 
@@ -691,11 +716,11 @@
         // is issued to the Element rather than the Attr
         // and causes a _second_ DOMSubtreeModified in the Element's
         // tree.
-        Vector pv = new Vector(10,10);
+        List<Node> pv = new ArrayList<>(10);
         Node p = node;
         Node n = p.getParentNode();
         while (n != null) {
-            pv.addElement(n);
+            pv.add(n);
             p = n;
             n = n.getParentNode();
         }
@@ -710,15 +735,15 @@
                     break;  // Someone set the flag. Phase ends.
 
                 // Handle all capturing listeners on this node
-                NodeImpl nn = (NodeImpl) pv.elementAt(j);
+                NodeImpl nn = (NodeImpl) pv.get(j);
                 evt.currentTarget = nn;
-                Vector nodeListeners = getEventListeners(nn);
+                List<LEntry> nodeListeners = getEventListeners(nn);
                 if (nodeListeners != null) {
-                    Vector nl = (Vector) nodeListeners.clone();
+                    List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
                     // call listeners in the order in which they got registered
                     int nlsize = nl.size();
                     for (int i = 0; i < nlsize; i++) {
-                        LEntry le = (LEntry) nl.elementAt(i);
+                        LEntry le = nl.get(i);
                         if (le.useCapture && le.type.equals(evt.type) &&
                             nodeListeners.contains(le)) {
                             try {
@@ -741,13 +766,13 @@
             // node are _not_ invoked, even during the capture phase.
             evt.eventPhase = Event.AT_TARGET;
             evt.currentTarget = node;
-            Vector nodeListeners = getEventListeners(node);
+            List<LEntry> nodeListeners = getEventListeners(node);
             if (!evt.stopPropagation && nodeListeners != null) {
-                Vector nl = (Vector) nodeListeners.clone();
+                List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
                 // call listeners in the order in which they got registered
                 int nlsize = nl.size();
                 for (int i = 0; i < nlsize; i++) {
-                    LEntry le = (LEntry) nl.elementAt(i);
+                    LEntry le = (LEntry) nl.get(i);
                     if (!le.useCapture && le.type.equals(evt.type) &&
                         nodeListeners.contains(le)) {
                         try {
@@ -772,16 +797,16 @@
                         break;  // Someone set the flag. Phase ends.
 
                     // Handle all bubbling listeners on this node
-                    NodeImpl nn = (NodeImpl) pv.elementAt(j);
+                    NodeImpl nn = (NodeImpl) pv.get(j);
                     evt.currentTarget = nn;
                     nodeListeners = getEventListeners(nn);
                     if (nodeListeners != null) {
-                        Vector nl = (Vector) nodeListeners.clone();
+                        List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
                         // call listeners in the order in which they got
                         // registered
                         int nlsize = nl.size();
                         for (int i = 0; i < nlsize; i++) {
-                            LEntry le = (LEntry) nl.elementAt(i);
+                            LEntry le = nl.get(i);
                             if (!le.useCapture && le.type.equals(evt.type) &&
                                 nodeListeners.contains(le)) {
                                 try {
@@ -1118,7 +1143,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).insertedNodeFromDOM(newInternal);
+                ((RangeImpl)ranges.get(i)).insertedNodeFromDOM(newInternal);
             }
         }
     }
@@ -1132,7 +1157,7 @@
         if (iterators != null) {
             int size = iterators.size();
             for (int i = 0; i != size; i++) {
-               ((NodeIteratorImpl)iterators.elementAt(i)).removeNode(oldChild);
+               ((NodeIteratorImpl)iterators.get(i)).removeNode(oldChild);
             }
         }
 
@@ -1140,7 +1165,7 @@
         if (ranges != null) {
             int size = ranges.size();
             for (int i = 0; i != size; i++) {
-                ((RangeImpl)ranges.elementAt(i)).removeNode(oldChild);
+                ((RangeImpl)ranges.get(i)).removeNode(oldChild);
             }
         }
 
@@ -1302,4 +1327,53 @@
         // REVISIT: To be implemented!!!
     }
 
+
+    /**
+     * @serialData Serialized fields. Convert Maps to Hashtables and Lists
+     * to Vectors for backward compatibility.
+     */
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        // Convert Maps to Hashtables, Lists to Vectors
+        Vector<NodeIterator> it = (iterators == null)? null : new Vector<>(iterators);
+        Vector<Range> r = (ranges == null)? null : new Vector<>(ranges);
+
+        Hashtable<NodeImpl, Vector<LEntry>> el = null;
+        if (eventListeners != null) {
+            el = new Hashtable<>();
+            for (Map.Entry<NodeImpl, List<LEntry>> e : eventListeners.entrySet()) {
+                 el.put(e.getKey(), new Vector<>(e.getValue()));
+            }
+        }
+
+        // Write serialized fields
+        ObjectOutputStream.PutField pf = out.putFields();
+        pf.put("iterators", it);
+        pf.put("ranges", r);
+        pf.put("eventListeners", el);
+        pf.put("mutationEvents", mutationEvents);
+        out.writeFields();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void readObject(ObjectInputStream in)
+                        throws IOException, ClassNotFoundException {
+        // We have to read serialized fields first.
+        ObjectInputStream.GetField gf = in.readFields();
+        Vector<NodeIterator> it = (Vector<NodeIterator>)gf.get("iterators", null);
+        Vector<Range> r = (Vector<Range>)gf.get("ranges", null);
+        Hashtable<NodeImpl, Vector<LEntry>> el =
+                (Hashtable<NodeImpl, Vector<LEntry>>)gf.get("eventListeners", null);
+
+        mutationEvents = gf.get("mutationEvents", false);
+
+        //convert Hashtables back to HashMaps and Vectors to Lists
+        if (it != null) iterators = new ArrayList<>(it);
+        if (r != null) ranges = new ArrayList<>(r);
+        if (el != null) {
+            eventListeners = new HashMap<>();
+            for (Map.Entry<NodeImpl, Vector<LEntry>> e : el.entrySet()) {
+                 eventListeners.put(e.getKey(), new ArrayList<>(e.getValue()));
+            }
+        }
+    }
 } // class DocumentImpl
--- a/src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,11 +20,17 @@
 
 package com.sun.org.apache.xerces.internal.dom;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DocumentType;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import java.util.Hashtable;
 import org.w3c.dom.UserDataHandler;
 
 /**
@@ -95,10 +101,37 @@
     // a number, on demand, for ordering purposes for compareDocumentPosition
     private int doctypeNumber=0;
 
+    private Map<String, UserDataRecord> userData =  null;
+
+
+    /**
+     * @serialField name String document type name
+     * @serialField entities NamedNodeMapImpl entities
+     * @serialField notations NamedNodeMapImpl notations
+     * @serialField elements NamedNodeMapImpl elements
+     * @serialField publicID String support public ID
+     * @serialField systemID String support system ID
+     * @serialField internalSubset String support internal subset
+     * @serialField doctypeNumber int Doctype number
+     * @serialField userData Hashtable user data
+     */
+    private static final ObjectStreamField[] serialPersistentFields =
+        new ObjectStreamField[] {
+            new ObjectStreamField("name", String.class),
+            new ObjectStreamField("entities", NamedNodeMapImpl.class),
+            new ObjectStreamField("notations", NamedNodeMapImpl.class),
+            new ObjectStreamField("elements", NamedNodeMapImpl.class),
+            new ObjectStreamField("publicID", String.class),
+            new ObjectStreamField("systemID", String.class),
+            new ObjectStreamField("internalSubset", String.class),
+            new ObjectStreamField("doctypeNumber", int.class),
+            new ObjectStreamField("userData", Hashtable.class),
+        };
+
     //
     // Constructors
     //
-    private Hashtable userData =  null;
+
     /** Factory method for creating a document type node. */
     public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name) {
         super(ownerDocument);
@@ -445,22 +478,20 @@
     public Object setUserData(String key,
     Object data, UserDataHandler handler) {
         if(userData == null)
-            userData = new Hashtable();
+            userData = new HashMap<>();
         if (data == null) {
             if (userData != null) {
-                Object o = userData.remove(key);
-                if (o != null) {
-                    UserDataRecord r = (UserDataRecord) o;
-                    return r.fData;
+                UserDataRecord udr = userData.remove(key);
+                if (udr != null) {
+                    return udr.fData;
                 }
             }
             return null;
         }
         else {
-            Object o = userData.put(key, new UserDataRecord(data, handler));
-            if (o != null) {
-                UserDataRecord r = (UserDataRecord) o;
-                return r.fData;
+            UserDataRecord udr = userData.put(key, new UserDataRecord(data, handler));
+            if (udr != null) {
+                return udr.fData;
             }
         }
         return null;
@@ -470,16 +501,58 @@
         if (userData == null) {
             return null;
         }
-        Object o = userData.get(key);
-        if (o != null) {
-            UserDataRecord r = (UserDataRecord) o;
-            return r.fData;
+        UserDataRecord udr = userData.get(key);
+        if (udr != null) {
+            return udr.fData;
         }
         return null;
     }
 
-    protected Hashtable getUserDataRecord(){
+    @Override
+    protected Map<String, UserDataRecord> getUserDataRecord(){
         return userData;
     }
 
+    /**
+     * @serialData Serialized fields. Convert Map to Hashtable for backward
+     * compatibility.
+     */
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        // Convert the HashMap to Hashtable
+        Hashtable<String, UserDataRecord> ud = (userData == null)? null : new Hashtable<>(userData);
+
+        // Write serialized fields
+        ObjectOutputStream.PutField pf = out.putFields();
+        pf.put("name", name);
+        pf.put("entities", entities);
+        pf.put("notations", notations);
+        pf.put("elements", elements);
+        pf.put("publicID", publicID);
+        pf.put("systemID", systemID);
+        pf.put("internalSubset", internalSubset);
+        pf.put("doctypeNumber", doctypeNumber);
+        pf.put("userData", ud);
+        out.writeFields();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void readObject(ObjectInputStream in)
+                        throws IOException, ClassNotFoundException {
+        // We have to read serialized fields first.
+        ObjectInputStream.GetField gf = in.readFields();
+        name = (String)gf.get("name", null);
+        entities = (NamedNodeMapImpl)gf.get("entities", null);
+        notations = (NamedNodeMapImpl)gf.get("notations", null);
+        elements = (NamedNodeMapImpl)gf.get("elements", null);
+        publicID = (String)gf.get("publicID", null);
+        systemID = (String)gf.get("systemID", null);
+        internalSubset = (String)gf.get("internalSubset", null);
+        doctypeNumber = gf.get("doctypeNumber", 0);
+
+        Hashtable<String, UserDataRecord> ud =
+                (Hashtable<String, UserDataRecord>)gf.get("userData", null);
+
+        //convert the Hashtable back to HashMap
+        if (ud != null) userData = new HashMap<>(ud);
+    }
 } // class DocumentTypeImpl
--- a/src/com/sun/org/apache/xerces/internal/dom/LCount.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/LCount.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,20 +22,13 @@
 
 /** Internal class LCount is used to track the number of
     listeners registered for a given event name, as an entry
-    in a global hashtable. This should allow us to avoid generating,
-    or discard, events for which no listeners are registered.
+    in a global Map. This should allow us to avoid generating,
+    or discarding, events for which no listeners are registered.
 
     ***** There should undoubtedly be methods here to manipulate
     this table. At the moment that code's residing in NodeImpl.
     Move it when we have a chance to do so. Sorry; we were
     rushed.
-
-    ???? CONCERN: Hashtables are known to be "overserialized" in
-    current versions of Java. That may impact performance.
-
-    ???? CONCERN: The hashtable should probably be a per-document object.
-    Finer granularity would be even better, but would cost more cycles to
-    resolve and might not save enough event traffic to be worth the investment.
 */
 /**
  * @xerces.internal
@@ -44,7 +37,7 @@
 
 class LCount
 {
-    static java.util.Hashtable lCounts=new java.util.Hashtable();
+    static final java.util.Map<String, LCount> lCounts=new java.util.concurrent.ConcurrentHashMap<>();
     public int captures=0,bubbles=0,defaults, total=0;
 
     static LCount lookup(String evtName)
--- a/src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
  /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,15 +23,14 @@
 import java.io.IOException;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.util.Hashtable;
-
-import org.w3c.dom.UserDataHandler;
+import java.util.Map;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+import org.w3c.dom.UserDataHandler;
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventListener;
 import org.w3c.dom.events.EventTarget;
@@ -1793,7 +1792,7 @@
         return ownerDocument().getUserData(this, key);
     }
 
-        protected Hashtable getUserDataRecord(){
+    protected Map<String, ParentNode.UserDataRecord> getUserDataRecord(){
         return ownerDocument().getUserDataRecord(this);
         }
 
@@ -1845,7 +1844,7 @@
      * NON-DOM: As an alternative to subclassing the DOM, this implementation
      * has been extended with the ability to attach an object to each node.
      * (If you need multiple objects, you can attach a collection such as a
-     * vector or hashtable, then attach your application information to that.)
+     * List or Map, then attach your application information to that.)
      * <p><b>Important Note:</b> You are responsible for removing references
      * to your data on nodes that are no longer used. Failure to do so will
      * prevent the nodes, your data is attached to, to be garbage collected
--- a/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,10 +20,10 @@
 
 package com.sun.org.apache.xerces.internal.dom;
 
-import java.io.Serializable;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -1023,7 +1023,7 @@
     /*
      * a class to store some user data along with its handler
      */
-    class UserDataRecord implements Serializable {
+    protected class UserDataRecord implements Serializable {
         /** Serialization version. */
         private static final long serialVersionUID = 3258126977134310455L;
 
--- a/src/com/sun/org/apache/xerces/internal/impl/Constants.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/Constants.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -242,6 +242,14 @@
      */
     public static final String JDK_GENEAL_ENTITY_SIZE_LIMIT =
             ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String JDK_ENTITY_REPLACEMENT_LIMIT =
+            ORACLE_JAXP_PROPERTY_PREFIX + "entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
@@ -295,6 +303,13 @@
      * JDK maximum general entity size limit
      */
     public static final String SP_GENEAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String SP_ENTITY_REPLACEMENT_LIMIT = "jdk.xml.entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,62 +1,21 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2004 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
@@ -156,7 +115,7 @@
     protected boolean scanPubidLiteral(XMLString literal)
         throws IOException, XNIException
     {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -167,7 +126,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             // REVISIT:  it could really only be \n or 0x20; all else is normalized, no?  - neilg
             if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
                 if (!skipSpace) {
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,74 +1,32 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2004 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
 
-import java.io.IOException;
-
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
+import java.io.IOException;
 
 /**
  * This class is responsible for scanning XML document structure
@@ -135,7 +93,7 @@
             // happens when there is the character reference &#13;
             // but scanContent doesn't do entity expansions...
             // is this *really* necessary???  - NG
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             content.append((char)c);
             c = -1;
         }
@@ -144,7 +102,7 @@
         } */
 
         if (c == ']') {
-            content.append((char)fEntityScanner.scanChar());
+            content.append((char)fEntityScanner.scanChar(null));
             // remember where we are in case we get an endEntity before we
             // could flush the buffer out - this happens when we're parsing an
             // entity which ends with a ]
@@ -153,12 +111,12 @@
             // We work on a single character basis to handle cases such as:
             // ']]]>' which we might otherwise miss.
             //
-            if (fEntityScanner.skipChar(']')) {
+            if (fEntityScanner.skipChar(']', null)) {
                 content.append(']');
-                while (fEntityScanner.skipChar(']')) {
+                while (fEntityScanner.skipChar(']', null)) {
                     content.append(']');
                 }
-                if (fEntityScanner.skipChar('>')) {
+                if (fEntityScanner.skipChar('>', null)) {
                     reportFatalError("CDEndInContent", null);
                 }
             }
@@ -185,6 +143,7 @@
      * @param checkEntities true if undeclared entities should be reported as VC violation,
      *                      false if undeclared entities should be reported as WFC violation.
      * @param eleName The name of element to which this attribute belongs.
+     * @param isNSURI The flag indicating whether the content is a namespace URI
      *
      * @return true if the non-normalized and normalized value are the same
      *
@@ -194,7 +153,7 @@
     protected boolean scanAttributeValue(XMLString value,
                                       XMLString nonNormalizedValue,
                                       String atName,
-                                      boolean checkEntities,String eleName)
+                                      boolean checkEntities,String eleName, boolean isNSURI)
         throws IOException, XNIException
     {
         // quote
@@ -203,10 +162,10 @@
             reportFatalError("OpenQuoteExpected", new Object[]{eleName,atName});
         }
 
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
         int entityDepth = fEntityDepth;
 
-        int c = fEntityScanner.scanLiteral(quote, value);
+        int c = fEntityScanner.scanLiteral(quote, value, isNSURI);
         if (DEBUG_ATTR_NORMALIZATION) {
             System.out.println("** scanLiteral -> \""
                                + value.toString() + "\"");
@@ -216,7 +175,7 @@
         if (c == quote && (fromIndex = isUnchangedByNormalization(value)) == -1) {
             /** Both the non-normalized and normalized attribute values are equal. **/
             nonNormalizedValue.setValues(value);
-            int cquote = fEntityScanner.scanChar();
+            int cquote = fEntityScanner.scanChar(NameType.ATTRIBUTE);
             if (cquote != quote) {
                 reportFatalError("CloseQuoteExpected", new Object[]{eleName,atName});
             }
@@ -239,11 +198,11 @@
                                        + fStringBuffer.toString() + "\"");
                 }
                 if (c == '&') {
-                    fEntityScanner.skipChar('&');
+                    fEntityScanner.skipChar('&', NameType.REFERENCE);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append('&');
                     }
-                    if (fEntityScanner.skipChar('#')) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append('#');
                         }
@@ -257,59 +216,22 @@
                         }
                     }
                     else {
-                        String entityName = fEntityScanner.scanName();
+                        String entityName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (entityName == null) {
                             reportFatalError("NameRequiredInReference", null);
                         }
                         else if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append(entityName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                                              new Object []{entityName});
                         }
                         else if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append(';');
                         }
-                        if (entityName == fAmpSymbol) {
-                            fStringBuffer.append('&');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value5: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fAposSymbol) {
-                            fStringBuffer.append('\'');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value7: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fLtSymbol) {
-                            fStringBuffer.append('<');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value9: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fGtSymbol) {
-                            fStringBuffer.append('>');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueB: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fQuotSymbol) {
-                            fStringBuffer.append('"');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueD: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
+                        if (resolveCharacter(entityName, fStringBuffer)) {
+                            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
                         }
                         else {
                             if (fEntityManager.isExternalEntity(entityName)) {
@@ -332,7 +254,7 @@
                                                          new Object[]{entityName});
                                     }
                                 }
-                                fEntityManager.startEntity(entityName, true);
+                                fEntityManager.startEntity(true, entityName, true);
                             }
                         }
                     }
@@ -340,13 +262,13 @@
                 else if (c == '<') {
                     reportFatalError("LessthanInAttValue",
                                      new Object[] { eleName, atName });
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
                     }
                 }
                 else if (c == '%' || c == ']') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append((char)c);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
@@ -360,7 +282,7 @@
                 // XML11EntityScanner.  Not sure why
                 // this check was originally necessary.  - NG
                 else if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(' ');
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append('\n');
@@ -383,12 +305,12 @@
                 else if (c != -1 && isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInAttValue",
                                      new Object[] {eleName, atName, Integer.toString(c, 16)});
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
                     }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, isNSURI);
                 if (entityDepth == fEntityDepth) {
                     fStringBuffer2.append(value);
                 }
@@ -405,7 +327,7 @@
         nonNormalizedValue.setValues(fStringBuffer2);
 
         // quote
-        int cquote = fEntityScanner.scanChar();
+        int cquote = fEntityScanner.scanChar(null);
         if (cquote != quote) {
             reportFatalError("CloseQuoteExpected", new Object[]{eleName,atName});
         }
@@ -440,7 +362,7 @@
     protected boolean scanPubidLiteral(XMLString literal)
         throws IOException, XNIException
     {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -451,7 +373,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             // REVISIT:  none of these except \n and 0x20 should make it past the entity scanner
             if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
                 if (!skipSpace) {
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,72 +1,34 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2002 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
 
+import com.sun.org.apache.xerces.internal.impl.XMLScanner.NameType;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
+import com.sun.xml.internal.stream.Entity;
 import java.io.IOException;
 
 /**
@@ -132,7 +94,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanChar() throws IOException {
+    protected int scanChar(NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -140,6 +102,7 @@
         }
 
         // scan character
+        int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[fCurrentEntity.position++];
         boolean external = false;
         if (c == '\n' ||
@@ -150,6 +113,7 @@
                 invokeListeners(1);
                 fCurrentEntity.ch[0] = (char)c;
                 load(1, false, false);
+                offset = 0;
             }
             if (c == '\r' && external) {
                 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
@@ -162,6 +126,9 @@
 
         // return character that was scanned
         fCurrentEntity.columnNumber++;
+        if (!detectingVersion) {
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
+        }
         return c;
 
     } // scanChar():int
@@ -181,7 +148,7 @@
      * @see com.sun.org.apache.xerces.internal.util.SymbolTable
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      */
-    public String scanNmtoken() throws IOException {
+    protected String scanNmtoken() throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
             load(0, true, true);
@@ -288,6 +255,8 @@
      * <strong>Note:</strong> The string returned must be a symbol. The
      * SymbolTable can be used for this purpose.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      *
@@ -295,7 +264,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
      */
-    public String scanName() throws IOException {
+    protected String scanName(NameType nt) throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
             load(0, true, true);
@@ -350,23 +319,11 @@
             return null;
         }
 
+        int length = 0;
         do {
             ch = fCurrentEntity.ch[fCurrentEntity.position];
             if (XML11Char.isXML11Name(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -374,20 +331,7 @@
                 }
             }
             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         --fCurrentEntity.position;
@@ -401,20 +345,7 @@
                     --fCurrentEntity.position;
                     break;
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -427,12 +358,14 @@
         }
         while (true);
 
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         // return name
         String symbol = null;
         if (length > 0) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
         }
         return symbol;
@@ -455,7 +388,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCName
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCNameStart
      */
-    public String scanNCName() throws IOException {
+    protected String scanNCName() throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -611,6 +544,7 @@
      * this purpose.
      *
      * @param qname The qualified name structure to fill.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if a qualified name appeared immediately on
      *         the input and was scanned, false otherwise.
@@ -622,7 +556,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
      */
-    public boolean scanQName(QName qname) throws IOException {
+    protected boolean scanQName(QName qname, XMLScanner.NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -642,6 +576,7 @@
                     fCurrentEntity.columnNumber++;
                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
                     qname.setValues(null, name, name, null);
+                    checkEntityLimit(nt, fCurrentEntity, 0, 1);
                     return true;
                 }
             }
@@ -672,6 +607,7 @@
                     fCurrentEntity.columnNumber += 2;
                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
                     qname.setValues(null, name, name, null);
+                    checkEntityLimit(nt, fCurrentEntity, 0, 2);
                     return true;
                 }
             }
@@ -681,6 +617,7 @@
         }
 
         int index = -1;
+        int length = 0;
         boolean sawIncompleteSurrogatePair = false;
         do {
             ch = fCurrentEntity.ch[fCurrentEntity.position];
@@ -690,21 +627,10 @@
                         break;
                     }
                     index = fCurrentEntity.position;
+                    //check prefix before further read
+                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -715,20 +641,7 @@
                 }
             }
             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -747,20 +660,7 @@
                     --fCurrentEntity.position;
                     break;
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -776,7 +676,7 @@
         }
         while (true);
 
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         if (length > 0) {
@@ -786,6 +686,8 @@
                                                     offset, length);
             if (index != -1) {
                 int prefixLength = index - offset;
+                //check the result: prefix
+                checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, prefixLength);
                 prefix = fSymbolTable.addSymbol(fCurrentEntity.ch,
                                                     offset, prefixLength);
                 int len = length - prefixLength - 1;
@@ -798,14 +700,19 @@
                                                null,
                                                XMLErrorReporter.SEVERITY_FATAL_ERROR);
                 }
+                //check the result: localpart
+                checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, index + 1, len);
                 localpart = fSymbolTable.addSymbol(fCurrentEntity.ch,
                                                    index + 1, len);
 
             }
             else {
                 localpart = rawname;
+                //check the result: localpart
+                checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
             }
             qname.setValues(prefix, localpart, rawname, null);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             return true;
         }
         return false;
@@ -838,7 +745,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanContent(XMLString content) throws IOException {
+    protected int scanContent(XMLString content) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -856,6 +763,7 @@
         int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[offset];
         int newlines = 0;
+        boolean counted = false;
         boolean external = fCurrentEntity.isExternal();
         if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
             do {
@@ -865,11 +773,13 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
                         fCurrentEntity.position = newlines;
                         fCurrentEntity.startPosition = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -888,11 +798,13 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
                         fCurrentEntity.position = newlines;
                         fCurrentEntity.startPosition = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -907,6 +819,7 @@
             }
             int length = fCurrentEntity.position - offset;
             if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                checkEntityLimit(null, fCurrentEntity, offset, length);
                 content.setValues(fCurrentEntity.ch, offset, length);
                 return -1;
             }
@@ -934,6 +847,9 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+        if (!counted) {
+            checkEntityLimit(null, fCurrentEntity, offset, length);
+        }
         content.setValues(fCurrentEntity.ch, offset, length);
 
         // return next character
@@ -972,6 +888,7 @@
      * @param quote   The quote character that signifies the end of the
      *                attribute value data.
      * @param content The content structure to fill.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * @return Returns the next character on the input, if known. This
      *         value may be -1 but this does <em>note</em> designate
@@ -980,7 +897,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanLiteral(int quote, XMLString content)
+    protected int scanLiteral(int quote, XMLString content, boolean isNSURI)
         throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1078,6 +995,11 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+
+        checkEntityLimit(null, fCurrentEntity, offset, length);
+        if (isNSURI) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+        }
         content.setValues(fCurrentEntity.ch, offset, length);
 
         // return next character
@@ -1127,7 +1049,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean scanData(String delimiter, XMLStringBuffer buffer)
+    protected boolean scanData(String delimiter, XMLStringBuffer buffer)
         throws IOException {
 
         boolean done = false;
@@ -1159,6 +1081,7 @@
             if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
                 // something must be wrong with the input:  e.g., file ends  an unterminated comment
                 int length = fCurrentEntity.count - fCurrentEntity.position;
+                checkEntityLimit(NameType.COMMENT, fCurrentEntity, fCurrentEntity.position, length);
                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
                 fCurrentEntity.columnNumber += fCurrentEntity.count;
                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
@@ -1223,6 +1146,7 @@
                 }
                 int length = fCurrentEntity.position - offset;
                 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     return true;
                 }
@@ -1261,6 +1185,7 @@
                         fCurrentEntity.position--;
                         int length = fCurrentEntity.position - offset;
                         fCurrentEntity.columnNumber += length - newlines;
+                        checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                         buffer.append(fCurrentEntity.ch, offset, length);
                         return true;
                     }
@@ -1298,6 +1223,7 @@
                         fCurrentEntity.position--;
                         int length = fCurrentEntity.position - offset;
                         fCurrentEntity.columnNumber += length - newlines;
+                        checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                         buffer.append(fCurrentEntity.ch, offset, length);
                         return true;
                     }
@@ -1305,6 +1231,7 @@
             }
             int length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length - newlines;
+            checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
             if (done) {
                 length -= delimLen;
             }
@@ -1329,7 +1256,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipChar(int c) throws IOException {
+    protected boolean skipChar(int c, NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1337,6 +1264,7 @@
         }
 
         // skip character
+        int offset = fCurrentEntity.position;
         int cc = fCurrentEntity.ch[fCurrentEntity.position];
         if (cc == c) {
             fCurrentEntity.position++;
@@ -1347,12 +1275,14 @@
             else {
                 fCurrentEntity.columnNumber++;
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
         else if (c == '\n' && ((cc == 0x2028 || cc == 0x85) && fCurrentEntity.isExternal())) {
             fCurrentEntity.position++;
             fCurrentEntity.lineNumber++;
             fCurrentEntity.columnNumber = 1;
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
         else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
@@ -1368,6 +1298,7 @@
             }
             fCurrentEntity.lineNumber++;
             fCurrentEntity.columnNumber = 1;
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
 
@@ -1390,7 +1321,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Space
      */
-    public boolean skipSpaces() throws IOException {
+    protected boolean skipSpaces() throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1410,7 +1341,7 @@
 
         // skip spaces
         int c = fCurrentEntity.ch[fCurrentEntity.position];
-
+        int offset = fCurrentEntity.position - 1;
         // External --  Match: S + 0x85 + 0x2028, and perform end of line normalization
         if (fCurrentEntity.isExternal()) {
             if (XML11Char.isXML11Space(c)) {
@@ -1446,6 +1377,11 @@
                     else {
                         fCurrentEntity.columnNumber++;
                     }
+
+                    //If this is a general entity, spaces within a start element should be counted
+                    checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                    offset = fCurrentEntity.position;
+
                     // load more characters, if needed
                     if (!entityChanged)
                         fCurrentEntity.position++;
@@ -1485,6 +1421,11 @@
                 else {
                     fCurrentEntity.columnNumber++;
                 }
+
+                //If this is a general entity, spaces within a start element should be counted
+                checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                offset = fCurrentEntity.position;
+
                 // load more characters, if needed
                 if (!entityChanged)
                     fCurrentEntity.position++;
@@ -1518,7 +1459,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipString(String s) throws IOException {
+    protected boolean skipString(String s) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1527,6 +1468,7 @@
 
         // skip string
         final int length = s.length();
+        final int beforeSkip = fCurrentEntity.position ;
         for (int i = 0; i < length; i++) {
             char c = fCurrentEntity.ch[fCurrentEntity.position++];
             if (c != s.charAt(i)) {
@@ -1546,6 +1488,9 @@
             }
         }
         fCurrentEntity.columnNumber += length;
+        if (!detectingVersion) {
+            checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+        }
         return true;
 
     } // skipString(String):boolean
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,62 +1,21 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2003 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.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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.
+ * 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
  *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 2002, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
@@ -67,6 +26,7 @@
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
@@ -176,7 +136,7 @@
         if (DEBUG_START_END_ELEMENT)
             System.out.println(">>> scanStartElementNS()");
                 // Note: namespace processing is on by default
-        fEntityScanner.scanQName(fElementQName);
+        fEntityScanner.scanQName(fElementQName, NameType.ATTRIBUTE);
         // REVISIT - [Q] Why do we need this local variable? -- mrglavas
         String rawname = fElementQName.rawname;
         if (fBindNamespaces) {
@@ -214,11 +174,11 @@
             // end tag?
             int c = fEntityScanner.peekChar();
             if (c == '>') {
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 break;
             } else if (c == '/') {
-                fEntityScanner.scanChar();
-                if (!fEntityScanner.skipChar('>')) {
+                fEntityScanner.scanChar(null);
+                if (!fEntityScanner.skipChar('>', null)) {
                     reportFatalError(
                         "ElementUnterminated",
                         new Object[] { rawname });
@@ -340,36 +300,37 @@
         }
 
         // call handler
-
-            if (empty) {
-
-                //decrease the markup depth..
-                fMarkupDepth--;
+        if (empty) {
+            //decrease the markup depth..
+            fMarkupDepth--;
 
-                // check that this element was opened in the same entity
-                if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
-                    reportFatalError(
-                        "ElementEntityMismatch",
-                        new Object[] { fCurrentElement.rawname });
-                }
+            // check that this element was opened in the same entity
+            if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
+                reportFatalError(
+                    "ElementEntityMismatch",
+                    new Object[] { fCurrentElement.rawname });
+            }
 
+            if (fDocumentHandler != null) {
                 fDocumentHandler.emptyElement(fElementQName, fAttributes, null);
+            }
 
-                /*if (fBindNamespaces) {
-                    fNamespaceContext.popContext();
-                }*/
-                fScanEndElement = true;
+            /*if (fBindNamespaces) {
+                fNamespaceContext.popContext();
+            }*/
+            fScanEndElement = true;
 
-                //pop the element off the stack..
-                fElementStack.popElement();
-            } else {
+            //pop the element off the stack..
+            fElementStack.popElement();
+        } else {
+            if(dtdGrammarUtil != null) {
+                dtdGrammarUtil.startElement(fElementQName, fAttributes);
+            }
 
-                if(dtdGrammarUtil != null)
-                    dtdGrammarUtil.startElement(fElementQName, fAttributes);
-
-                if (fDocumentHandler != null)
+            if (fDocumentHandler != null) {
                 fDocumentHandler.startElement(fElementQName, fAttributes, null);
             }
+        }
 
         if (DEBUG_START_END_ELEMENT)
             System.out.println("<<< scanStartElement(): " + empty);
@@ -385,7 +346,7 @@
     protected void scanStartElementName ()
         throws IOException, XNIException {
         // Note: namespace processing is on by default
-        fEntityScanner.scanQName(fElementQName);
+        fEntityScanner.scanQName(fElementQName, NameType.ATTRIBUTE);
         // Must skip spaces here because the DTD scanner
         // would consume them at the end of the external subset.
         fSawSpace = fEntityScanner.skipSpaces();
@@ -435,11 +396,11 @@
             // end tag?
             int c = fEntityScanner.peekChar();
             if (c == '>') {
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 break;
             } else if (c == '/') {
-                fEntityScanner.scanChar();
-                if (!fEntityScanner.skipChar('>')) {
+                fEntityScanner.scanChar(null);
+                if (!fEntityScanner.skipChar('>', null)) {
                     reportFatalError(
                         "ElementUnterminated",
                         new Object[] { rawname });
@@ -611,11 +572,11 @@
             System.out.println(">>> scanAttribute()");
 
         // name
-        fEntityScanner.scanQName(fAttributeQName);
+        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTE);
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError(
                 "EqRequiredInAttribute",
                 new Object[] {
@@ -654,13 +615,20 @@
         //REVISIT: one more case needs to be included: external PE and standalone is no
         boolean isVC = fHasExternalDTD && !fStandalone;
 
-        // REVISIT: it seems that this function should not take attributes, and length
-        scanAttributeValue(
-            this.fTempString,
-            fTempString2,
-            fAttributeQName.rawname,
-            isVC,
-            fCurrentElement.rawname);
+        /**
+         * Determine whether this is a namespace declaration that will be subject
+         * to the name limit check in the scanAttributeValue operation.
+         * Namespace declaration format: xmlns="..." or xmlns:prefix="..."
+         * Note that prefix:xmlns="..." isn't a namespace.
+         */
+        String localpart = fAttributeQName.localpart;
+        String prefix = fAttributeQName.prefix != null
+                ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
+        boolean isNSDecl = fBindNamespaces & (prefix == XMLSymbols.PREFIX_XMLNS ||
+                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS);
+
+        scanAttributeValue(this.fTempString, fTempString2, fAttributeQName.rawname,
+            isVC, fCurrentElement.rawname, isNSDecl);
         String value = fTempString.toString();
         attributes.setValue(attrIndex, value);
         attributes.setNonNormalizedValue(attrIndex, fTempString2.toString());
@@ -668,18 +636,14 @@
 
         // record namespace declarations if any.
         if (fBindNamespaces) {
-
-            String localpart = fAttributeQName.localpart;
-            String prefix =
-                fAttributeQName.prefix != null
-                    ? fAttributeQName.prefix
-                    : XMLSymbols.EMPTY_STRING;
-            // when it's of form xmlns="..." or xmlns:prefix="...",
-            // it's a namespace declaration. but prefix:xmlns="..." isn't.
-            if (prefix == XMLSymbols.PREFIX_XMLNS
-                || prefix == XMLSymbols.EMPTY_STRING
-                && localpart == XMLSymbols.PREFIX_XMLNS) {
-
+            if (isNSDecl) {
+                if (value.length() > fXMLNameLimit) {
+                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+                            "MaxXMLNameLimit",
+                            new Object[]{value, value.length(), fXMLNameLimit,
+                            fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.MAX_NAME_LIMIT)},
+                            XMLErrorReporter.SEVERITY_FATAL_ERROR);
+                }
                 // get the internalized value of this attribute
                 String uri = fSymbolTable.addSymbol(value);
 
@@ -792,7 +756,7 @@
 
         // end
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
             reportFatalError(
                 "ETagUnterminated",
                 new Object[] { endElementName.rawname });
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -41,9 +41,6 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
-import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
-import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.xml.internal.stream.Entity;
@@ -369,6 +366,9 @@
                 }
                 // we're done, set starting state for external subset
                 setScannerState(SCANNER_STATE_TEXT_DECL);
+                // we're done scanning DTD.
+                fLimitAnalyzer.reset(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT);
+                fLimitAnalyzer.reset(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT);
                 return false;
             }
         } while (complete);
@@ -378,6 +378,26 @@
 
     } // scanDTDInternalSubset(boolean,boolean,boolean):boolean
 
+    /**
+     * Skip the DTD if javax.xml.stream.supportDTD is false.
+     *
+     * @param supportDTD The value of the property javax.xml.stream.supportDTD.
+     * @return true if DTD is skipped, false otherwise.
+     * @throws java.io.IOException if i/o error occurs
+     */
+    @Override
+    public boolean skipDTD(boolean supportDTD) throws IOException {
+        if (!supportDTD) {
+            fStringBuffer.clear();
+            if (!fEntityScanner.scanData("]", fStringBuffer)) {
+                fEntityScanner.fCurrentEntity.position--;
+            }
+
+            return true;
+        }
+        return false;
+    }
+
     //
     // XMLComponent methods
     //
@@ -704,7 +724,7 @@
             fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",
             new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
         }
-        fEntityManager.startEntity(fSymbolTable.addSymbol(pName),
+        fEntityManager.startEntity(false, fSymbolTable.addSymbol(pName),
         literal);
         // if we actually got a new entity and it's external
         // parse text decl if there is any
@@ -738,7 +758,7 @@
                 fStringBuffer.clear();
                 fStringBuffer.append("xml");
                 while (isValidNameChar(fEntityScanner.peekChar())) {
-                    fStringBuffer.append((char)fEntityScanner.scanChar());
+                    fStringBuffer.append((char)fEntityScanner.scanChar(null));
                 }
                 String target =
                 fSymbolTable.addSymbol(fStringBuffer.ch,
@@ -838,7 +858,7 @@
         }
 
         // element name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
         if (name == null) {
             reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL",
             null);
@@ -871,7 +891,7 @@
             }
         }
         else {
-            if (!fEntityScanner.skipChar('(')) {
+            if (!fEntityScanner.skipChar('(', null)) {
                 reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",
                 new Object[]{name});
             }
@@ -901,7 +921,7 @@
         fReportEntity = false;
         skipSeparator(false, !scanningInternalSubset());
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("ElementDeclUnterminated", new Object[]{name});
         }
         fReportEntity = true;
@@ -938,7 +958,7 @@
             fDTDContentModelHandler.pcdata(null);
         }
         skipSeparator(false, !scanningInternalSubset());
-        while (fEntityScanner.skipChar('|')) {
+        while (fEntityScanner.skipChar('|', null)) {
             fStringBuffer.append('|');
             // call handler
             if (fDTDContentModelHandler != null) {
@@ -947,7 +967,7 @@
             }
             skipSeparator(false, !scanningInternalSubset());
 
-            childName = fEntityScanner.scanName();
+            childName = fEntityScanner.scanName(NameType.ENTITY);
             if (childName == null) {
                 reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT",
                 new Object[]{elName});
@@ -976,7 +996,7 @@
             reportFatalError("MixedContentUnterminated",
             new Object[]{elName});
         }
-        else if (fEntityScanner.skipChar(')')){
+        else if (fEntityScanner.skipChar(')', null)){
             fStringBuffer.append(')');
             // call handler
             if (fDTDContentModelHandler != null) {
@@ -1014,7 +1034,7 @@
         int currentOp = 0;
         int c;
         while (true) {
-            if (fEntityScanner.skipChar('(')) {
+            if (fEntityScanner.skipChar('(', null)) {
                 fMarkUpDepth++;
                 fStringBuffer.append('(');
                 // call handler
@@ -1028,7 +1048,7 @@
                 continue;
             }
             skipSeparator(false, !scanningInternalSubset());
-            String childName = fEntityScanner.scanName();
+            String childName = fEntityScanner.scanName(NameType.ELEMENTSTART);
             if (childName == null) {
                 reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",
                 new Object[]{elName});
@@ -1055,7 +1075,7 @@
                     }
                     fDTDContentModelHandler.occurrence(oc, null);
                 }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 fStringBuffer.append((char)c);
             }
             while (true) {
@@ -1068,7 +1088,7 @@
                         fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_SEQUENCE,
                         null);
                     }
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(',');
                     break;
                 }
@@ -1079,7 +1099,7 @@
                         fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_CHOICE,
                         null);
                     }
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append('|');
                     break;
                 }
@@ -1125,7 +1145,7 @@
                 }
                 else {
                     // no occurrence specified
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(')');
                 }
                 fMarkUpDepth--;
@@ -1157,7 +1177,7 @@
         }
 
         // element name
-        String elName = fEntityScanner.scanName();
+        String elName = fEntityScanner.scanName(NameType.ELEMENTSTART);
         if (elName == null) {
             reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL",
             null);
@@ -1171,7 +1191,7 @@
         // spaces
         if (!skipSeparator(true, !scanningInternalSubset())) {
             // no space, is it the end yet?
-            if (fEntityScanner.skipChar('>')) {
+            if (fEntityScanner.skipChar('>', null)) {
                 // yes, stop here
                 // call handler
                 if (fDTDHandler != null) {
@@ -1187,8 +1207,8 @@
         }
 
         // definitions
-        while (!fEntityScanner.skipChar('>')) {
-            String name = fEntityScanner.scanName();
+        while (!fEntityScanner.skipChar('>', null)) {
+            String name = fEntityScanner.scanName(NameType.ATTRIBUTE);
             if (name == null) {
                 reportFatalError("AttNameRequiredInAttDef",
                 new Object[]{elName});
@@ -1324,7 +1344,7 @@
                 new Object[]{elName, atName});
             }
             // open paren
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c != '(') {
                 reportFatalError("MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE",
                 new Object[]{elName, atName});
@@ -1332,7 +1352,7 @@
             fMarkUpDepth++;
             do {
                 skipSeparator(false, !scanningInternalSubset());
-                String aName = fEntityScanner.scanName();
+                String aName = fEntityScanner.scanName(NameType.ATTRIBUTE);
                 if (aName == null) {
                     reportFatalError("MSG_NAME_REQUIRED_IN_NOTATIONTYPE",
                     new Object[]{elName, atName});
@@ -1340,7 +1360,7 @@
                 ensureEnumerationSize(fEnumerationCount + 1);
                 fEnumeration[fEnumerationCount++] = aName;
                 skipSeparator(false, !scanningInternalSubset());
-                c = fEntityScanner.scanChar();
+                c = fEntityScanner.scanChar(null);
             } while (c == '|');
             if (c != ')') {
                 reportFatalError("NotationTypeUnterminated",
@@ -1351,7 +1371,7 @@
         else {              // Enumeration
             type = "ENUMERATION";
             // open paren
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c != '(') {
                 //                       "OPEN_PAREN_REQUIRED_BEFORE_ENUMERATION_IN_ATTRDECL",
                 reportFatalError("AttTypeRequiredInAttDef",
@@ -1368,7 +1388,7 @@
                 ensureEnumerationSize(fEnumerationCount + 1);
                 fEnumeration[fEnumerationCount++] = token;
                 skipSeparator(false, !scanningInternalSubset());
-                c = fEntityScanner.scanChar();
+                c = fEntityScanner.scanChar(null);
             } while (c == '|');
             if (c != ')') {
                 reportFatalError("EnumerationUnterminated",
@@ -1418,7 +1438,7 @@
             // AttValue
             boolean isVC = !fStandalone  &&  (fSeenExternalDTD || fSeenExternalPE) ;
             scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,
-            fAttributes, 0, isVC, elName);
+            fAttributes, 0, isVC, elName, false);
         }
         return defaultType;
 
@@ -1446,7 +1466,7 @@
         boolean sawPERef = false;
         fReportEntity = false;
         if (fEntityScanner.skipSpaces()) {
-            if (!fEntityScanner.skipChar('%')) {
+            if (!fEntityScanner.skipChar('%', NameType.REFERENCE)) {
                 isPEDecl = false; // <!ENTITY x "x">
             }
             else if (skipSeparator(true, !scanningInternalSubset())) {
@@ -1467,7 +1487,7 @@
                 sawPERef = true;
             }
         }
-        else if (scanningInternalSubset() || !fEntityScanner.skipChar('%')) {
+        else if (scanningInternalSubset() || !fEntityScanner.skipChar('%', NameType.REFERENCE)) {
             // <!ENTITY[^ ]...> or <!ENTITY[^ %]...>
             reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL",
             null);
@@ -1484,11 +1504,11 @@
         }
         if (sawPERef) {
             while (true) {
-                String peName = fEntityScanner.scanName();
+                String peName = fEntityScanner.scanName(NameType.REFERENCE);
                 if (peName == null) {
                     reportFatalError("NameRequiredInPEReference", null);
                 }
-                else if (!fEntityScanner.skipChar(';')) {
+                else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                     reportFatalError("SemicolonRequiredInPEReference",
                     new Object[]{peName});
                 }
@@ -1496,20 +1516,20 @@
                     startPE(peName, false);
                 }
                 fEntityScanner.skipSpaces();
-                if (!fEntityScanner.skipChar('%'))
+                if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                     break;
                 if (!isPEDecl) {
                     if (skipSeparator(true, !scanningInternalSubset())) {
                         isPEDecl = true;
                         break;
                     }
-                    isPEDecl = fEntityScanner.skipChar('%');
+                    isPEDecl = fEntityScanner.skipChar('%', NameType.REFERENCE);
                 }
             }
         }
 
         // name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.ENTITY);
         if (name == null) {
             reportFatalError("MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL", null);
         }
@@ -1544,7 +1564,7 @@
                 reportFatalError("MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL",
                 new Object[]{name});
             }
-            notation = fEntityScanner.scanName();
+            notation = fEntityScanner.scanName(NameType.NOTATION);
             if (notation == null) {
                 reportFatalError("MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL",
                 new Object[]{name});
@@ -1566,7 +1586,7 @@
         skipSeparator(false, !scanningInternalSubset());
 
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("EntityDeclUnterminated", new Object[]{name});
         }
         fMarkUpDepth--;
@@ -1621,7 +1641,7 @@
     protected final void scanEntityValue(String entityName, boolean isPEDecl, XMLString value,
     XMLString nonNormalizedValue)
     throws IOException, XNIException {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("OpenQuoteMissingInDecl", null);
         }
@@ -1632,29 +1652,28 @@
         XMLString literal2 = fString;
         int countChar = 0;
         if (fLimitAnalyzer == null ) {
-            fLimitAnalyzer = new XMLLimitAnalyzer();
+            fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
          }
             fLimitAnalyzer.startEntity(entityName);
 
-        if (fEntityScanner.scanLiteral(quote, fString) != quote) {
+        if (fEntityScanner.scanLiteral(quote, fString, false) != quote) {
             fStringBuffer.clear();
             fStringBuffer2.clear();
+            int offset;
             do {
-                if (isPEDecl && fLimitAnalyzer != null) {
-                    checkLimit("%" + entityName, fString.length + countChar);
-                }
                 countChar = 0;
+                offset = fStringBuffer.length;
                 fStringBuffer.append(fString);
                 fStringBuffer2.append(fString);
-                if (fEntityScanner.skipChar('&')) {
-                    if (fEntityScanner.skipChar('#')) {
+                if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         fStringBuffer2.append("&#");
                         scanCharReferenceValue(fStringBuffer, fStringBuffer2);
                     }
                     else {
                         fStringBuffer.append('&');
                         fStringBuffer2.append('&');
-                        String eName = fEntityScanner.scanName();
+                        String eName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (eName == null) {
                             reportFatalError("NameRequiredInReference",
                             null);
@@ -1663,7 +1682,7 @@
                             fStringBuffer.append(eName);
                             fStringBuffer2.append(eName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                             new Object[]{eName});
                         }
@@ -1673,15 +1692,15 @@
                         }
                     }
                 }
-                else if (fEntityScanner.skipChar('%')) {
+                else if (fEntityScanner.skipChar('%', NameType.REFERENCE)) {
                     while (true) {
                         fStringBuffer2.append('%');
-                        String peName = fEntityScanner.scanName();
+                        String peName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (peName == null) {
                             reportFatalError("NameRequiredInPEReference",
                             null);
                         }
-                        else if (!fEntityScanner.skipChar(';')) {
+                        else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInPEReference",
                             new Object[]{peName});
                         }
@@ -1698,20 +1717,20 @@
                         // REVISIT: This will make returning the non-
                         //          normalized value harder. -Ac
                         fEntityScanner.skipSpaces();
-                        if (!fEntityScanner.skipChar('%'))
+                        if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                             break;
                     }
                 }
                 else {
-                    countChar++;
                     int c = fEntityScanner.peekChar();
                     if (XMLChar.isHighSurrogate(c)) {
+                        countChar++;
                         scanSurrogates(fStringBuffer2);
                     }
                     else if (isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInLiteral",
                         new Object[]{Integer.toHexString(c)});
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                     // if it's not the delimiting quote or if it is but from a
                     // different entity than the one this literal started from,
@@ -1719,26 +1738,30 @@
                     else if (c != quote || entityDepth != fEntityDepth) {
                         fStringBuffer.append((char)c);
                         fStringBuffer2.append((char)c);
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                 }
-            } while (fEntityScanner.scanLiteral(quote, fString) != quote);
+                checkEntityLimit(isPEDecl, entityName, fStringBuffer.length - offset + countChar);
+            } while (fEntityScanner.scanLiteral(quote, fString, false) != quote);
+            checkEntityLimit(isPEDecl, entityName, fString.length);
             fStringBuffer.append(fString);
             fStringBuffer2.append(fString);
             literal = fStringBuffer;
             literal2 = fStringBuffer2;
         } else {
-            if (isPEDecl) {
-                checkLimit("%" + entityName, literal);
-        }
+            checkEntityLimit(isPEDecl, entityName, literal);
         }
         value.setValues(literal);
         nonNormalizedValue.setValues(literal2);
         if (fLimitAnalyzer != null) {
-            fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName);
+            if (isPEDecl) {
+                fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName);
+            } else {
+                fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT, entityName);
+            }
         }
 
-        if (!fEntityScanner.skipChar(quote)) {
+        if (!fEntityScanner.skipChar(quote, null)) {
             reportFatalError("CloseQuoteMissingInDecl", null);
         }
     } // scanEntityValue(XMLString,XMLString):void
@@ -1763,7 +1786,7 @@
         }
 
         // notation name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.NOTATION);
         if (name == null) {
             reportFatalError("MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL",
             null);
@@ -1790,7 +1813,7 @@
         skipSeparator(false, !scanningInternalSubset());
 
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("NotationDeclUnterminated", new Object[]{name});
         }
         fMarkUpDepth--;
@@ -1838,7 +1861,7 @@
                 XMLErrorReporter.SEVERITY_ERROR);
             }
             // call handler
-            if (!fEntityScanner.skipChar('[')) {
+            if (!fEntityScanner.skipChar('[', null)) {
                 reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
             }
 
@@ -1863,7 +1886,7 @@
                 fDTDHandler.startConditional(XMLDTDHandler.CONDITIONAL_IGNORE,
                 null);
             }
-            if (!fEntityScanner.skipChar('[')) {
+            if (!fEntityScanner.skipChar('[', null)) {
                 reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
             }
             fReportEntity = true;
@@ -1872,7 +1895,7 @@
                 fIgnoreConditionalBuffer.clear();
             }
             while (true) {
-                if (fEntityScanner.skipChar('<')) {
+                if (fEntityScanner.skipChar('<', null)) {
                     if (fDTDHandler != null) {
                         fIgnoreConditionalBuffer.append('<');
                     }
@@ -1880,8 +1903,8 @@
                     // These tests are split so that we handle cases like
                     // '<<![' and '<!<![' which we might otherwise miss.
                     //
-                    if (fEntityScanner.skipChar('!')) {
-                        if(fEntityScanner.skipChar('[')) {
+                    if (fEntityScanner.skipChar('!', null)) {
+                        if(fEntityScanner.skipChar('[', null)) {
                             if (fDTDHandler != null) {
                                 fIgnoreConditionalBuffer.append("![");
                             }
@@ -1893,24 +1916,24 @@
                         }
                     }
                 }
-                else if (fEntityScanner.skipChar(']')) {
+                else if (fEntityScanner.skipChar(']', null)) {
                     if (fDTDHandler != null) {
                         fIgnoreConditionalBuffer.append(']');
                     }
                     //
                     // The same thing goes for ']<![' and '<]]>', etc.
                     //
-                    if (fEntityScanner.skipChar(']')) {
+                    if (fEntityScanner.skipChar(']', null)) {
                         if (fDTDHandler != null) {
                             fIgnoreConditionalBuffer.append(']');
                         }
-                        while (fEntityScanner.skipChar(']')) {
+                        while (fEntityScanner.skipChar(']', null)) {
                             /* empty loop body */
                             if (fDTDHandler != null) {
                                 fIgnoreConditionalBuffer.append(']');
                             }
                         }
-                        if (fEntityScanner.skipChar('>')) {
+                        if (fEntityScanner.skipChar('>', null)) {
                             if (fIncludeSectDepth-- == initialDepth) {
                                 fMarkUpDepth--;
                                 // call handler
@@ -1928,7 +1951,7 @@
                     }
                 }
                 else {
-                    int c = fEntityScanner.scanChar();
+                    int c = fEntityScanner.scanChar(null);
                     if (fScannerState == SCANNER_STATE_END_OF_INPUT) {
                         reportFatalError("IgnoreSectUnterminated", null);
                         return;
@@ -1965,16 +1988,16 @@
         //System.out.println("scanDecls"+fScannerState);
         while (again && fScannerState == SCANNER_STATE_MARKUP_DECL) {
             again = complete;
-            if (fEntityScanner.skipChar('<')) {
+            if (fEntityScanner.skipChar('<', null)) {
                 fMarkUpDepth++;
-                if (fEntityScanner.skipChar('?')) {
+                if (fEntityScanner.skipChar('?', null)) {
                     fStringBuffer.clear();
                     scanPI(fStringBuffer);
                     fMarkUpDepth--; // we're done with this decl
                 }
-                else if (fEntityScanner.skipChar('!')) {
-                    if (fEntityScanner.skipChar('-')) {
-                        if (!fEntityScanner.skipChar('-')) {
+                else if (fEntityScanner.skipChar('!', null)) {
+                    if (fEntityScanner.skipChar('-', null)) {
+                        if (!fEntityScanner.skipChar('-', null)) {
                             reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD",
                             null);
                         } else {
@@ -1993,7 +2016,7 @@
                     else if (fEntityScanner.skipString("NOTATION")) {
                         scanNotationDecl();
                     }
-                    else if (fEntityScanner.skipChar('[') &&
+                    else if (fEntityScanner.skipChar('[', null) &&
                     !scanningInternalSubset()) {
                         scanConditionalSect(fPEDepth);
                     }
@@ -2008,10 +2031,10 @@
                     reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
                 }
             }
-            else if (fIncludeSectDepth > 0 && fEntityScanner.skipChar(']')) {
+            else if (fIncludeSectDepth > 0 && fEntityScanner.skipChar(']', null)) {
                 // end of conditional section?
-                if (!fEntityScanner.skipChar(']')
-                || !fEntityScanner.skipChar('>')) {
+                if (!fEntityScanner.skipChar(']', null)
+                || !fEntityScanner.skipChar('>', null)) {
                     reportFatalError("IncludeSectUnterminated", null);
                 }
                 // call handler
@@ -2058,21 +2081,21 @@
     throws IOException, XNIException {
         int depth = fPEDepth;
         boolean sawSpace = fEntityScanner.skipSpaces();
-        if (!lookForPERefs || !fEntityScanner.skipChar('%')) {
+        if (!lookForPERefs || !fEntityScanner.skipChar('%', NameType.REFERENCE)) {
             return !spaceRequired || sawSpace || (depth != fPEDepth);
         }
         while (true) {
-            String name = fEntityScanner.scanName();
+            String name = fEntityScanner.scanName(NameType.ENTITY);
             if (name == null) {
                 reportFatalError("NameRequiredInPEReference", null);
             }
-            else if (!fEntityScanner.skipChar(';')) {
+            else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                 reportFatalError("SemicolonRequiredInPEReference",
                 new Object[]{name});
             }
             startPE(name, false);
             fEntityScanner.skipSpaces();
-            if (!fEntityScanner.skipChar('%'))
+            if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                 return true;
         }
     }
@@ -2152,44 +2175,8 @@
         setScannerState(SCANNER_STATE_TEXT_DECL);
         //new SymbolTable());
 
-        fLimitAnalyzer = new XMLLimitAnalyzer();
-    }
-
-    /**
-     * Add the count of the content buffer and check if the accumulated
-     * value exceeds the limit
-     * @param entityName entity name
-     * @param buffer content buffer
-     */
-    private void checkLimit(String entityName, XMLString buffer) {
-        checkLimit(entityName, buffer.length);
-    }
-
-    /**
-     * Add the count and check limit
-     * @param entityName entity name
-     * @param len length of the buffer
-     */
-    private void checkLimit(String entityName, int len) {
-        if (fLimitAnalyzer == null) {
-            fLimitAnalyzer = new XMLLimitAnalyzer();
-        }
-        fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName, len);
-        if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-                    fSecurityManager.debugPrint(fLimitAnalyzer);
-            reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
-                fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
-        }
-        if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-            fSecurityManager.debugPrint(fLimitAnalyzer);
-            reportFatalError("TotalEntitySizeLimit",
-                new Object[]{fLimitAnalyzer.getTotalValue(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)});
-        }
-
+        fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
+        fSecurityManager = fEntityManager.fSecurityManager;
     }
 
     public DTDGrammar getGrammar(){
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -21,21 +21,17 @@
 
 package com.sun.org.apache.xerces.internal.impl;
 
-import com.sun.xml.internal.stream.XMLBufferListener;
-import com.sun.xml.internal.stream.XMLEntityStorage;
-import com.sun.xml.internal.stream.XMLInputFactoryImpl;
-import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
-
-import java.io.EOFException;
-import java.io.IOException;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.events.XMLEvent;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesIteratorImpl;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
+import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
@@ -47,18 +43,12 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import com.sun.org.apache.xerces.internal.xni.Augmentations;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
-import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.State;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
-import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
-import javax.xml.XMLConstants;
+import com.sun.xml.internal.stream.XMLBufferListener;
+import com.sun.xml.internal.stream.XMLEntityStorage;
+import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
+import java.io.EOFException;
+import java.io.IOException;
+import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.events.XMLEvent;
 
@@ -89,7 +79,7 @@
     // Constants
     //
 
-    protected int fElementAttributeLimit;
+    protected int fElementAttributeLimit, fXMLNameLimit;
 
     /** External subset resolver. **/
     protected ExternalSubsetResolver fExternalSubsetResolver;
@@ -425,7 +415,7 @@
      */
     public void setInputSource(XMLInputSource inputSource) throws IOException {
         fEntityManager.setEntityHandler(this);
-        fEntityManager.startEntity("$fragment$", inputSource, false, true);
+        fEntityManager.startEntity(false, "$fragment$", inputSource, false, true);
         // fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
     } // setInputSource(XMLInputSource)
 
@@ -460,6 +450,7 @@
                     //fDocumentHandler.startElement(getElementQName(),fAttributes,null);
                     break;
                 case XMLStreamConstants.CHARACTERS :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.characters(getCharacterData(),null);
                     break;
                 case XMLStreamConstants.SPACE:
@@ -468,13 +459,15 @@
                     //fDocumentHandler.ignorableWhitespace(getCharacterData(), null);
                     break;
                 case XMLStreamConstants.ENTITY_REFERENCE :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     //entity reference callback are given in startEntity
                     break;
                 case XMLStreamConstants.PROCESSING_INSTRUCTION :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.processingInstruction(getPITarget(),getPIData(),null);
                     break;
                 case XMLStreamConstants.COMMENT :
-                    //System.out.println(" in COMMENT of the XMLNSDocumentScannerImpl");
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.comment(getCharacterData(),null);
                     break;
                 case XMLStreamConstants.DTD :
@@ -483,6 +476,7 @@
                     //therefore we don't need to take care of anything here. So Just break;
                     break;
                 case XMLStreamConstants.CDATA:
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.startCDATA(null);
                     //xxx: check if CDATA values comes from getCharacterData() function
                     fDocumentHandler.characters(getCharacterData(),null);
@@ -660,11 +654,12 @@
 
         if (fSecurityManager != null) {
             fElementAttributeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT);
+            fXMLNameLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_NAME_LIMIT);
         } else {
             fElementAttributeLimit = 0;
+            fXMLNameLimit = XMLSecurityManager.Limit.MAX_NAME_LIMIT.defaultValue();
         }
-        fLimitAnalyzer = new XMLLimitAnalyzer();
-        fEntityManager.setLimitAnalyzer(fLimitAnalyzer);
+        fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
     }
 
     /**
@@ -1278,9 +1273,9 @@
             fElementQName = fElementStack.nextElement();
             // name
             if (fNamespaces) {
-                fEntityScanner.scanQName(fElementQName);
+                fEntityScanner.scanQName(fElementQName, NameType.ELEMENTSTART);
             } else {
-                String name = fEntityScanner.scanName();
+                String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
                 fElementQName.setValues(null, name, name, null);
             }
 
@@ -1381,11 +1376,11 @@
         // end tag?
         final int c = fEntityScanner.peekChar();
         if (c == '>') {
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             return true;
         } else if (c == '/') {
-            fEntityScanner.scanChar();
-            if (!fEntityScanner.skipChar('>')) {
+            fEntityScanner.scanChar(null);
+            if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
                 reportFatalError("ElementUnterminated",
                         new Object[]{fElementQName.rawname});
             }
@@ -1518,15 +1513,15 @@
 
         // name
         if (fNamespaces) {
-            fEntityScanner.scanQName(fAttributeQName);
+            fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
         } else {
-            String name = fEntityScanner.scanName();
+            String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
             fAttributeQName.setValues(null, name, name, null);
         }
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError("EqRequiredInAttribute",
                 new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
         }
@@ -1544,9 +1539,8 @@
         //can safely add the attribute later..
         XMLString tmpStr = getString();
 
-        scanAttributeValue(tmpStr, fTempString2,
-                fAttributeQName.rawname, attributes,
-                attIndex, isVC, fCurrentElement.rawname);
+        scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
+                attIndex, isVC, fCurrentElement.rawname, false);
 
         // content
         int oldLen = attributes.getLength();
@@ -1594,13 +1588,13 @@
         if (c == '\r') {
             // happens when there is the character reference &#13;
             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             content.append((char)c);
             c = -1;
         } else if (c == ']') {
             //fStringBuffer.clear();
             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-            content.append((char)fEntityScanner.scanChar());
+            content.append((char)fEntityScanner.scanChar(null));
             // remember where we are in case we get an endEntity before we
             // could flush the buffer out - this happens when we're parsing an
             // entity which ends with a ]
@@ -1609,12 +1603,12 @@
             // We work on a single character basis to handle cases such as:
             // ']]]>' which we might otherwise miss.
             //
-            if (fEntityScanner.skipChar(']')) {
+            if (fEntityScanner.skipChar(']', null)) {
                 content.append(']');
-                while (fEntityScanner.skipChar(']')) {
+                while (fEntityScanner.skipChar(']', null)) {
                     content.append(']');
                 }
-                if (fEntityScanner.skipChar('>')) {
+                if (fEntityScanner.skipChar('>', null)) {
                     reportFatalError("CDEndInContent", null);
                 }
             }
@@ -1689,7 +1683,7 @@
                     } else {
                         reportFatalError("InvalidCharInCDSect",
                                 new Object[]{Integer.toString(c,16)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
                 //by this time we have also read surrogate contents if any...
@@ -1751,7 +1745,7 @@
 
         // end
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
             reportFatalError("ETagUnterminated",
                     new Object[]{rawname});
         }
@@ -1841,12 +1835,12 @@
      *                      notification.
      */
     protected void scanEntityReference(XMLStringBuffer content) throws IOException, XNIException {
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.REFERENCE);
         if (name == null) {
             reportFatalError("NameRequiredInReference", null);
             return;
         }
-        if (!fEntityScanner.skipChar(';')) {
+        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
             reportFatalError("SemicolonRequiredInReference", new Object []{name});
         }
         if (fEntityStore.isUnparsedEntity(name)) {
@@ -1905,7 +1899,7 @@
         //if that was the case it its taken care in XMLEntityManager.startEntity()
         //we immediately call the endEntity. Application gets to know if there was
         //any entity that was not declared.
-        fEntityManager.startEntity(name, false);
+        fEntityManager.startEntity(true, name, false);
         //set the scaner state to content.. parser will automatically revive itself at any point of time.
         //setScannerState(SCANNER_STATE_CONTENT);
         //return true ;
@@ -1943,6 +1937,7 @@
      */
     private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
         foundBuiltInRefs = true;
+        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
         content.append(c);
         if (fDocumentHandler != null) {
             fSingleChar[0] = c;
@@ -2605,13 +2600,13 @@
             switch(ch){
                 case '?' :{
                     setScannerState(SCANNER_STATE_PI);
-                    fEntityScanner.skipChar(ch);
+                        fEntityScanner.skipChar(ch, null);
                     break;
                 }
                 case '!' :{
-                    fEntityScanner.skipChar(ch);
-                    if (fEntityScanner.skipChar('-')) {
-                        if (!fEntityScanner.skipChar('-')) {
+                        fEntityScanner.skipChar(ch, null);
+                        if (fEntityScanner.skipChar('-', null)) {
+                            if (!fEntityScanner.skipChar('-', NameType.COMMENT)) {
                             reportFatalError("InvalidCommentStart",
                                     null);
                         }
@@ -2626,7 +2621,7 @@
                 }
                 case '/' :{
                     setScannerState(SCANNER_STATE_END_ELEMENT_TAG);
-                    fEntityScanner.skipChar(ch);
+                        fEntityScanner.skipChar(ch, NameType.ELEMENTEND);
                     break;
                 }
                 default :{
@@ -2642,9 +2637,9 @@
         }//startOfMarkup
 
         private void startOfContent() throws IOException {
-            if (fEntityScanner.skipChar('<')) {
+            if (fEntityScanner.skipChar('<', null)) {
                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
-            } else if (fEntityScanner.skipChar('&')) {
+            } else if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
                 setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE
             } else {
                 //element content is there..
@@ -2717,10 +2712,10 @@
                     case SCANNER_STATE_CONTENT: {
                         final int ch = fEntityScanner.peekChar();
                         if (ch == '<') {
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             setScannerState(SCANNER_STATE_START_OF_MARKUP);
                         } else if (ch == '&') {
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(NameType.REFERENCE);
                             setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE
                             break;
                         } else {
@@ -2820,9 +2815,9 @@
                         if(DEBUG){
                             System.out.println("fTempString = " + fTempString);
                         }
-                        if(fEntityScanner.skipChar('<')){
+                        if(fEntityScanner.skipChar('<', null)){
                             //check if we have reached end of element
-                            if(fEntityScanner.skipChar('/')){
+                            if(fEntityScanner.skipChar('/', NameType.ELEMENTEND)){
                                 //increase the mark up depth
                                 fMarkupDepth++;
                                 fLastSectionWasCharacterData = false;
@@ -2851,8 +2846,6 @@
                             if(DEBUG){
                                 System.out.println("NOT USING THE BUFFER, STRING = " + fTempString.toString());
                             }
-                            //check limit before returning event
-                            checkLimit(fContentBuffer);
                             if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
                                 if(DEBUG)System.out.println("Return SPACE EVENT");
                                 return XMLEvent.SPACE;
@@ -2874,7 +2867,7 @@
                             }
                             // happens when there is the character reference &#13;
                             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             fUsebuffer = true;
                             fContentBuffer.append((char)c);
                             c = -1 ;
@@ -2882,7 +2875,7 @@
                             //fStringBuffer.clear();
                             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
                             fUsebuffer = true;
-                            fContentBuffer.append((char)fEntityScanner.scanChar());
+                            fContentBuffer.append((char)fEntityScanner.scanChar(null));
                             // remember where we are in case we get an endEntity before we
                             // could flush the buffer out - this happens when we're parsing an
                             // entity which ends with a ]
@@ -2891,12 +2884,12 @@
                             // We work on a single character basis to handle cases such as:
                             // ']]]>' which we might otherwise miss.
                             //
-                            if (fEntityScanner.skipChar(']')) {
+                            if (fEntityScanner.skipChar(']', null)) {
                                 fContentBuffer.append(']');
-                                while (fEntityScanner.skipChar(']')) {
+                                while (fEntityScanner.skipChar(']', null)) {
                                     fContentBuffer.append(']');
                                 }
-                                if (fEntityScanner.skipChar('>')) {
+                                if (fEntityScanner.skipChar('>', null)) {
                                     reportFatalError("CDEndInContent", null);
                                 }
                             }
@@ -2909,12 +2902,12 @@
                             // we need not to grow the buffer only when isCoalesce() is not true;
 
                             if (c == '<') {
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
                                 break;
                             }//xxx what should be the behavior if entity reference is present in the content ?
                             else if (c == '&') {
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(NameType.REFERENCE);
                                 setScannerState(SCANNER_STATE_REFERENCE);
                                 break;
                             }///xxx since this part is also characters, it should be merged...
@@ -2927,7 +2920,7 @@
                                     reportFatalError("InvalidCharInContent",
                                             new Object[] {
                                         Integer.toString(c, 16)});
-                                        fEntityScanner.scanChar();
+                                        fEntityScanner.scanChar(null);
                                 }
                                 break;
                             }
@@ -2951,8 +2944,6 @@
                             fLastSectionWasCharacterData = true ;
                             continue;
                         }else{
-                            //check limit before returning event
-                            checkLimit(fContentBuffer);
                             if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
                                 if(DEBUG)System.out.println("Return SPACE EVENT");
                                 return XMLEvent.SPACE;
@@ -3055,7 +3046,7 @@
                         }
                         fUsebuffer = true ;
                         //take care of character reference
-                        if (fEntityScanner.skipChar('#')) {
+                        if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                             scanCharReferenceValue(fContentBuffer, null);
                             fMarkupDepth--;
                             if(!fIsCoalesce){
@@ -3106,11 +3097,11 @@
 
                                 if (fNamespaces) {
                                     while (isValidNCName(fEntityScanner.peekChar())) {
-                                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                                     }
                                 } else {
                                     while (isValidNameChar(fEntityScanner.peekChar())) {
-                                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                                     }
                                 }
                                 String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
@@ -3163,31 +3154,6 @@
             } //while loop
         }//next
 
-        /**
-         * Add the count of the content buffer and check if the accumulated
-         * value exceeds the limit
-         * @param buffer content buffer
-         */
-        protected void checkLimit(XMLStringBuffer buffer) {
-            if (fLimitAnalyzer.isTracking(fCurrentEntityName)) {
-                fLimitAnalyzer.addValue(Limit.GENEAL_ENTITY_SIZE_LIMIT, fCurrentEntityName, buffer.length);
-                if (fSecurityManager.isOverLimit(Limit.GENEAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-                    fSecurityManager.debugPrint(fLimitAnalyzer);
-                    reportFatalError("MaxEntitySizeLimit", new Object[]{fCurrentEntityName,
-                        fLimitAnalyzer.getValue(Limit.GENEAL_ENTITY_SIZE_LIMIT),
-                        fSecurityManager.getLimit(Limit.GENEAL_ENTITY_SIZE_LIMIT),
-                        fSecurityManager.getStateLiteral(Limit.GENEAL_ENTITY_SIZE_LIMIT)});
-                }
-                if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-                    fSecurityManager.debugPrint(fLimitAnalyzer);
-                    reportFatalError("TotalEntitySizeLimit",
-                        new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                        fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                        fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)});
-                }
-            }
-        }
-
         //
         // Protected methods
         //
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -636,7 +636,7 @@
         }
 
         // root element name
-        fDoctypeName = fEntityScanner.scanName();
+        fDoctypeName = fEntityScanner.scanName(NameType.DOCTYPE);
         if (fDoctypeName == null) {
             reportFatalError("MSG_ROOT_ELEMENT_TYPE_REQUIRED", null);
         }
@@ -676,10 +676,10 @@
 
         // is there an internal subset?
         boolean internalSubset = true;
-        if (!fEntityScanner.skipChar('[')) {
+        if (!fEntityScanner.skipChar('[', null)) {
             internalSubset = false;
             fEntityScanner.skipSpaces();
-            if (!fEntityScanner.skipChar('>')) {
+            if (!fEntityScanner.skipChar('>', null)) {
                 reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
             }
             fMarkupDepth--;
@@ -758,7 +758,7 @@
                         fStringBuffer.clear();
                         fStringBuffer.append("xml");
                         while (XMLChar.isName(fEntityScanner.peekChar())) {
-                            fStringBuffer.append((char)fEntityScanner.scanChar());
+                            fStringBuffer.append((char)fEntityScanner.scanChar(null));
                         }
                         String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                         //this function should fill the data.. and set the fEvent object to this event.
@@ -836,9 +836,9 @@
                     switch (fScannerState) {
                         case SCANNER_STATE_PROLOG: {
                             fEntityScanner.skipSpaces();
-                            if (fEntityScanner.skipChar('<')) {
+                            if (fEntityScanner.skipChar('<', null)) {
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
-                            } else if (fEntityScanner.skipChar('&')) {
+                            } else if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
                                 setScannerState(SCANNER_STATE_REFERENCE);
                             } else {
                                 setScannerState(SCANNER_STATE_CONTENT);
@@ -849,11 +849,11 @@
                         case SCANNER_STATE_START_OF_MARKUP: {
                             fMarkupDepth++;
 
-                            if (fEntityScanner.skipChar('?')) {
+                            if (fEntityScanner.skipChar('?', null)) {
                                 setScannerState(SCANNER_STATE_PI);
-                            } else if (fEntityScanner.skipChar('!')) {
-                                if (fEntityScanner.skipChar('-')) {
-                                    if (!fEntityScanner.skipChar('-')) {
+                            } else if (fEntityScanner.skipChar('!', null)) {
+                                if (fEntityScanner.skipChar('-', null)) {
+                                    if (!fEntityScanner.skipChar('-', null)) {
                                         reportFatalError("InvalidCommentStart",
                                                 null);
                                     }
@@ -997,7 +997,7 @@
 
                     case SCANNER_STATE_CONTENT: {
                         reportFatalError("ContentIllegalInProlog", null);
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                     case SCANNER_STATE_REFERENCE: {
                         reportFatalError("ReferenceIllegalInProlog", null);
@@ -1096,11 +1096,14 @@
                     again = false;
                     switch (fScannerState) {
                         case SCANNER_STATE_DTD_INTERNAL_DECLS: {
+                            boolean moreToScan = false;
+                            if (!fDTDScanner.skipDTD(fSupportDTD)) {
                             // REVISIT: Should there be a feature for
                             //          the "complete" parameter?
                             boolean completeDTD = true;
 
-                            boolean moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
+                                moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
+                            }
                             Entity entity = fEntityScanner.getCurrentEntity();
                             if(entity instanceof Entity.ScannedEntity){
                                 fEndPos=((Entity.ScannedEntity)entity).position;
@@ -1108,12 +1111,12 @@
                             fReadingDTD=false;
                             if (!moreToScan) {
                                 // end doctype declaration
-                                if (!fEntityScanner.skipChar(']')) {
+                                if (!fEntityScanner.skipChar(']', null)) {
                                     reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
                                             null);
                                 }
                                 fEntityScanner.skipSpaces();
-                                if (!fEntityScanner.skipChar('>')) {
+                                if (!fEntityScanner.skipChar('>', null)) {
                                     reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
                                 }
                                 fMarkupDepth--;
@@ -1377,7 +1380,7 @@
                             if(fScannerState == SCANNER_STATE_TERMINATED ){
                                 return XMLEvent.END_DOCUMENT ;
                             }
-                            if (fEntityScanner.skipChar('<')) {
+                            if (fEntityScanner.skipChar('<', null)) {
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
                             } else {
                                 setScannerState(SCANNER_STATE_CONTENT);
@@ -1386,11 +1389,11 @@
                         }
                         case SCANNER_STATE_START_OF_MARKUP: {
                             fMarkupDepth++;
-                            if (fEntityScanner.skipChar('?')) {
+                            if (fEntityScanner.skipChar('?', null)) {
                                 setScannerState(SCANNER_STATE_PI);
-                            } else if (fEntityScanner.skipChar('!')) {
+                            } else if (fEntityScanner.skipChar('!', null)) {
                                 setScannerState(SCANNER_STATE_COMMENT);
-                            } else if (fEntityScanner.skipChar('/')) {
+                            } else if (fEntityScanner.skipChar('/', null)) {
                                 reportFatalError("MarkupNotRecognizedInMisc",
                                         null);
                             } else if (XMLChar.isNameStart(fEntityScanner.peekChar())) {
@@ -1432,7 +1435,7 @@
                         } else{
                             reportFatalError("ContentIllegalInTrailingMisc",
                                     null);
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             setScannerState(SCANNER_STATE_TRAILING_MISC);
                             return XMLEvent.CHARACTERS;
                         }
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * Copyright (c) 2003, 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -44,12 +44,11 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Stack;
-import javax.xml.XMLConstants;
 import javax.xml.stream.XMLInputFactory;
 
 
@@ -365,7 +364,7 @@
     // entities
 
     /** Entities. */
-    protected Hashtable fEntities = new Hashtable();
+    protected Map<String, Entity> fEntities = new HashMap<>();
 
     /** Entity stack. */
     protected Stack fEntityStack = new Stack();
@@ -402,6 +401,8 @@
      * If this constructor is used to create the object, reset() should be invoked on this object
      */
     public XMLEntityManager() {
+        //for entity managers not created by parsers
+        fSecurityManager = new XMLSecurityManager(true);
         fEntityStorage = new XMLEntityStorage(this) ;
         setScannerVersion(Constants.XML_VERSION_1_0);
     } // <init>()
@@ -579,6 +580,8 @@
     /**
      * This method uses the passed-in XMLInputSource to make
      * fCurrentEntity usable for reading.
+     *
+     * @param reference flag to indicate whether the entity is an Entity Reference.
      * @param name  name of the entity (XML is it's the document entity)
      * @param xmlInputSource    the input source, with sufficient information
      *      to begin scanning characters.
@@ -589,7 +592,7 @@
      *  XNIException    If any parser-specific goes wrong.
      * @return the encoding of the new entity or null if a character stream was employed
      */
-    public String setupCurrentEntity(String name, XMLInputSource xmlInputSource,
+    public String setupCurrentEntity(boolean reference, String name, XMLInputSource xmlInputSource,
             boolean literal, boolean isExternal)
             throws IOException, XNIException {
         // get information
@@ -832,7 +835,9 @@
          * in the prolog of the XML document is not considered. Hence, prolog can
          * be read in Chunks of data instead of byte by byte.
          */
-        fCurrentEntity = new com.sun.xml.internal.stream.Entity.ScannedEntity(name,new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId),stream, reader, encoding, literal, encodingExternallySpecified, isExternal);
+        fCurrentEntity = new Entity.ScannedEntity(reference, name,
+                new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId),
+                stream, reader, encoding, literal, encodingExternallySpecified, isExternal);
         fCurrentEntity.setEncodingExternallySpecified(encodingExternallySpecified);
         fEntityScanner.setCurrentEntity(fCurrentEntity);
         fResourceIdentifier.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
@@ -852,7 +857,7 @@
      */
     public boolean isExternalEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -869,7 +874,7 @@
      */
     public boolean isEntityDeclInExternalSubset(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -899,13 +904,13 @@
 
     public boolean isDeclaredEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         return entity != null;
     }
 
     public boolean isUnparsedEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -1100,6 +1105,7 @@
     /**
      * Starts a named entity.
      *
+     * @param isGE flag to indicate whether the entity is a General Entity
      * @param entityName The name of the entity to start.
      * @param literal    True if this entity is started within a literal
      *                   value.
@@ -1107,11 +1113,11 @@
      * @throws IOException  Thrown on i/o error.
      * @throws XNIException Thrown by entity handler to signal an error.
      */
-    public void startEntity(String entityName, boolean literal)
+    public void startEntity(boolean isGE, String entityName, boolean literal)
     throws IOException, XNIException {
 
         // was entity declared?
-        Entity entity = (Entity)fEntityStorage.getEntity(entityName);
+        Entity entity = fEntityStorage.getEntity(entityName);
         if (entity == null) {
             if (fEntityHandler != null) {
                 String encoding = null;
@@ -1231,7 +1237,7 @@
         }
 
         // start the entity
-        startEntity(entityName, xmlInputSource, literal, external);
+        startEntity(isGE, entityName, xmlInputSource, literal, external);
 
     } // startEntity(String,boolean)
 
@@ -1246,7 +1252,7 @@
      */
     public void startDocumentEntity(XMLInputSource xmlInputSource)
     throws IOException, XNIException {
-        startEntity(XMLEntity, xmlInputSource, false, true);
+        startEntity(false, XMLEntity, xmlInputSource, false, true);
     } // startDocumentEntity(XMLInputSource)
 
     //xxx these methods are not required.
@@ -1261,7 +1267,7 @@
      */
     public void startDTDEntity(XMLInputSource xmlInputSource)
     throws IOException, XNIException {
-        startEntity(DTDEntity, xmlInputSource, false, true);
+        startEntity(false, DTDEntity, xmlInputSource, false, true);
     } // startDTDEntity(XMLInputSource)
 
     // indicate start of external subset so that
@@ -1280,6 +1286,7 @@
      * This method can be used to insert an application defined XML
      * entity stream into the parsing stream.
      *
+     * @param isGE flag to indicate whether the entity is a General Entity
      * @param name           The name of the entity.
      * @param xmlInputSource The input source of the entity.
      * @param literal        True if this entity is started within a
@@ -1289,12 +1296,12 @@
      * @throws IOException  Thrown on i/o error.
      * @throws XNIException Thrown by entity handler to signal an error.
      */
-    public void startEntity(String name,
+    public void startEntity(boolean isGE, String name,
             XMLInputSource xmlInputSource,
             boolean literal, boolean isExternal)
             throws IOException, XNIException {
 
-        String encoding = setupCurrentEntity(name, xmlInputSource, literal, isExternal);
+        String encoding = setupCurrentEntity(isGE, name, xmlInputSource, literal, isExternal);
 
         //when entity expansion limit is set by the Application, we need to
         //check for the entity expansion limit set by the parser, if number of entity
@@ -1306,7 +1313,7 @@
         }
         if( fSecurityManager != null && fSecurityManager.isOverLimit(entityExpansionIndex, fLimitAnalyzer)){
             fSecurityManager.debugPrint(fLimitAnalyzer);
-            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"EntityExpansionLimitExceeded",
+            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"EntityExpansionLimit",
                     new Object[]{fSecurityManager.getLimitValueByIndex(entityExpansionIndex)},
                                              XMLErrorReporter.SEVERITY_FATAL_ERROR );
             // is there anything better to do than reset the counter?
@@ -1422,10 +1429,6 @@
     // XMLComponent methods
     //
     public void reset(PropertyManager propertyManager){
-        //reset fEntityStorage
-        fEntityStorage.reset(propertyManager);
-        //reset XMLEntityReaderImpl
-        fEntityScanner.reset(propertyManager);
         // xerces properties
         fSymbolTable = (SymbolTable)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
         fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
@@ -1448,6 +1451,12 @@
 
         fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);
 
+        fLimitAnalyzer = new XMLLimitAnalyzer();
+        //reset fEntityStorage
+        fEntityStorage.reset(propertyManager);
+        //reset XMLEntityReaderImpl
+        fEntityScanner.reset(propertyManager);
+
         // initialize state
         //fStandalone = false;
         fEntities.clear();
@@ -1534,7 +1543,7 @@
     // a class acting as a component manager but not
     // implementing that interface for whatever reason.
     public void reset() {
-
+        fLimitAnalyzer = new XMLLimitAnalyzer();
         // initialize state
         fStandalone = false;
         fEntities.clear();
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -21,7 +21,7 @@
 package com.sun.org.apache.xerces.internal.impl;
 
 
-
+import com.sun.org.apache.xerces.internal.impl.XMLScanner.NameType;
 import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader;
 import com.sun.org.apache.xerces.internal.impl.io.UCSReader;
 import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader;
@@ -30,10 +30,14 @@
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
+import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
 import com.sun.org.apache.xerces.internal.xni.*;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.xml.internal.stream.Entity;
+import com.sun.xml.internal.stream.Entity.ScannedEntity;
 import com.sun.xml.internal.stream.XMLBufferListener;
 import java.io.EOFException;
 import java.io.IOException;
@@ -60,6 +64,12 @@
 
     protected XMLEntityManager fEntityManager ;
 
+    /** Security manager. */
+    protected XMLSecurityManager fSecurityManager = null;
+
+    /** Limit analyzer. */
+    protected XMLLimitAnalyzer fLimitAnalyzer = null;
+
     /** Debug switching readers for encodings. */
     private static final boolean DEBUG_ENCODINGS = false;
     /** Listeners which should know when load is being called */
@@ -133,6 +143,10 @@
     // SAPJVM: Remember, that the XML version has explicitly been set,
     // so that XMLStreamReader.getVersion() can find that out.
     boolean xmlVersionSetExplicitly = false;
+
+    // indicates that the operation is for detecting XML version
+    boolean detectingVersion = false;
+
     //
     // Constructors
     //
@@ -174,10 +188,7 @@
     public void reset(PropertyManager propertyManager){
         fSymbolTable = (SymbolTable)propertyManager.getProperty(SYMBOL_TABLE) ;
         fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(ERROR_REPORTER) ;
-        fCurrentEntity = null;
-        whiteSpaceLen = 0;
-        whiteSpaceInfoNeeded = true;
-        listeners.clear();
+        resetCommon();
     }
 
     /**
@@ -196,18 +207,13 @@
      */
     public void reset(XMLComponentManager componentManager)
     throws XMLConfigurationException {
-
-        //System.out.println(" this is being called");
         // xerces features
         fAllowJavaEncodings = componentManager.getFeature(ALLOW_JAVA_ENCODINGS, false);
 
         //xerces properties
         fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
         fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
-        fCurrentEntity = null;
-        whiteSpaceLen = 0;
-        whiteSpaceInfoNeeded = true;
-        listeners.clear();
+        resetCommon();
     } // reset(XMLComponentManager)
 
 
@@ -217,6 +223,17 @@
         fSymbolTable = symbolTable;
         fEntityManager = entityManager;
         fErrorReporter = reporter;
+        fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
+        fSecurityManager = fEntityManager.fSecurityManager;
+    }
+
+    private void resetCommon() {
+        fCurrentEntity = null;
+        whiteSpaceLen = 0;
+        whiteSpaceInfoNeeded = true;
+        listeners.clear();
+        fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
+        fSecurityManager = fEntityManager.fSecurityManager;
     }
 
     /**
@@ -516,10 +533,12 @@
      * <p>
      * <strong>Note:</strong> The character is consumed.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanChar() throws IOException {
+    protected int scanChar(NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanChar: ");
             print();
@@ -532,6 +551,7 @@
         }
 
         // scan character
+        int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[fCurrentEntity.position++];
         if (c == '\n' ||
                 (c == '\r' && isExternal)) {
@@ -541,6 +561,7 @@
                 invokeListeners(1);
                 fCurrentEntity.ch[0] = (char)c;
                 load(1, false, false);
+                offset = 0;
             }
             if (c == '\r' && isExternal) {
                 if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
@@ -557,6 +578,9 @@
             System.out.println(" -> '"+(char)c+"'");
         }
         fCurrentEntity.columnNumber++;
+        if (!detectingVersion) {
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
+        }
         return c;
 
     } // scanChar():int
@@ -576,7 +600,7 @@
      * @see com.sun.org.apache.xerces.internal.util.SymbolTable
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      */
-    public String scanNmtoken() throws IOException {
+    protected String scanNmtoken() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanNmtoken: ");
             print();
@@ -648,6 +672,8 @@
      * <strong>Note:</strong> The string returned must be a symbol. The
      * SymbolTable can be used for this purpose.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      *
@@ -655,7 +681,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isNameStart
      */
-    public String scanName() throws IOException {
+    protected String scanName(NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanName: ");
             print();
@@ -669,6 +695,7 @@
 
         // scan name
         int offset = fCurrentEntity.position;
+        int length;
         if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
             if (++fCurrentEntity.position == fCurrentEntity.count) {
                 invokeListeners(1);
@@ -696,20 +723,7 @@
                     vc = XMLChar.isName(c);
                 }
                 if(!vc)break;
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.fBufferSize) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.fBufferSize * 2];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                        fCurrentEntity.fBufferSize *= 2;
-                    } else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -717,12 +731,14 @@
                 }
             }
         }
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         // return name
         String symbol;
         if (length > 0) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
         } else
             symbol = null;
@@ -746,6 +762,7 @@
      * this purpose.
      *
      * @param qname The qualified name structure to fill.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if a qualified name appeared immediately on
      *         the input and was scanned, false otherwise.
@@ -757,7 +774,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isNameStart
      */
-    public boolean scanQName(QName qname) throws IOException {
+    protected boolean scanQName(QName qname, NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanQName, "+qname+": ");
             print();
@@ -793,11 +810,13 @@
                         print();
                         System.out.println(" -> true");
                     }
+                    checkEntityLimit(nt, fCurrentEntity, 0, 1);
                     return true;
                 }
             }
             int index = -1;
             boolean vc = false;
+            int length;
             while ( true){
 
                 //XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) ;
@@ -813,21 +832,10 @@
                         break;
                     }
                     index = fCurrentEntity.position;
+                    //check prefix before further read
+                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.fBufferSize) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.fBufferSize * 2];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                        fCurrentEntity.fBufferSize *= 2;
-                    } else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -837,7 +845,7 @@
                     }
                 }
             }
-            int length = fCurrentEntity.position - offset;
+            length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length;
             if (length > 0) {
                 String prefix = null;
@@ -847,14 +855,20 @@
 
                 if (index != -1) {
                     int prefixLength = index - offset;
+                    //check the result: prefix
+                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, prefixLength);
                     prefix = fSymbolTable.addSymbol(fCurrentEntity.ch,
                             offset, prefixLength);
                     int len = length - prefixLength - 1;
+                    //check the result: localpart
+                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, index + 1, len);
                     localpart = fSymbolTable.addSymbol(fCurrentEntity.ch,
                             index + 1, len);
 
                 } else {
                     localpart = rawname;
+                    //check the result: localpart
+                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
                 }
                 qname.setValues(prefix, localpart, rawname, null);
                 if (DEBUG_BUFFER) {
@@ -862,6 +876,7 @@
                     print();
                     System.out.println(" -> true");
                 }
+                checkEntityLimit(nt, fCurrentEntity, offset, length);
                 return true;
             }
         }
@@ -877,6 +892,109 @@
     } // scanQName(QName):boolean
 
     /**
+     * Checks whether the end of the entity buffer has been reached. If yes,
+     * checks against the limit and buffer size before loading more characters.
+     *
+     * @param entity the current entity
+     * @param offset the offset from which the current read was started
+     * @param nameOffset the offset from which the current name starts
+     * @return the length of characters scanned before the end of the buffer,
+     * zero if there is more to be read in the buffer
+     */
+    protected int checkBeforeLoad(Entity.ScannedEntity entity, int offset,
+            int nameOffset) throws IOException {
+        int length = 0;
+        if (++entity.position == entity.count) {
+            length = entity.position - offset;
+            int nameLength = length;
+            if (nameOffset != -1) {
+                nameOffset = nameOffset - offset;
+                nameLength = length - nameOffset;
+            } else {
+                nameOffset = offset;
+            }
+            //check limit before loading more data
+            checkLimit(Limit.MAX_NAME_LIMIT, entity, nameOffset, nameLength);
+            invokeListeners(length);
+            if (length == entity.ch.length) {
+                // bad luck we have to resize our buffer
+                char[] tmp = new char[entity.fBufferSize * 2];
+                System.arraycopy(entity.ch, offset, tmp, 0, length);
+                entity.ch = tmp;
+                entity.fBufferSize *= 2;
+            }
+            else {
+                System.arraycopy(entity.ch, offset, entity.ch, 0, length);
+            }
+        }
+        return length;
+    }
+
+    /**
+     * If the current entity is an Entity reference, check the accumulated size
+     * against the limit.
+     *
+     * @param nt type of name (element, attribute or entity)
+     * @param entity The current entity
+     * @param offset The index of the first byte
+     * @param length The length of the entity scanned
+     */
+    protected void checkEntityLimit(NameType nt, ScannedEntity entity, int offset, int length) {
+        if (entity == null || !entity.isGE) {
+            return;
+        }
+
+        if (nt != NameType.REFERENCE) {
+            checkLimit(Limit.GENEAL_ENTITY_SIZE_LIMIT, entity, offset, length);
+        }
+        if (nt == NameType.ELEMENTSTART || nt == NameType.ATTRIBUTENAME) {
+            checkNodeCount(entity);
+        }
+    }
+
+    /**
+     * If the current entity is an Entity reference, counts the total nodes in
+     * the entity and checks the accumulated value against the limit.
+     *
+     * @param entity The current entity
+     */
+    protected void checkNodeCount(ScannedEntity entity) {
+        if (entity != null && entity.isGE) {
+            checkLimit(Limit.ENTITY_REPLACEMENT_LIMIT, entity, 0, 1);
+        }
+    }
+
+    /**
+     * Checks whether the value of the specified Limit exceeds its limit
+     *
+     * @param limit The Limit to be checked
+     * @param entity The current entity
+     * @param offset The index of the first byte
+     * @param length The length of the entity scanned
+     */
+    protected void checkLimit(Limit limit, ScannedEntity entity, int offset, int length) {
+        fLimitAnalyzer.addValue(limit, entity.name, length);
+        if (fSecurityManager.isOverLimit(limit, fLimitAnalyzer)) {
+            fSecurityManager.debugPrint(fLimitAnalyzer);
+            Object[] e = (limit == Limit.ENTITY_REPLACEMENT_LIMIT) ?
+                    new Object[]{fLimitAnalyzer.getValue(limit),
+                        fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)} :
+                    new Object[]{entity.name, fLimitAnalyzer.getValue(limit),
+                        fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)};
+            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, limit.key(),
+                    e, XMLErrorReporter.SEVERITY_FATAL_ERROR);
+        }
+        if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+            fSecurityManager.debugPrint(fLimitAnalyzer);
+            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "TotalEntitySizeLimit",
+                    new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)},
+                    XMLErrorReporter.SEVERITY_FATAL_ERROR);
+        }
+    }
+
+    /**
      * CHANGED:
      * Scans a range of parsed character data, This function appends the character data to
      * the supplied buffer.
@@ -898,7 +1016,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanContent(XMLString content) throws IOException {
+    protected int scanContent(XMLString content) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanContent: ");
             print();
@@ -919,6 +1037,7 @@
         int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[offset];
         int newlines = 0;
+        boolean counted = false;
         if (c == '\n' || (c == '\r' && isExternal)) {
             if (DEBUG_BUFFER) {
                 System.out.print("[newline, "+offset+", "+fCurrentEntity.position+": ");
@@ -932,9 +1051,11 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.position = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -951,9 +1072,11 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.position = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -967,6 +1090,7 @@
             }
             int length = fCurrentEntity.position - offset;
             if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                checkEntityLimit(null, fCurrentEntity, offset, length);
                 //CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
                 //on buffering the data..
                 content.setValues(fCurrentEntity.ch, offset, length);
@@ -994,6 +1118,9 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+        if (!counted) {
+            checkEntityLimit(null, fCurrentEntity, offset, length);
+        }
 
         //CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
         //on buffering the data..
@@ -1039,6 +1166,7 @@
      * @param quote   The quote character that signifies the end of the
      *                attribute value data.
      * @param content The content structure to fill.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * @return Returns the next character on the input, if known. This
      *         value may be -1 but this does <em>note</em> designate
@@ -1047,7 +1175,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanLiteral(int quote, XMLString content)
+    protected int scanLiteral(int quote, XMLString content, boolean isNSURI)
     throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanLiteral, '"+(char)quote+"': ");
@@ -1168,6 +1296,11 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+
+        checkEntityLimit(null, fCurrentEntity, offset, length);
+        if (isNSURI) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+        }
         content.setValues(fCurrentEntity.ch, offset, length);
 
         // return next character
@@ -1215,7 +1348,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean scanData(String delimiter, XMLStringBuffer buffer)
+    protected boolean scanData(String delimiter, XMLStringBuffer buffer)
     throws IOException {
 
         boolean done = false;
@@ -1253,6 +1386,7 @@
             if (fCurrentEntity.position > fCurrentEntity.count - delimLen) {
                 // something must be wrong with the input:  e.g., file ends in an unterminated comment
                 int length = fCurrentEntity.count - fCurrentEntity.position;
+                checkEntityLimit(NameType.COMMENT, fCurrentEntity, fCurrentEntity.position, length);
                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
                 fCurrentEntity.columnNumber += fCurrentEntity.count;
                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
@@ -1315,6 +1449,7 @@
                 }
                 int length = fCurrentEntity.position - offset;
                 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     if (DEBUG_BUFFER) {
                         System.out.print("]newline, "+offset+", "+fCurrentEntity.position+": ");
@@ -1358,12 +1493,14 @@
                     fCurrentEntity.position--;
                     int length = fCurrentEntity.position - offset;
                     fCurrentEntity.columnNumber += length - newlines;
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     return true;
                 }
             }
             int length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length - newlines;
+            checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
             if (done) {
                 length -= delimLen;
             }
@@ -1387,13 +1524,14 @@
      * the specified character.
      *
      * @param c The character to skip.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if the character was skipped.
      *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipChar(int c) throws IOException {
+    protected boolean skipChar(int c, NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipChar, '"+(char)c+"': ");
             print();
@@ -1406,6 +1544,7 @@
         }
 
         // skip character
+        int offset = fCurrentEntity.position;
         int cc = fCurrentEntity.ch[fCurrentEntity.position];
         if (cc == c) {
             fCurrentEntity.position++;
@@ -1420,6 +1559,7 @@
                 print();
                 System.out.println(" -> true");
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         } else if (c == '\n' && cc == '\r' && isExternal) {
             // handle newlines
@@ -1439,6 +1579,7 @@
                 print();
                 System.out.println(" -> true");
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
 
@@ -1468,7 +1609,7 @@
      *
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      */
-    public boolean skipSpaces() throws IOException {
+    protected boolean skipSpaces() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipSpaces: ");
             print();
@@ -1492,6 +1633,7 @@
 
         // skip spaces
         int c = fCurrentEntity.ch[fCurrentEntity.position];
+        int offset = fCurrentEntity.position - 1;
         if (XMLChar.isSpace(c)) {
             do {
                 boolean entityChanged = false;
@@ -1521,6 +1663,11 @@
                 } else {
                     fCurrentEntity.columnNumber++;
                 }
+
+                //If this is a general entity, spaces within a start element should be counted
+                checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                offset = fCurrentEntity.position;
+
                 // load more characters, if needed
                 if (!entityChanged){
                     fCurrentEntity.position++;
@@ -1562,7 +1709,7 @@
 
 
     /**
-     * @param legnth This function checks that following number of characters are available.
+     * @param length This function checks that following number of characters are available.
      * to the underlying buffer.
      * @return This function returns true if capacity asked is available.
      */
@@ -1571,9 +1718,9 @@
     }
 
     /**
-     * @param legnth This function checks that following number of characters are available.
+     * @param length This function checks that following number of characters are available.
      * to the underlying buffer.
-     * @param if the underlying function should change the entity
+     * @param changeEntity a flag to indicate that the underlying function should change the entity
      * @return This function returns true if capacity asked is available.
      *
      */
@@ -1636,7 +1783,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipString(String s) throws IOException {
+    protected boolean skipString(String s) throws IOException {
 
         final int length = s.length();
 
@@ -1656,6 +1803,9 @@
                 if(afterSkip-- == beforeSkip){
                     fCurrentEntity.position = fCurrentEntity.position + length ;
                     fCurrentEntity.columnNumber += length;
+                    if (!detectingVersion) {
+                        checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+                    }
                     return true;
                 }
             }
@@ -1664,7 +1814,7 @@
         return false;
     } // skipString(String):boolean
 
-    public boolean skipString(char [] s) throws IOException {
+    protected boolean skipString(char [] s) throws IOException {
 
         final int length = s.length;
         //first make sure that required capacity is avaible
@@ -1684,6 +1834,9 @@
             }
             fCurrentEntity.position = fCurrentEntity.position + length ;
             fCurrentEntity.columnNumber += length;
+            if (!detectingVersion) {
+                checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+            }
             return true;
 
         }
@@ -2081,7 +2234,7 @@
      *
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      */
-    public final boolean skipDeclSpaces() throws IOException {
+    protected final boolean skipDeclSpaces() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipDeclSpaces: ");
             //XMLEntityManager.print(fCurrentEntity);
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,68 +1,24 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2004 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
-import java.util.Hashtable;
-import java.util.Locale;
-
 import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
 import com.sun.org.apache.xerces.internal.util.ErrorHandlerProxy;
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
@@ -73,6 +29,9 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
 import org.xml.sax.ErrorHandler;
 
 /**
@@ -189,7 +148,7 @@
     protected Locale fLocale;
 
     /** Mapping of Message formatters for domains. */
-    protected Hashtable fMessageFormatters;
+    protected Map<String, MessageFormatter> fMessageFormatters;
 
     /** Error handler. */
     protected XMLErrorHandler fErrorHandler;
@@ -233,7 +192,7 @@
         //       caller to specify the location of the error being
         //       reported. -Ac
 
-        fMessageFormatters = new Hashtable();
+        fMessageFormatters = new HashMap<>();
 
     } // <init>()
 
@@ -291,7 +250,7 @@
      * @param domain The domain of the message formatter.
      */
     public MessageFormatter getMessageFormatter(String domain) {
-        return (MessageFormatter)fMessageFormatters.get(domain);
+        return fMessageFormatters.get(domain);
     } // getMessageFormatter(String):MessageFormatter
 
     /**
@@ -301,7 +260,7 @@
      * @param domain The domain of the message formatter.
      */
     public MessageFormatter removeMessageFormatter(String domain) {
-        return (MessageFormatter) fMessageFormatters.remove(domain);
+        return fMessageFormatters.remove(domain);
     } // removeMessageFormatter(String):MessageFormatter
 
     /**
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -37,6 +37,7 @@
 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
@@ -195,9 +196,9 @@
             // There are two variables,fNamespaces and fBindNamespaces
             //StAX uses XMLNSDocumentScannerImpl so this distinction needs to be maintained
             if (fNamespaces) {
-                fEntityScanner.scanQName(fElementQName);
+                fEntityScanner.scanQName(fElementQName, NameType.ELEMENTSTART);
             } else {
-                String name = fEntityScanner.scanName();
+                String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
                 fElementQName.setValues(null, name, name, null);
             }
 
@@ -410,11 +411,11 @@
         if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");
 
         // name
-        fEntityScanner.scanQName(fAttributeQName);
+        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTE);
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError("EqRequiredInAttribute",
                     new Object[]{fCurrentElement.rawname,fAttributeQName.rawname});
         }
@@ -436,24 +437,37 @@
         //since scanAttributeValue doesn't use attIndex parameter therefore we
         //can safely add the attribute later..
         XMLString tmpStr = getString();
-        scanAttributeValue(tmpStr, fTempString2,
-                fAttributeQName.rawname, attributes,
-                attrIndex, isVC, fCurrentElement.rawname);
+
+        /**
+         * Determine whether this is a namespace declaration that will be subject
+         * to the name limit check in the scanAttributeValue operation.
+         * Namespace declaration format: xmlns="..." or xmlns:prefix="..."
+         * Note that prefix:xmlns="..." isn't a namespace.
+         */
+        String localpart = fAttributeQName.localpart;
+        String prefix = fAttributeQName.prefix != null
+                ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
+        boolean isNSDecl = fBindNamespaces & (prefix == XMLSymbols.PREFIX_XMLNS ||
+                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS);
+
+        scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
+                attrIndex, isVC, fCurrentElement.rawname, isNSDecl);
 
         String value = null;
         //fTempString.toString();
 
         // record namespace declarations if any.
         if (fBindNamespaces) {
-
-            String localpart = fAttributeQName.localpart;
-            String prefix = fAttributeQName.prefix != null
-                    ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
-            // when it's of form xmlns="..." or xmlns:prefix="...",
-            // it's a namespace declaration. but prefix:xmlns="..." isn't.
-            if (prefix == XMLSymbols.PREFIX_XMLNS ||
-                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS) {
-
+            if (isNSDecl) {
+                //check the length of URI
+                if (tmpStr.length > fXMLNameLimit) {
+                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+                            "MaxXMLNameLimit",
+                            new Object[]{new String(tmpStr.ch,tmpStr.offset,tmpStr.length),
+                            tmpStr.length, fXMLNameLimit,
+                            fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.MAX_NAME_LIMIT)},
+                            XMLErrorReporter.SEVERITY_FATAL_ERROR);
+                }
                 // get the internalized value of this attribute
                 String uri = fSymbolTable.addSymbol(tmpStr.ch,tmpStr.offset,tmpStr.length);
                 value = uri;
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -116,6 +116,30 @@
     /** Debug attribute normalization. */
     protected static final boolean DEBUG_ATTR_NORMALIZATION = false;
 
+    /**
+     * Type of names
+     */
+    public static enum NameType {
+        ATTRIBUTE("attribute"),
+        ATTRIBUTENAME("attribute name"),
+        COMMENT("comment"),
+        DOCTYPE("doctype"),
+        ELEMENTSTART("startelement"),
+        ELEMENTEND("endelement"),
+        ENTITY("entity"),
+        NOTATION("notation"),
+        PI("pi"),
+        REFERENCE("reference");
+
+        final String literal;
+        NameType(String literal) {
+            this.literal = literal;
+        }
+
+        String literal() {
+            return literal;
+        }
+    }
 
     //xxx: setting the default value as false, as we dont need to calculate this value
     //we should have a feature when set to true computes this value
@@ -146,7 +170,7 @@
     protected boolean fNotifyCharRefs = false;
 
     /** Internal parser-settings feature */
-        protected boolean fParserSettings = true;
+    protected boolean fParserSettings = true;
 
     // properties
 
@@ -175,13 +199,13 @@
     /** event type */
     protected XMLEvent fEvent ;
 
-    /** Entity scanner, this alwasy works on last entity that was opened. */
+    /** Entity scanner, this always works on last entity that was opened. */
     protected XMLEntityScanner fEntityScanner = null;
 
     /** Entity depth. */
     protected int fEntityDepth;
 
-    /** Literal value of the last character refence scanned. */
+    /** Literal value of the last character reference scanned. */
     protected String fCharRefLiteral = null;
 
     /** Scanning attribute. */
@@ -549,10 +573,10 @@
         }
 
         // end
-        if (!fEntityScanner.skipChar('?')) {
+        if (!fEntityScanner.skipChar('?', null)) {
             reportFatalError("XMLDeclUnterminated", null);
         }
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("XMLDeclUnterminated", null);
 
         }
@@ -579,7 +603,7 @@
      * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
      * at the time of calling is lost.
      */
-    public String scanPseudoAttribute(boolean scanningTextDecl,
+    protected String scanPseudoAttribute(boolean scanningTextDecl,
             XMLString value)
             throws IOException, XNIException {
 
@@ -590,7 +614,7 @@
             reportFatalError("PseudoAttrNameExpected", null);
         }
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', null)) {
             reportFatalError(scanningTextDecl ? "EqRequiredInTextDecl"
                     : "EqRequiredInXMLDecl", new Object[]{name});
         }
@@ -600,15 +624,15 @@
             reportFatalError(scanningTextDecl ? "QuoteRequiredInTextDecl"
                     : "QuoteRequiredInXMLDecl" , new Object[]{name});
         }
-        fEntityScanner.scanChar();
-        int c = fEntityScanner.scanLiteral(quote, value);
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
+        int c = fEntityScanner.scanLiteral(quote, value, false);
         if (c != quote) {
             fStringBuffer2.clear();
             do {
                 fStringBuffer2.append(value);
                 if (c != -1) {
                     if (c == '&' || c == '%' || c == '<' || c == ']') {
-                        fStringBuffer2.append((char)fEntityScanner.scanChar());
+                        fStringBuffer2.append((char)fEntityScanner.scanChar(NameType.ATTRIBUTE));
                     } else if (XMLChar.isHighSurrogate(c)) {
                         scanSurrogates(fStringBuffer2);
                     } else if (isInvalidLiteral(c)) {
@@ -616,15 +640,15 @@
                                 ? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
                         reportFatalError(key,
                                 new Object[] {Integer.toString(c, 16)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, false);
             } while (c != quote);
             fStringBuffer2.append(value);
             value.setValues(fStringBuffer2);
         }
-        if (!fEntityScanner.skipChar(quote)) {
+        if (!fEntityScanner.skipChar(quote, null)) {
             reportFatalError(scanningTextDecl ? "CloseQuoteMissingInTextDecl"
                     : "CloseQuoteMissingInXMLDecl",
                     new Object[]{name});
@@ -682,7 +706,7 @@
 
         // target
         fReportEntity = false;
-        String target = fEntityScanner.scanName();
+        String target = fEntityScanner.scanName(NameType.PI);
         if (target == null) {
             reportFatalError("PITargetRequired", null);
         }
@@ -747,7 +771,7 @@
                     } else if (isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInPI",
                                 new Object[]{Integer.toHexString(c)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
             } while (fEntityScanner.scanData("?>", data));
@@ -788,11 +812,11 @@
                 if (isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInComment",
                             new Object[] { Integer.toHexString(c) });
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(NameType.COMMENT);
                 }
             }
         }
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.COMMENT)) {
             reportFatalError("DashDashInComment", null);
         }
 
@@ -813,15 +837,14 @@
      * @param checkEntities true if undeclared entities should be reported as VC violation,
      *                      false if undeclared entities should be reported as WFC violation.
      * @param eleName The name of element to which this attribute belongs.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
      * at the time of calling is lost.
      **/
-    protected void scanAttributeValue(XMLString value,
-            XMLString nonNormalizedValue,
-            String atName,
-            XMLAttributes attributes, int attrIndex,
-            boolean checkEntities, String eleName)
+    protected void scanAttributeValue(XMLString value, XMLString nonNormalizedValue,
+            String atName, XMLAttributes attributes, int attrIndex, boolean checkEntities,
+            String eleName, boolean isNSURI)
             throws IOException, XNIException {
         XMLStringBuffer stringBuffer = null;
         // quote
@@ -830,10 +853,10 @@
             reportFatalError("OpenQuoteExpected", new Object[]{eleName, atName});
         }
 
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
         int entityDepth = fEntityDepth;
 
-        int c = fEntityScanner.scanLiteral(quote, value);
+        int c = fEntityScanner.scanLiteral(quote, value, isNSURI);
         if (DEBUG_ATTR_NORMALIZATION) {
             System.out.println("** scanLiteral -> \""
                     + value.toString() + "\"");
@@ -859,11 +882,11 @@
                             + stringBuffer.toString() + "\"");
                 }
                 if (c == '&') {
-                    fEntityScanner.skipChar('&');
+                    fEntityScanner.skipChar('&', NameType.REFERENCE);
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue ) {
                         fStringBuffer2.append('&');
                     }
-                    if (fEntityScanner.skipChar('#')) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         if (entityDepth == fEntityDepth && fNeedNonNormalizedValue ) {
                             fStringBuffer2.append('#');
                         }
@@ -881,53 +904,20 @@
                             }
                         }
                     } else {
-                        String entityName = fEntityScanner.scanName();
+                        String entityName = fEntityScanner.scanName(NameType.ENTITY);
                         if (entityName == null) {
                             reportFatalError("NameRequiredInReference", null);
                         } else if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                             fStringBuffer2.append(entityName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                                     new Object []{entityName});
                         } else if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                             fStringBuffer2.append(';');
                         }
-                        if (entityName == fAmpSymbol) {
-                            stringBuffer.append('&');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value5: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fAposSymbol) {
-                            stringBuffer.append('\'');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value7: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fLtSymbol) {
-                            stringBuffer.append('<');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value9: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fGtSymbol) {
-                            stringBuffer.append('>');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueB: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fQuotSymbol) {
-                            stringBuffer.append('"');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueD: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
+                        if (resolveCharacter(entityName, stringBuffer)) {
+                            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
                         } else {
                             if (fEntityStore.isExternalEntity(entityName)) {
                                 reportFatalError("ReferenceToExternalEntity",
@@ -947,19 +937,19 @@
                                                 new Object[]{entityName});
                                     }
                                 }
-                                fEntityManager.startEntity(entityName, true);
+                                fEntityManager.startEntity(true, entityName, true);
                             }
                         }
                     }
                 } else if (c == '<') {
                     reportFatalError("LessthanInAttValue",
                             new Object[] { eleName, atName });
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
                             }
                 } else if (c == '%' || c == ']') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     stringBuffer.append((char)c);
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                         fStringBuffer2.append((char)c);
@@ -969,12 +959,13 @@
                                 + stringBuffer.toString() + "\"");
                     }
                 } else if (c == '\n' || c == '\r') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     stringBuffer.append(' ');
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                         fStringBuffer2.append('\n');
                     }
                 } else if (c != -1 && XMLChar.isHighSurrogate(c)) {
+                    fStringBuffer3.clear();
                     if (scanSurrogates(fStringBuffer3)) {
                         stringBuffer.append(fStringBuffer3);
                         if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
@@ -989,12 +980,12 @@
                 } else if (c != -1 && isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInAttValue",
                             new Object[] {eleName, atName, Integer.toString(c, 16)});
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
                             }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, isNSURI);
                 if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                     fStringBuffer2.append(value);
                 }
@@ -1015,7 +1006,7 @@
             nonNormalizedValue.setValues(fStringBuffer2);
 
         // quote
-        int cquote = fEntityScanner.scanChar();
+        int cquote = fEntityScanner.scanChar(NameType.ATTRIBUTE);
         if (cquote != quote) {
             reportFatalError("CloseQuoteExpected", new Object[]{eleName, atName});
         }
@@ -1023,6 +1014,39 @@
 
 
     /**
+     * Resolves character entity references.
+     * @param entityName the name of the entity
+     * @param stringBuffer the current XMLStringBuffer to append the character to.
+     * @return true if resolved, false otherwise
+     */
+    protected boolean resolveCharacter(String entityName, XMLStringBuffer stringBuffer) {
+        /**
+         * entityNames (symbols) are interned. The equals method would do the same,
+         * but I'm leaving it as comparisons by references are common in the impl
+         * and it made it explicit to others who read this code.
+         */
+        if (entityName == fAmpSymbol) {
+            stringBuffer.append('&');
+            return true;
+        } else if (entityName == fAposSymbol) {
+            stringBuffer.append('\'');
+            return true;
+        } else if (entityName == fLtSymbol) {
+            stringBuffer.append('<');
+            return true;
+        } else if (entityName == fGtSymbol) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
+            stringBuffer.append('>');
+            return true;
+        } else if (entityName == fQuotSymbol) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
+            stringBuffer.append('"');
+            return true;
+        }
+        return false;
+    }
+
+    /**
      * Scans External ID and return the public and system IDs.
      *
      * @param identifiers An array of size 2 to return the system id,
@@ -1065,25 +1089,25 @@
                 }
                 reportFatalError("QuoteRequiredInSystemID", null);
             }
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             XMLString ident = fString;
-            if (fEntityScanner.scanLiteral(quote, ident) != quote) {
+            if (fEntityScanner.scanLiteral(quote, ident, false) != quote) {
                 fStringBuffer.clear();
                 do {
                     fStringBuffer.append(ident);
                     int c = fEntityScanner.peekChar();
                     if (XMLChar.isMarkup(c) || c == ']') {
-                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                     } else if (c != -1 && isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInSystemID",
                             new Object[] {Integer.toString(c, 16)});
                     }
-                } while (fEntityScanner.scanLiteral(quote, ident) != quote);
+                } while (fEntityScanner.scanLiteral(quote, ident, false) != quote);
                 fStringBuffer.append(ident);
                 ident = fStringBuffer;
             }
             systemId = ident.toString();
-            if (!fEntityScanner.skipChar(quote)) {
+            if (!fEntityScanner.skipChar(quote, null)) {
                 reportFatalError("SystemIDUnterminated", null);
             }
         }
@@ -1115,7 +1139,7 @@
      */
     protected boolean scanPubidLiteral(XMLString literal)
     throws IOException, XNIException {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -1126,7 +1150,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c == ' ' || c == '\n' || c == '\r') {
                 if (!skipSpace) {
                     // take the first whitespace as a space and skip the others
@@ -1242,9 +1266,10 @@
      */
     protected int scanCharReferenceValue(XMLStringBuffer buf, XMLStringBuffer buf2)
     throws IOException, XNIException {
+        int initLen = buf.length;
         // scan hexadecimal value
         boolean hex = false;
-        if (fEntityScanner.skipChar('x')) {
+        if (fEntityScanner.skipChar('x', NameType.REFERENCE)) {
             if (buf2 != null) { buf2.append('x'); }
             hex = true;
             fStringBuffer3.clear();
@@ -1256,7 +1281,7 @@
                     (c >= 'A' && c <= 'F');
             if (digit) {
                 if (buf2 != null) { buf2.append((char)c); }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(NameType.REFERENCE);
                 fStringBuffer3.append((char)c);
 
                 do {
@@ -1266,7 +1291,7 @@
                             (c >= 'A' && c <= 'F');
                     if (digit) {
                         if (buf2 != null) { buf2.append((char)c); }
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(NameType.REFERENCE);
                         fStringBuffer3.append((char)c);
                     }
                 } while (digit);
@@ -1284,7 +1309,7 @@
             digit = c >= '0' && c <= '9';
             if (digit) {
                 if (buf2 != null) { buf2.append((char)c); }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(NameType.REFERENCE);
                 fStringBuffer3.append((char)c);
 
                 do {
@@ -1292,7 +1317,7 @@
                     digit = c >= '0' && c <= '9';
                     if (digit) {
                         if (buf2 != null) { buf2.append((char)c); }
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(NameType.REFERENCE);
                         fStringBuffer3.append((char)c);
                     }
                 } while (digit);
@@ -1302,7 +1327,7 @@
         }
 
         // end
-        if (!fEntityScanner.skipChar(';')) {
+        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
             reportFatalError("SemicolonRequiredInCharRef", null);
         }
         if (buf2 != null) { buf2.append(';'); }
@@ -1348,6 +1373,9 @@
             }
         }
 
+        if (fEntityScanner.fCurrentEntity.isGE) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, buf.length - initLen);
+        }
         return value;
     }
     // returns true if the given character is not
@@ -1401,14 +1429,14 @@
     protected boolean scanSurrogates(XMLStringBuffer buf)
     throws IOException, XNIException {
 
-        int high = fEntityScanner.scanChar();
+        int high = fEntityScanner.scanChar(null);
         int low = fEntityScanner.peekChar();
         if (!XMLChar.isLowSurrogate(low)) {
             reportFatalError("InvalidCharInContent",
                     new Object[] {Integer.toString(high, 16)});
                     return false;
         }
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(null);
 
         // convert surrogates to supplemental character
         int c = XMLChar.supplemental((char)high, (char)low);
@@ -1471,5 +1499,52 @@
         }
     }
 
+    /**
+     * Add the count of the content buffer and check if the accumulated
+     * value exceeds the limit
+     * @param isPEDecl a flag to indicate whether the entity is parameter
+     * @param entityName entity name
+     * @param buffer content buffer
+     */
+    void checkEntityLimit(boolean isPEDecl, String entityName, XMLString buffer) {
+        checkEntityLimit(isPEDecl, entityName, buffer.length);
+    }
 
+    /**
+     * Add the count and check limit
+     * @param isPEDecl a flag to indicate whether the entity is parameter
+     * @param entityName entity name
+     * @param len length of the buffer
+     */
+    void checkEntityLimit(boolean isPEDecl, String entityName, int len) {
+        if (fLimitAnalyzer == null) {
+            fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
+        }
+        if (isPEDecl) {
+            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, "%" + entityName, len);
+            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+                        fSecurityManager.debugPrint(fLimitAnalyzer);
+                reportFatalError("MaxEntitySizeLimit", new Object[]{"%" + entityName,
+                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
+            }
+        } else {
+            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT, entityName, len);
+            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+                        fSecurityManager.debugPrint(fLimitAnalyzer);
+                reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
+                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getLimit(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT)});
+            }
+        }
+        if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+            fSecurityManager.debugPrint(fLimitAnalyzer);
+            reportFatalError("TotalEntitySizeLimit",
+                new Object[]{fLimitAnalyzer.getTotalValue(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)});
+        }
+    }
 } // class XMLScanner
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,22 +25,21 @@
 
 package com.sun.org.apache.xerces.internal.impl;
 
+import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
+import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
+import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
+import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
 import com.sun.xml.internal.stream.Entity;
 import com.sun.xml.internal.stream.StaxErrorReporter;
 import com.sun.xml.internal.stream.XMLEntityStorage;
+import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
+import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
 import com.sun.xml.internal.stream.events.EntityDeclarationImpl;
 import com.sun.xml.internal.stream.events.NotationDeclarationImpl;
-import javax.xml.namespace.NamespaceContext;
-import com.sun.org.apache.xerces.internal.xni.XNIException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-import javax.xml.stream.events.XMLEvent;
-import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
-import com.sun.org.apache.xerces.internal.util.SymbolTable;
-import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
-import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -48,20 +47,16 @@
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
-import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
-import com.sun.org.apache.xerces.internal.util.XMLChar;
-import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
-import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
-import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
-import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
+import javax.xml.stream.events.XMLEvent;
 
 /** This class implements javax.xml.stream.XMLStreamReader. It makes use of XML*Scanner classes to
  * derive most of its functionality. If desired, Application can reuse this instance by calling
@@ -1173,7 +1168,7 @@
     public boolean hasText() {
         if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
         if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
-            return fScanner.getCharacterData().length > 0 ? true : false;
+            return fScanner.getCharacterData().length > 0;
         } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
             String name = fScanner.getEntityName();
             if(name != null){
@@ -1185,9 +1180,9 @@
                 if(en == null)
                     return false;
                 if(en.isExternal()){
-                    return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
+                    return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
                 } else{
-                    return ((Entity.InternalEntity)en).text != null ? true : false ;
+                    return ((Entity.InternalEntity)en).text != null ;
                 }
             }else
                 return false;
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,62 +1,21 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2003 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 2003, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
@@ -186,46 +145,52 @@
      * @throws IOException
      */
     public short determineDocVersion(XMLInputSource inputSource) throws IOException {
-        fEncoding = fEntityManager.setupCurrentEntity(fXMLSymbol, inputSource, false, true);
+        fEncoding = fEntityManager.setupCurrentEntity(false, fXMLSymbol, inputSource, false, true);
 
         // Must use XML 1.0 scanner to handle whitespace correctly
         // in the XML declaration.
         fEntityManager.setScannerVersion(Constants.XML_VERSION_1_0);
         XMLEntityScanner scanner = fEntityManager.getEntityScanner();
+        scanner.detectingVersion = true;
         try {
             if (!scanner.skipString("<?xml")) {
                 // definitely not a well-formed 1.1 doc!
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             if (!scanner.skipDeclSpaces()) {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 5);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             if (!scanner.skipString("version")) {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 6);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             scanner.skipDeclSpaces();
             // Check if the next character is '='. If it is then consume it.
             if (scanner.peekChar() != '=') {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 13);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
-            scanner.scanChar();
+            scanner.scanChar(null);
             scanner.skipDeclSpaces();
-            int quoteChar = scanner.scanChar();
+            int quoteChar = scanner.scanChar(null);
             fExpectedVersionString[14] = (char) quoteChar;
             for (int versionPos = 0; versionPos < XML11_VERSION.length; versionPos++) {
-                fExpectedVersionString[15 + versionPos] = (char) scanner.scanChar();
+                fExpectedVersionString[15 + versionPos] = (char) scanner.scanChar(null);
             }
             // REVISIT:  should we check whether this equals quoteChar?
-            fExpectedVersionString[18] = (char) scanner.scanChar();
+            fExpectedVersionString[18] = (char) scanner.scanChar(null);
             fixupCurrentEntity(fEntityManager, fExpectedVersionString, 19);
             int matched = 0;
             for (; matched < XML11_VERSION.length; matched++) {
                 if (fExpectedVersionString[15 + matched] != XML11_VERSION[matched])
                     break;
             }
+            scanner.detectingVersion = false;
             if (matched == XML11_VERSION.length)
                 return Constants.XML_VERSION_1_1;
             return Constants.XML_VERSION_1_0;
@@ -237,10 +202,9 @@
                 "PrematureEOF",
                 null,
                 XMLErrorReporter.SEVERITY_FATAL_ERROR);
+            scanner.detectingVersion = false;
             return Constants.XML_VERSION_1_0;
-
         }
-
     }
 
     // This method prepends "length" chars from the char array,
--- a/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,69 +1,25 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2002 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl.dtd;
 
-import java.util.ArrayList;
-import java.util.Hashtable;
-
 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMBinOp;
 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMLeaf;
@@ -88,10 +44,13 @@
 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * A DTD grammar. This class implements the XNI handler interfaces
- * for DTD information so that it can build the approprate validation
+ * for DTD information so that it can build the appropriate validation
  * structures automatically from the callbacks.
  *
  * @xerces.internal
@@ -251,13 +210,13 @@
     // other information
 
     /** Element index mapping table. */
-    private QNameHashtable fElementIndexMap = new QNameHashtable();
+    private final Map<String, Integer> fElementIndexMap = new HashMap<>();
 
     /** Entity index mapping table. */
-    private QNameHashtable fEntityIndexMap = new QNameHashtable();
+    private final Map<String, Integer> fEntityIndexMap = new HashMap<>();
 
     /** Notation index mapping table. */
-    private QNameHashtable fNotationIndexMap = new QNameHashtable();
+    private final Map<String, Integer> fNotationIndexMap = new HashMap<>();
 
     // temp variables
 
@@ -291,7 +250,7 @@
     private XMLContentSpec fContentSpec = new XMLContentSpec();
 
     /** table of XMLElementDecl   */
-    Hashtable   fElementDeclTab     = new Hashtable();
+    Map<String, XMLElementDecl> fElementDeclTab = new HashMap<>();
 
     /** Children content model operation stack. */
     private short[] fOpStack = null;
@@ -516,7 +475,7 @@
     public void elementDecl(String name, String contentModel, Augmentations augs)
         throws XNIException {
 
-        XMLElementDecl tmpElementDecl = (XMLElementDecl) fElementDeclTab.get(name) ;
+        XMLElementDecl tmpElementDecl = fElementDeclTab.get(name) ;
 
         // check if it is already defined
         if ( tmpElementDecl != null ) {
@@ -606,7 +565,7 @@
                               String defaultType, XMLString defaultValue,
                               XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
 
-        if ( this.fElementDeclTab.containsKey( (String) elementName) ) {
+        if ( this.fElementDeclTab.containsKey(elementName) ) {
             //if ElementDecl has already being created in the Grammar then remove from table,
             //this.fElementDeclTab.remove( (String) elementName );
         }
@@ -989,7 +948,7 @@
     public void startContentModel(String elementName, Augmentations augs)
         throws XNIException {
 
-        XMLElementDecl elementDecl = (XMLElementDecl) this.fElementDeclTab.get( elementName);
+        XMLElementDecl elementDecl = this.fElementDeclTab.get(elementName);
         if ( elementDecl != null ) {
             fElementDecl = elementDecl;
         }
@@ -1216,7 +1175,10 @@
      * @return index of the elementDeclName in scope
      */
     public int getElementDeclIndex(String elementDeclName) {
-        int mapping = fElementIndexMap.get(elementDeclName);
+        Integer mapping = fElementIndexMap.get(elementDeclName);
+        if (mapping == null) {
+            mapping = -1;
+        }
         //System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping);
         return mapping;
     } // getElementDeclIndex(String):int
@@ -1393,7 +1355,7 @@
      * @return the index of the EntityDecl
      */
     public int getEntityDeclIndex(String entityDeclName) {
-        if (entityDeclName == null) {
+        if (entityDeclName == null || fEntityIndexMap.get(entityDeclName) == null) {
             return -1;
         }
 
@@ -1436,7 +1398,7 @@
      * @return the index if found a notation with the name, otherwise -1.
      */
     public int getNotationDeclIndex(String notationDeclName) {
-        if (notationDeclName == null) {
+        if (notationDeclName == null || fNotationIndexMap.get(notationDeclName) == null) {
             return -1;
         }
 
@@ -2670,108 +2632,6 @@
     } // class ChildrenList
 
     //
-    // Classes
-    //
-
-    /**
-     * A simple Hashtable implementation that takes a tuple (String, String)
-     * as the key and a int as value.
-     *
-     * @xerces.internal
-     *
-     * @author Eric Ye, IBM
-     * @author Andy Clark, IBM
-     */
-    protected static final class QNameHashtable {
-
-        //
-        // Constants
-        //
-
-        /** Initial bucket size (4). */
-        private static final int INITIAL_BUCKET_SIZE = 4;
-
-        // NOTE: Changed previous hashtable size from 512 to 101 so
-        //       that we get a better distribution for hashing. -Ac
-        /** Hashtable size (101). */
-        private static final int HASHTABLE_SIZE = 101;
-
-        //
-        // Data
-        //
-        private Object[][] fHashTable = new Object[HASHTABLE_SIZE][];
-
-        //
-        // Public methods
-        //
-        /** Associates the given value with the specified key tuple. */
-        public void put(String key, int value) {
-
-            int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
-            Object[] bucket = fHashTable[hash];
-
-            if (bucket == null) {
-                bucket = new Object[1 + 2*INITIAL_BUCKET_SIZE];
-                bucket[0] = new int[]{1};
-                bucket[1] = key;
-                bucket[2] = new int[]{value};
-                fHashTable[hash] = bucket;
-            } else {
-                int count = ((int[])bucket[0])[0];
-                int offset = 1 + 2*count;
-                if (offset == bucket.length) {
-                    int newSize = count + INITIAL_BUCKET_SIZE;
-                    Object[] newBucket = new Object[1 + 2*newSize];
-                    System.arraycopy(bucket, 0, newBucket, 0, offset);
-                    bucket = newBucket;
-                    fHashTable[hash] = bucket;
-                }
-                boolean found = false;
-                int j=1;
-                for (int i=0; i<count; i++){
-                    if ((String)bucket[j] == key) {
-                        ((int[])bucket[j+1])[0] = value;
-                        found = true;
-                        break;
-                    }
-                    j += 2;
-                }
-                if (! found) {
-                    bucket[offset++] = key;
-                    bucket[offset]= new int[]{value};
-                    ((int[])bucket[0])[0] = ++count;
-                }
-
-            }
-            //System.out.println("put("+key+" -> "+value+')');
-            //System.out.println("get("+key+") -> "+get(key));
-
-        } // put(int,String,String,int)
-
-        /** Returns the value associated with the specified key tuple. */
-        public int get(String key) {
-            int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
-            Object[] bucket = fHashTable[hash];
-
-            if (bucket == null) {
-                return -1;
-            }
-            int count = ((int[])bucket[0])[0];
-
-            int j=1;
-            for (int i=0; i<count; i++){
-                if ((String)bucket[j] == key) {
-                    return ((int[])bucket[j+1])[0];
-                }
-                j += 2;
-            }
-            return -1;
-
-        } // get(int,String,String)
-
-    }  // class QNameHashtable
-
-    //
     // EntityState methods
     //
     public boolean isEntityDeclared (String name){
--- a/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammarBucket.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammarBucket.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,68 +1,28 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2002 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl.dtd;
 
 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This very simple class is the skeleton of what the DTDValidator could use
@@ -87,7 +47,7 @@
     //
 
     /** Grammars associated with element root name. */
-    protected Hashtable fGrammars;
+    protected Map<XMLDTDDescription, DTDGrammar> fGrammars;
 
     // the unique grammar from fGrammars (or that we're
     // building) that is used in validation.
@@ -102,7 +62,7 @@
 
     /** Default constructor. */
     public DTDGrammarBucket() {
-        fGrammars = new Hashtable();
+        fGrammars = new HashMap<>();
     } // <init>()
 
     //
@@ -122,7 +82,7 @@
 
     // retrieve a DTDGrammar given an XMLDTDDescription
     public DTDGrammar getGrammar(XMLGrammarDescription desc) {
-        return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
+        return fGrammars.get((XMLDTDDescription)desc);
     } // putGrammar(DTDGrammar)
 
     public void clear() {
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,7 +20,7 @@
 
 package com.sun.org.apache.xerces.internal.impl.dv;
 
-import java.util.Hashtable;
+import java.util.Map;
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
 
 /**
@@ -80,10 +80,10 @@
     public abstract DatatypeValidator getBuiltInDV(String name);
 
     /**
-     * get all built-in DVs, which are stored in a hashtable keyed by the name
+     * get all built-in DVs, which are stored in a map keyed by the name
      *
-     * @return      a hashtable which contains all datatypes
+     * @return      a map which contains all datatypes
      */
-    public abstract Hashtable getBuiltInTypes();
+    public abstract Map<String, DatatypeValidator> getBuiltInTypes();
 
 }
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,7 +22,9 @@
 
 import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;
 import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * the factory to create/return built-in schema DVs and create user-defined DVs
@@ -34,9 +36,25 @@
  */
 public class DTDDVFactoryImpl extends DTDDVFactory {
 
-    static Hashtable fBuiltInTypes = new Hashtable();
+    static final Map<String, DatatypeValidator> fBuiltInTypes;
     static {
-        createBuiltInTypes();
+        Map<String, DatatypeValidator> builtInTypes = new HashMap<>();
+        DatatypeValidator dvTemp;
+
+        builtInTypes.put("string", new StringDatatypeValidator());
+        builtInTypes.put("ID", new IDDatatypeValidator());
+        dvTemp = new IDREFDatatypeValidator();
+        builtInTypes.put("IDREF", dvTemp);
+        builtInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
+        dvTemp = new ENTITYDatatypeValidator();
+        builtInTypes.put("ENTITY", new ENTITYDatatypeValidator());
+        builtInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
+        builtInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
+        dvTemp = new NMTOKENDatatypeValidator();
+        builtInTypes.put("NMTOKEN", dvTemp);
+        builtInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
+
+        fBuiltInTypes = Collections.unmodifiableMap(builtInTypes);
     }
 
     /**
@@ -45,37 +63,19 @@
      * @param name  the name of the datatype
      * @return      the datatype validator of the given name
      */
+    @Override
     public DatatypeValidator getBuiltInDV(String name) {
-        return (DatatypeValidator)fBuiltInTypes.get(name);
+        return fBuiltInTypes.get(name);
     }
 
     /**
-     * get all built-in DVs, which are stored in a hashtable keyed by the name
+     * get all built-in DVs, which are stored in a Map keyed by the name
      *
-     * @return      a hashtable which contains all datatypes
+     * @return      a Map which contains all datatypes
      */
-    public Hashtable getBuiltInTypes() {
-        return (Hashtable)fBuiltInTypes.clone();
+    @Override
+    public Map<String, DatatypeValidator> getBuiltInTypes() {
+        return new HashMap<>(fBuiltInTypes);
     }
 
-    // create all built-in types
-    static void createBuiltInTypes() {
-
-        DatatypeValidator dvTemp;
-
-        fBuiltInTypes.put("string", new StringDatatypeValidator());
-        fBuiltInTypes.put("ID", new IDDatatypeValidator());
-        dvTemp = new IDREFDatatypeValidator();
-        fBuiltInTypes.put("IDREF", dvTemp);
-        fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
-        dvTemp = new ENTITYDatatypeValidator();
-        fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
-        fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
-        fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
-        dvTemp = new NMTOKENDatatypeValidator();
-        fBuiltInTypes.put("NMTOKEN", dvTemp);
-        fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
-
-    }//createBuiltInTypes()
-
 }// DTDDVFactoryImpl
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,10 +20,10 @@
 
 package com.sun.org.apache.xerces.internal.impl.dv.dtd;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
-
 import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * the factory to create/return built-in XML 1.1 DVs and create user-defined DVs
@@ -35,7 +35,18 @@
  */
 public class XML11DTDDVFactoryImpl extends DTDDVFactoryImpl {
 
-    static Hashtable fXML11BuiltInTypes = new Hashtable();
+    static Map<String, DatatypeValidator> XML11BUILTINTYPES;
+    static {
+        Map<String, DatatypeValidator> xml11BuiltInTypes = new HashMap<>();
+        xml11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
+        DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
+        xml11BuiltInTypes.put("XML11IDREF", dvTemp);
+        xml11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
+        dvTemp = new XML11NMTOKENDatatypeValidator();
+        xml11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
+        xml11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
+        XML11BUILTINTYPES = Collections.unmodifiableMap(xml11BuiltInTypes);
+    } // <clinit>
 
     /**
      * return a dtd type of the given name
@@ -45,38 +56,24 @@
      * @param name  the name of the datatype
      * @return      the datatype validator of the given name
      */
+    @Override
     public DatatypeValidator getBuiltInDV(String name) {
-        if(fXML11BuiltInTypes.get(name) != null) {
-            return (DatatypeValidator)fXML11BuiltInTypes.get(name);
+        if(XML11BUILTINTYPES.get(name) != null) {
+            return XML11BUILTINTYPES.get(name);
         }
-        return (DatatypeValidator)fBuiltInTypes.get(name);
+        return fBuiltInTypes.get(name);
     }
 
     /**
-     * get all built-in DVs, which are stored in a hashtable keyed by the name
+     * get all built-in DVs, which are stored in a Map keyed by the name
      * New XML 1.1 datatypes are inserted.
      *
-     * @return      a hashtable which contains all datatypes
+     * @return      a Map which contains all datatypes
      */
-    public Hashtable getBuiltInTypes() {
-        Hashtable toReturn = (Hashtable)fBuiltInTypes.clone();
-        Enumeration xml11Keys = fXML11BuiltInTypes.keys();
-        while (xml11Keys.hasMoreElements()) {
-            Object key = xml11Keys.nextElement();
-            toReturn.put(key, fXML11BuiltInTypes.get(key));
-        }
+    @Override
+    public Map<String, DatatypeValidator> getBuiltInTypes() {
+        final HashMap<String, DatatypeValidator> toReturn = new HashMap<>(fBuiltInTypes);
+        toReturn.putAll(XML11BUILTINTYPES);
         return toReturn;
     }
-
-    static {
-        fXML11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
-        DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
-        fXML11BuiltInTypes.put("XML11IDREF", dvTemp);
-        fXML11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
-        dvTemp = new XML11NMTOKENDatatypeValidator();
-        fXML11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
-        fXML11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
-    } // <clinit>
-
-
 }//XML11DTDDVFactoryImpl
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -43,7 +43,7 @@
 
 #Error codes used in DOM Normalizer
 InvalidXMLCharInDOM = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde bei der Normalisierung im DOM gefunden.
-UndeclaredEntRefInAttrValue = Attribut "{0}" Wert "{1}" referenzierte eine nicht deklarierte Entit\u00E4t.
+UndeclaredEntRefInAttrValue = Attribut "{0}" Wert "{1}" referenzierte eine nicht deklarierte Entity.
 NullLocalElementName = Lokaler Nullname wurde bei der Namespace-Normalisierung von Element {0} gefunden.
 NullLocalAttrName = Lokaler Nullname wurde bei der Namespace-Normalisierung von Attribut {0} gefunden.
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -10,9 +10,9 @@
 FieldCannotBeNull=\u7121\u6CD5\u4F7F\u7528 ''null'' \u53C3\u6578\u547C\u53EB {0}
 UnknownField=\u4F7F\u7528\u4E0D\u660E\u7684\u6B04\u4F4D\u547C\u53EB {0}:{1}
 #There are two similar keys 'InvalidXMLGreogorianCalendarValue' . Suffix (year, month) has been added and are used as per the context.
-InvalidXGCValue-milli=\u5E74 = {0}\u3001\u6708 = {1}\uFF0C\u65E5 = {2}\uFF0C\u5C0F\u6642 = {3}\uFF0C\u5206\u9418\uFF0C = {4}\uFF0C\u79D2 = {5}\uFF0C\u5C0F\u6578\u79D2 = {6}\uFF0C\u6642\u5340\uFF0C = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
+InvalidXGCValue-milli=\u5E74 = {0}\u3001\u6708 = {1}\u3001\u65E5 = {2}\u3001\u5C0F\u6642 = {3}\u3001\u5206\u9418 = {4}\u3001\u79D2 = {5}\u3001\u5C0F\u6578\u79D2 = {6}\u3001\u6642\u5340 = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
 #There are two similar keys 'InvalidXMLGreogorianCalendarValue' . Suffix (year, month) has been added and are used as per the context.
-InvalidXGCValue-fractional=\u5E74 = {0}\u3001\u6708 = {1}\uFF0C\u65E5 = {2}\uFF0C\u5C0F\u6642 = {3}\uFF0C\u5206\u9418\uFF0C = {4}\uFF0C\u79D2 = {5}\uFF0C\u5C0F\u6578\u79D2 = {6}\uFF0C\u6642\u5340\uFF0C = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
+InvalidXGCValue-fractional=\u5E74 = {0}\u3001\u6708 = {1}\u3001\u65E5 = {2}\u3001\u5C0F\u6642 = {3}\u3001\u5206\u9418 = {4}\u3001\u79D2 = {5}\u3001\u5C0F\u6578\u79D2 = {6}\u3001\u6642\u5340 = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
 
 InvalidXGCFields=XMLGregorianCalendar \u8A2D\u5B9A\u4E86\u7121\u6548\u7684\u6B04\u4F4D\u96C6
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -17,14 +17,14 @@
 NO_XPointerSchema = Schema f\u00FCr "{0}" wird standardm\u00E4\u00DFig nicht unterst\u00FCtzt. Definieren Sie Ihr eigenes Schema f\u00FCr {0}. Siehe http://apache.org/xml/properties/xpointer-schema
 NO_SubResourceIdentified = Keine Subressource von XPointer-Prozessor f\u00FCr Zeiger {0} identifiziert.
 NonDuplicateNotation = Mehrere Notationen mit dem Namen "{0}" wurden verwendet, die aber nicht als Duplikate ermittelt wurden.
-NonDuplicateUnparsedEntity = Mehrere nicht geparste Entit\u00E4ten mit dem Namen "{0}" wurden verwendet, die aber nicht als Duplikate ermittelt wurden.
+NonDuplicateUnparsedEntity = Mehrere nicht geparste Entitys mit dem Namen "{0}" wurden verwendet, die aber nicht als Duplikate ermittelt wurden.
 XpointerMissing = xpointer-Attribut muss vorhanden sein, wenn href-Attribut fehlt.
 AcceptMalformed = Zeichen au\u00DFerhalb des Bereichs #x20 bis #x7E sind im Wert des "accept"-Attributs eines "include"-Elements nicht zul\u00E4ssig.
 AcceptLanguageMalformed = Zeichen au\u00DFerhalb des Bereichs #x20 bis #x7E sind im Wert des "accept-language"-Attributs eines "include"-Elements nicht zul\u00E4ssig.
 RootElementRequired = F\u00FCr ein ordnungsgem\u00E4\u00DF formatiertes Dokument ist ein Root-Element erforderlich.
 MultipleRootElements = Ein ordnungsgem\u00E4\u00DF formatiertes Dokument darf nicht mehrere Root-Elemente enthalten.
 ContentIllegalAtTopLevel = Der Ersatz eines "include"-Elements, das als Dokumentelement im Quell-Infoset der obersten Ebene angezeigt wird, darf keine Zeichen enthalten.
-UnexpandedEntityReferenceIllegal = Der Ersatz eines "include"-Elements, das als Dokumentelement im Quell-Infoset der obersten Ebene angezeigt wird, darf keine nicht erweiterten Entit\u00E4tsreferenzen enthalten.
+UnexpandedEntityReferenceIllegal = Der Ersatz eines "include"-Elements, das als Dokumentelement im Quell-Infoset der obersten Ebene angezeigt wird, darf keine nicht erweiterten Entityreferenzen enthalten.
 HrefFragmentIdentifierIllegal = Fragment-IDs d\u00FCrfen nicht verwendet werden. Der "href"-Attributwert "{0}" ist nicht zul\u00E4ssig.
 HrefSyntacticallyInvalid = "href"-Attributwert "{0}" hat eine ung\u00FCltige Syntax. Nach Anwenden der Escape-Regeln ist der Wert kein syntaktisch korrekter URI oder IRI.
 XPointerStreamability = Es wurde ein xpointer angegeben, der auf eine Stelle im Quell-Infoset verweist. Auf diese Stelle kann aufgrund des Streamingcharakters des Prozessors nicht zugegriffen werden.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -294,10 +294,11 @@
 
 
 # Implementation limits
-        EntityExpansionLimitExceeded=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
+        EntityExpansionLimit=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
         ElementAttributeLimit=JAXP00010002:  Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the JDK.
         MaxEntitySizeLimit=JAXP00010003: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
-        TotalEntitySizeLimit=JAXP00010004: The accumulated size \"{0}\" of entities exceeded the \"{1}\" limit set by \"{2}\".
-        MaxXMLNameLimit=JAXP00010005: The name \"{0}\" exceeded the \"{1}\" limit set by \"{2}\".
+        TotalEntitySizeLimit=JAXP00010004: The accumulated size of entities is \"{0}\" that exceeded the \"{1}\" limit set by \"{2}\".
+        MaxXMLNameLimit=JAXP00010005: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
         MaxElementDepthLimit=JAXP00010006: The element \"{0}\" has a depth of \"{1}\" that exceeds the limit \"{2}\" set by \"{3}\".
+        EntityReplacementLimit=JAXP00010007: The total number of nodes in entity references is \"{0}\" that is over the limit \"{1}\" set by \"{2}\".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -62,9 +62,9 @@
 # 4.1 Character and Entity References
         ReferenceUnterminated = Referenz muss mit einem ";"-Begrenzungszeichen beendet werden.
 # 4.3.2 Well-Formed Parsed Entities
-        ReferenceNotInOneEntity = Referenz muss vollst\u00E4ndig in derselben geparsten Entit\u00E4t enthalten sein.
-        ElementEntityMismatch = Element "{0}" muss innerhalb derselben Entit\u00E4t beginnen und enden.
-        MarkupEntityMismatch=XML-Dokumentstrukturen m\u00FCssen innerhalb derselben Entit\u00E4t beginnen und enden.
+        ReferenceNotInOneEntity = Referenz muss vollst\u00E4ndig in derselben geparsten Entity enthalten sein.
+        ElementEntityMismatch = Element "{0}" muss innerhalb derselben Entity beginnen und enden.
+        MarkupEntityMismatch=XML-Dokumentstrukturen m\u00FCssen innerhalb derselben Entity beginnen und enden.
         
 # Messages common to Document and DTD
 # 2.2 Characters
@@ -81,27 +81,27 @@
         InvalidCommentStart = Kommentar muss mit "<!--" beginnen.
         DashDashInComment = Zeichenfolge "--" ist in Kommentaren nicht zul\u00E4ssig.
         CommentUnterminated = Kommentar muss mit "-->" enden.
-        COMMENT_NOT_IN_ONE_ENTITY = Kommentar ist nicht in derselben Entit\u00E4t enthalten.
+        COMMENT_NOT_IN_ONE_ENTITY = Kommentar ist nicht in derselben Entity enthalten.
 # 2.6 Processing Instructions
         PITargetRequired = Verarbeitungsanweisung muss mit dem Namen des Ziels beginnen.
         SpaceRequiredInPI = Leerstelle ist zwischen dem Ziel der Verarbeitungsanweisung und den Daten erforderlich.
         PIUnterminated = Verarbeitungsanweisung muss mit "?>" enden.
         ReservedPITarget = Verarbeitungsanweisungsziel, das "[xX][mM][lL]" entspricht, ist nicht zul\u00E4ssig.
-        PI_NOT_IN_ONE_ENTITY = Verarbeitungsanweisung ist nicht in derselben Entit\u00E4t enthalten.
+        PI_NOT_IN_ONE_ENTITY = Verarbeitungsanweisung ist nicht in derselben Entity enthalten.
 # 2.8 Prolog and Document Type Declaration
         VersionInfoInvalid = Ung\u00FCltige Version "{0}".
         VersionNotSupported = XML-Version "{0}" wird nicht unterst\u00FCtzt. Nur XML 1.0 wird unterst\u00FCtzt.
         VersionNotSupported11 = XML-Version "{0}" wird nicht unterst\u00FCtzt. Nur XML 1.0 und XML 1.1 werden unterst\u00FCtzt.
-        VersionMismatch= Eine Entit\u00E4t kann keine andere Entit\u00E4t einer sp\u00E4teren Version enthalten.
+        VersionMismatch= Eine Entity kann keine andere Entity einer sp\u00E4teren Version enthalten.
 # 4.1 Character and Entity References
         DigitRequiredInCharRef = Auf "&#" in einer Zeichenreferenz muss umgehend eine Dezimaldarstellung folgen.
         HexdigitRequiredInCharRef = Auf "&#x" in einer Zeichenreferenz muss umgehend eine hexadezimale Darstellung folgen.
         SemicolonRequiredInCharRef = Zeichenreferenz muss mit dem Begrenzungszeichen ";" enden.
         InvalidCharRef = Zeichenreferenz "&#{0}" ist ein ung\u00FCltiges XML-Zeichen.
-        NameRequiredInReference = Auf "&" in der Entit\u00E4tsreferenz muss umgehend der Entit\u00E4tsname folgen.
-        SemicolonRequiredInReference = Referenz zu Entit\u00E4t "{0}" muss mit dem Begrenzungszeichen ";" enden.
+        NameRequiredInReference = Auf "&" in der Entityreferenz muss umgehend der Entityname folgen.
+        SemicolonRequiredInReference = Referenz zu Entity "{0}" muss mit dem Begrenzungszeichen ";" enden.
 # 4.3.1 The Text Declaration
-        TextDeclMustBeFirst = Textdeklaration darf nur ganz am Anfang der externen geparsten Entit\u00E4t enthalten sein.
+        TextDeclMustBeFirst = Textdeklaration darf nur ganz am Anfang der externen geparsten Entity enthalten sein.
         EqRequiredInTextDecl = Zeichen " = " muss auf "{0}" in der Textdeklaration folgen.
         QuoteRequiredInTextDecl = Der Wert nach "{0}" in der Textdeklaration muss eine Zeichenfolge in Anf\u00FChrungszeichen sein.
         CloseQuoteMissingInTextDecl = Schlie\u00DFendes Anf\u00FChrungszeichen im Wert nach "{0}" in der Textdeklaration fehlt.
@@ -113,8 +113,8 @@
         MorePseudoAttributes = Es werden weitere Pseudoattribute erwartet.
         PseudoAttrNameExpected = Pseudoattributname wird erwartet. 
 # 4.3.2 Well-Formed Parsed Entities
-        CommentNotInOneEntity = Kommentar muss vollst\u00E4ndig in derselben geparsten Entit\u00E4t enthalten sein.
-        PINotInOneEntity = Verarbeitungsanweisung muss vollst\u00E4ndig in derselben geparsten Entit\u00E4t enthalten sein.
+        CommentNotInOneEntity = Kommentar muss vollst\u00E4ndig in derselben geparsten Entity enthalten sein.
+        PINotInOneEntity = Verarbeitungsanweisung muss vollst\u00E4ndig in derselben geparsten Entity enthalten sein.
 # 4.3.3 Character Encoding in Entities
         EncodingDeclInvalid = Ung\u00FCltiger Codierungsname "{0}".
         EncodingByteOrderUnsupported = Angegebene Bytereihenfolge f\u00FCr die Codierung von "{0}" wird nicht unterst\u00FCtzt.
@@ -123,11 +123,11 @@
         InvalidHighSurrogate = High-Surrogate-Bits in UTF-8-Sequenz d\u00FCrfen 0x10 nicht \u00FCberschreiten, gefunden wurde aber 0x{0}.
         OperationNotSupported = Vorgang "{0}" nicht unterst\u00FCtzt von {1}-Reader.
         InvalidASCII = Byte "{0}" geh\u00F6rt nicht zum (7-Bit) ASCII-Zeichensatz.
-        CharConversionFailure = Eine Entit\u00E4t, f\u00FCr die eine bestimmte Codierung ermittelt wurde, darf keine Sequenzen enthalten, die in dieser Codierung ung\u00FCltig sind.
+        CharConversionFailure = Eine Entity, f\u00FCr die eine bestimmte Codierung ermittelt wurde, darf keine Sequenzen enthalten, die in dieser Codierung ung\u00FCltig sind.
         
 # DTD Messages
 # 2.2 Characters
-        InvalidCharInEntityValue = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde im literalen Entit\u00E4tswert gefunden.
+        InvalidCharInEntityValue = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde im literalen Entitywert gefunden.
         InvalidCharInExternalSubset = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde in der externen Teilmenge der DTD gefunden.
         InvalidCharInIgnoreSect = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde im ausgeschlossenen Bedingungsabschnitt gefunden.
         InvalidCharInPublicID = Ung\u00FCltiges XML-Zeichen (Unicode: 0x{0}) wurde in der \u00F6ffentlichen ID gefunden.
@@ -145,7 +145,7 @@
         MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL = Leerstelle nach "<!DOCTYPE" in der Dokumenttypdeklaration erforderlich.
         MSG_ROOT_ELEMENT_TYPE_REQUIRED = Root-Elementtyp muss nach "<!DOCTYPE" in der Dokumenttypdeklaration enthalten sein.
         DoctypedeclUnterminated = Dokumenttypdeklaration f\u00FCr Root-Elementtyp "{0}" muss mit ">" enden.
-        PEReferenceWithinMarkup = Parameterentit\u00E4tsreferenz "%{0};" darf nicht in Markup in der internen Teilmenge der DTD vorkommen.
+        PEReferenceWithinMarkup = Parameterentityreferenz "%{0};" darf nicht in Markup in der internen Teilmenge der DTD vorkommen.
         MSG_MARKUP_NOT_RECOGNIZED_IN_DTD = Die Markup-Deklarationen, die in der Dokumenttypdeklaration enthalten sind bzw. auf die von der Dokumenttypdeklaration verwiesen wird, m\u00FCssen ordnungsgem\u00E4\u00DF formatiert sein.
 # 2.10 White Space Handling
         MSG_XML_SPACE_DECLARATION_ILLEGAL = Attributdeklaration f\u00FCr "xml:space" muss als aufgez\u00E4hlter Typ angegeben werden, dessen einzigen m\u00F6glichen Werte "default" und "preserve" sind.
@@ -186,21 +186,21 @@
         IncludeSectUnterminated = Der eingeschlossene Bedingungsabschnitt muss mit "]]>" enden.
         IgnoreSectUnterminated = Der ausgeschlossene Bedingungsabschnitt muss mit "]]>" enden.
 # 4.1 Character and Entity References
-        NameRequiredInPEReference = Auf "%" in der Parameterentit\u00E4tsreferenz muss umgehend der Entit\u00E4tsname folgen.
-        SemicolonRequiredInPEReference = Parameterentit\u00E4tsreferenz "%{0};" muss mit dem Begrenzungszeichen ";" enden.
+        NameRequiredInPEReference = Auf "%" in der Parameterentityreferenz muss umgehend der Entityname folgen.
+        SemicolonRequiredInPEReference = Parameterentityreferenz "%{0};" muss mit dem Begrenzungszeichen ";" enden.
 # 4.2 Entity Declarations
-        MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL = Leerstelle nach "<!ENTITY" in der Entit\u00E4tsdeklaration erforderlich.
-        MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL = Leerstelle zwischen "<!ENTITY" und dem Zeichen "%" in der Parameterentit\u00E4tsdeklaration erforderlich.
-        MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL = Leerstelle zwischen "%" und dem Entit\u00E4tsnamen in der Parameterentit\u00E4tsdeklaration erforderlich.
-        MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL = Name der Entit\u00E4t ist in der Entit\u00E4tsdeklaration erforderlich.
-        MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL = Leerstelle zwischen dem Entit\u00E4tsnamen "{0}" und der Definition in der Entit\u00E4tsdeklaration erforderlich.
-        MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL = Leerstelle zwischen "NDATA" und dem Notationsnamen in der Deklaration f\u00FCr die Entit\u00E4t "{0} erforderlich.
-        MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL = Leerstelle vor "NDATA" in der Deklaration f\u00FCr die Entit\u00E4t "{0} erforderlich.
-        MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL = Notationsname ist nach "NDATA" in der Deklaration f\u00FCr die Entit\u00E4t "{0} erforderlich.
-        EntityDeclUnterminated = Deklaration f\u00FCr Entit\u00E4t "{0}" muss mit ">" enden.
-	MSG_DUPLICATE_ENTITY_DEFINITION = Entit\u00E4t "{0}" wurde mehrmals deklariert.        
+        MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL = Leerstelle nach "<!ENTITY" in der Entitydeklaration erforderlich.
+        MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL = Leerstelle zwischen "<!ENTITY" und dem Zeichen "%" in der Parameterentitydeklaration erforderlich.
+        MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL = Leerstelle zwischen "%" und dem Entitynamen in der Parameterentitydeklaration erforderlich.
+        MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL = Name der Entity ist in der Entitydeklaration erforderlich.
+        MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL = Leerstelle zwischen dem Entitynamen "{0}" und der Definition in der Entitydeklaration erforderlich.
+        MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL = Leerstelle zwischen "NDATA" und dem Notationsnamen in der Deklaration f\u00FCr die Entity "{0} erforderlich.
+        MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL = Leerstelle vor "NDATA" in der Deklaration f\u00FCr die Entity "{0} erforderlich.
+        MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL = Notationsname ist nach "NDATA" in der Deklaration f\u00FCr die Entity "{0} erforderlich.
+        EntityDeclUnterminated = Deklaration f\u00FCr Entity "{0}" muss mit ">" enden.
+	MSG_DUPLICATE_ENTITY_DEFINITION = Entity "{0}" wurde mehrmals deklariert.        
 # 4.2.2 External Entities
-        ExternalIDRequired = Externe Entit\u00E4tsdeklaration muss mit "SYSTEM" oder "PUBLIC" beginnen.
+        ExternalIDRequired = Externe Entitydeklaration muss mit "SYSTEM" oder "PUBLIC" beginnen.
         MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID = Leerstelle zwischen "PUBLIC" und der \u00F6ffentlichen ID erforderlich.
         MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID = Leerstelle zwischen der \u00F6ffentlichen ID und der System-ID erforderlich.
         MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID = Leerstelle zwischen "SYSTEM" und der System-ID erforderlich.
@@ -214,8 +214,8 @@
         
 # Validation messages
         DuplicateTypeInMixedContent = Elementtyp "{1}" wurde bereits im Contentmodell der Elementdeklaration"{0}" angegeben.
-        ENTITIESInvalid = Attributwert "{1}" mit dem Typ ENTITIES muss aus den Namen von mindestens einer geparsten Entit\u00E4t bestehen.
-        ENTITYInvalid = Attributwert "{1}" mit dem Typ ENTITY muss aus dem Namen einer geparsten Entit\u00E4t bestehen.
+        ENTITIESInvalid = Attributwert "{1}" mit dem Typ ENTITIES muss aus den Namen von mindestens einer geparsten Entity bestehen.
+        ENTITYInvalid = Attributwert "{1}" mit dem Typ ENTITY muss aus dem Namen einer geparsten Entity bestehen.
         IDDefaultTypeInvalid = ID-Attribut "{0}" muss den deklarierten Standardwert "#IMPLIED" oder "#REQUIRED" haben.
         IDInvalid = Attributwert "{0}" mit dem Typ ID muss ein Name sein.
         IDInvalidWithNamespaces = Attributwert "{0}" mit dem Typ ID muss ein NCName sein, wenn Namespaces aktiviert sind.
@@ -223,10 +223,10 @@
         IDREFInvalid = Attributwert "{0}" mit dem Typ IDREF muss ein Name sein.
         IDREFInvalidWithNamespaces = Attributwert "{0}" mit dem Typ IDREF muss ein NCName sein, wenn Namespaces aktiviert sind.
         IDREFSInvalid = Attributwert "{0}" mit dem Typ IDREFS muss mindestens ein Name sein.
-        ILL_FORMED_PARAMETER_ENTITY_WHEN_USED_IN_DECL = Ersatztext der Parameterentit\u00E4t "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Deklarationen enthalten, wenn die Entit\u00E4tsreferenz als vollst\u00E4ndige Deklaration verwendet wird.
-        ImproperDeclarationNesting = Ersatztext der Parameterentit\u00E4t "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Deklarationen enthalten.
-        ImproperGroupNesting = Ersatztext der Parameterentit\u00E4t "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Klammernpaare enthalten.
-        INVALID_PE_IN_CONDITIONAL = Ersatztext der Parameterentit\u00E4t "{0}" muss den gesamten Bedingungsabschnitt oder nur INCLUDE oder IGNORE enthalten.
+        ILL_FORMED_PARAMETER_ENTITY_WHEN_USED_IN_DECL = Ersatztext der Parameterentity "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Deklarationen enthalten, wenn die Entityreferenz als vollst\u00E4ndige Deklaration verwendet wird.
+        ImproperDeclarationNesting = Ersatztext der Parameterentity "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Deklarationen enthalten.
+        ImproperGroupNesting = Ersatztext der Parameterentity "{0}" muss ordnungsgem\u00E4\u00DF verschachtelte Klammernpaare enthalten.
+        INVALID_PE_IN_CONDITIONAL = Ersatztext der Parameterentity "{0}" muss den gesamten Bedingungsabschnitt oder nur INCLUDE oder IGNORE enthalten.
         MSG_ATTRIBUTE_NOT_DECLARED = Attribut "{1}" muss f\u00FCr Elementtyp "{0}" deklariert werden.
         MSG_ATTRIBUTE_VALUE_NOT_IN_LIST = Attribut "{0}" mit Wert "{1}" muss einen Wert aus der Liste "{2}" haben.
         MSG_ATTVALUE_CHANGED_DURING_NORMALIZATION_WHEN_STANDALONE = Der Wert "{1}" des Attributs "{0}" darf nicht von der Normalisierung (zu "{2}") in einem Standalone-Dokument ge\u00E4ndert werden.
@@ -239,15 +239,15 @@
         MSG_ELEMENT_NOT_DECLARED = Elementtyp "{0}" muss deklariert werden.
         MSG_GRAMMAR_NOT_FOUND = Dokument ist ung\u00FCltig. Keine Grammatik gefunden.
         MSG_ELEMENT_WITH_ID_REQUIRED = Element mit "{0}" ist im Dokument erforderlich.
-        MSG_EXTERNAL_ENTITY_NOT_PERMITTED = Referenz zur externen Entit\u00E4t "{0}" ist in einem Standalone-Dokument nicht zul\u00E4ssig.
+        MSG_EXTERNAL_ENTITY_NOT_PERMITTED = Referenz zur externen Entity "{0}" ist in einem Standalone-Dokument nicht zul\u00E4ssig.
         MSG_FIXED_ATTVALUE_INVALID = Attribut "{1}" mit Wert "{2}" muss den Wert"{3}" haben.
         MSG_MORE_THAN_ONE_ID_ATTRIBUTE = Elementtyp "{0}" hat bereits ein Attribut "{1}" mit dem Typ ID. Ein zweites Attribut "{2}" mit dem Typ ID ist nicht zul\u00E4ssig.
         MSG_MORE_THAN_ONE_NOTATION_ATTRIBUTE = Elementtyp "{0}" hat bereits ein Attribut "{1}" mit dem Typ NOTATION. Ein zweites Attribut "{2}" mit dem Typ NOTATION ist nicht zul\u00E4ssig.
         MSG_NOTATION_NOT_DECLARED_FOR_NOTATIONTYPE_ATTRIBUTE = Notation "{1}" muss deklariert werden, wenn sie in der Notationstypliste f\u00FCr Attribut "{0}" referenziert wird.
-        MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL = Notation "{1}" muss deklariert werden, wenn sie in der Deklaration der nicht geparsten Entit\u00E4t f\u00FCr "{0}" referenziert wird.
-        MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE = Referenz zur Entit\u00E4t "{0}", die in einer externen geparsten Entit\u00E4t deklariert wird, ist in einem Standalone-Dokument nicht zul\u00E4ssig.
+        MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL = Notation "{1}" muss deklariert werden, wenn sie in der Deklaration der nicht geparsten Entity f\u00FCr "{0}" referenziert wird.
+        MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE = Referenz zur Entity "{0}", die in einer externen geparsten Entity deklariert wird, ist in einem Standalone-Dokument nicht zul\u00E4ssig.
         MSG_REQUIRED_ATTRIBUTE_NOT_SPECIFIED = Attribut "{1}" ist erforderlich und muss f\u00FCr Elementtyp "{0}" angegeben werden.
-        MSG_WHITE_SPACE_IN_ELEMENT_CONTENT_WHEN_STANDALONE = Es d\u00FCrfen keine Leerstellen zwischen Elementen in einem Standalone-Dokument vorkommen, die in einer externen geparsten Entit\u00E4t mit Elementcontent deklariert sind.
+        MSG_WHITE_SPACE_IN_ELEMENT_CONTENT_WHEN_STANDALONE = Es d\u00FCrfen keine Leerstellen zwischen Elementen in einem Standalone-Dokument vorkommen, die in einer externen geparsten Entity mit Elementcontent deklariert sind.
         NMTOKENInvalid = Attributwert "{0}" mit dem Typ NMTOKEN muss ein Namenstoken sein.
         NMTOKENSInvalid = Attributwert "{0}" mit dem Typ NMTOKENS muss mindestens ein Namenstoken sein.
         NoNotationOnEmptyElement = Elementtyp "{0}", der als EMPTY deklariert wurde, kann nicht das Attribut "{1}" mit dem Typ NOTATION deklarieren.
@@ -261,19 +261,19 @@
 
 # Entity related messages
 # 3.1 Start-Tags, End-Tags, and Empty-Element Tags
-        ReferenceToExternalEntity = Externe Entit\u00E4tsreferenz "&{0};" ist in einem Attributwert nicht zul\u00E4ssig.
+        ReferenceToExternalEntity = Externe Entityreferenz "&{0};" ist in einem Attributwert nicht zul\u00E4ssig.
         AccessExternalDTD = Externe DTD: Lesen von externer DTD "{0}" nicht erfolgreich, da "{1}"-Zugriff wegen der von der Eigenschaft "accessExternalDTD" festgelegten Einschr\u00E4nkung nicht zul\u00E4ssig ist.
-        AccessExternalEntity = Externe Entit\u00E4t: Lesen des externen Dokuments "{0}" nicht erfolgreich, da "{1}"-Zugriff wegen der von der Eigenschaft "accessExternalDTD" festgelegten Einschr\u00E4nkung nicht zul\u00E4ssig ist.
+        AccessExternalEntity = Externe Entity: Lesen des externen Dokuments "{0}" nicht erfolgreich, da "{1}"-Zugriff wegen der von der Eigenschaft "accessExternalDTD" festgelegten Einschr\u00E4nkung nicht zul\u00E4ssig ist.
 
 # 4.1 Character and Entity References
-        EntityNotDeclared = Entit\u00E4t "{0}" wurde referenziert aber nicht deklariert.
-        ReferenceToUnparsedEntity = Nicht geparste Entit\u00E4tsreferenz "&{0};" ist nicht zul\u00E4ssig.
-        RecursiveReference = Rekursive Entit\u00E4tsreferenz "{0}". (Referenzpfad: {1}),
-        RecursiveGeneralReference = Rekursive allgemeine Entit\u00E4tsreferenz "&{0};". (Referenzpfad: {1}),
-        RecursivePEReference = Rekursive Parameterentit\u00E4tsreferenz "%{0};". (Referenzpfad: {1}),
+        EntityNotDeclared = Entity "{0}" wurde referenziert aber nicht deklariert.
+        ReferenceToUnparsedEntity = Nicht geparste Entityreferenz "&{0};" ist nicht zul\u00E4ssig.
+        RecursiveReference = Rekursive Entityreferenz "{0}". (Referenzpfad: {1}),
+        RecursiveGeneralReference = Rekursive allgemeine Entityreferenz "&{0};". (Referenzpfad: {1}),
+        RecursivePEReference = Rekursive Parameterentityreferenz "%{0};". (Referenzpfad: {1}),
 # 4.3.3 Character Encoding in Entities
         EncodingNotSupported = Codierung "{0}" wird nicht unterst\u00FCtzt.
-        EncodingRequired = Eine nicht in UTF-8 oder UTF-16 codierte geparste Entit\u00E4t muss eine Codierungsdeklaration enthalten.
+        EncodingRequired = Eine nicht in UTF-8 oder UTF-16 codierte geparste Entity muss eine Codierungsdeklaration enthalten.
         
 # Namespaces support
 # 4. Using Qualified Names
@@ -294,10 +294,11 @@
 
 
 # Implementation limits
-        EntityExpansionLimitExceeded=JAXP00010001: Der Parser hat mehr als {0} Entit\u00E4tserweiterungen in diesem Dokument gefunden. Dies ist der von JDK vorgeschriebene Grenzwert.
+        EntityExpansionLimitExceeded=JAXP00010001: Der Parser hat mehr als {0} Entityerweiterungen in diesem Dokument gefunden. Dies ist der von JDK vorgeschriebene Grenzwert.
         ElementAttributeLimit=JAXP00010002: Element "{0}" hat mehr als {1} Attribute. "{1}" ist der von JDK vorgeschriebene Grenzwert.
-        MaxEntitySizeLimit=JAXP00010003: Die L\u00E4nge von Entit\u00E4t "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
-        TotalEntitySizeLimit=JAXP00010004: Die akkumulierte Gr\u00F6\u00DFe "{0}" der Entit\u00E4ten \u00FCberschreitet den Grenzwert "{1}", der von "{2}" festgelegt wurde.
+        MaxEntitySizeLimit=JAXP00010003: Die L\u00E4nge von Entity "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
+        TotalEntitySizeLimit=JAXP00010004: Die akkumulierte Gr\u00F6\u00DFe von Entitys ist "{0}" und \u00FCberschreitet den Grenzwert "{1}", der von "{2}" festgelegt wurde.
         MaxXMLNameLimit=JAXP00010005: Der Name "{0}" \u00FCberschreitet den Grenzwert "{1}", der von "{2}" festgelegt wurde.
         MaxElementDepthLimit=JAXP00010006: Die Tiefe von Element "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
+        EntityReplacementLimit=JAXP00010007: Die Gesamtanzahl von Knoten in Entityreferenzen betr\u00E4gt "{0}". Das liegt \u00FCber dem von "{2}" festgelegten Grenzwert "{1}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: el analizador ha encontrado m\u00E1s de "{0}"ampliaciones de entidad en este documento; \u00E9ste es el l\u00EDmite impuesto por el JDK.
         ElementAttributeLimit=JAXP00010002: el elemento "{0}" tiene m\u00E1s de "{1}" atributos, "{1}" es el l\u00EDmite impuesto por el JDK.
         MaxEntitySizeLimit=JAXP00010003: la longitud de la entidad "{0}" es "{1}", que excede el l\u00EDmite de "{2}" que ha definido "{3}".
-        TotalEntitySizeLimit=JAXP00010004: el tama\u00F1o acumulado "{0}" de las entidades ha excedido el l\u00EDmite de "{1}" que ha definido "{2}".
+        TotalEntitySizeLimit=JAXP00010004: el tama\u00F1o acumulado de las entidades es "{0}" y excede el l\u00EDmite de "{1}" definido por "{2}".
         MaxXMLNameLimit=JAXP00010005: el nombre "{0}" ha excedido el l\u00EDmite de "{1}" que ha definido "{2}".
         MaxElementDepthLimit=JAXP00010006: El elemento "{0}" tiene una profundidad de "{1}" que excede el l\u00EDmite "{2}" definido por "{3}".
+        EntityReplacementLimit=JAXP00010007: El n\u00FAmero total de nodos en las referencias de entidad es de "{0}" que supera el l\u00EDmite de "{1}" definido por "{2}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001 : L''analyseur a rencontr\u00E9 plus de "{0}" d\u00E9veloppements d''entit\u00E9 dans ce document. Il s''agit de la limite impos\u00E9e par le JDK.
         ElementAttributeLimit=JAXP00010002 : L''\u00E9l\u00E9ment "{0}" a plus de "{1}" attributs. "{1}" est la limite impos\u00E9e par le JDK.
         MaxEntitySizeLimit=JAXP00010003 : La longueur de l''entit\u00E9 "{0}" est de "{1}". Cette valeur d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
-        TotalEntitySizeLimit=JAXP00010004 : La taille cumul\u00E9e des entit\u00E9s ("{0}") d\u00E9passe la limite de "{1}" d\u00E9finie par "{2}".
+        TotalEntitySizeLimit=JAXP00010004 : La taille cumul\u00E9e des entit\u00E9s est "{0}" et d\u00E9passe la limite de "{1}" d\u00E9finie par "{2}".
         MaxXMLNameLimit=JAXP00010005 : le nom "{0}" d\u00E9passe la limite de "{1}" d\u00E9finie par "{2}".
         MaxElementDepthLimit=JAXP00010006 : l''\u00E9l\u00E9ment "{0}" a une profondeur de "{1}" qui d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
+        EntityReplacementLimit=JAXP00010007 : Le nombre total de noeuds dans les r\u00E9f\u00E9rences d''entit\u00E9 est "{0}", soit plus que la limite de "{1}" d\u00E9finie par "{2}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: il parser ha rilevato pi\u00F9 "{0}" espansioni di entit\u00E0 nel documento. Questo \u00E8 il limite imposto dal kit JDK.
         ElementAttributeLimit=JAXP00010002: l''elemento "{0}" contiene pi\u00F9 di "{1}" attributi. "{1}" \u00E8 il limite imposto dal kit JDK.
         MaxEntitySizeLimit=JAXP00010003: la lunghezza dell''entit\u00E0 "{0}" \u00E8 "{1}". Tale valore supera il limite "{2}" definito da "{3}".
-        TotalEntitySizeLimit=JAXP00010004: le dimensioni accumulate "{0}" delle entit\u00E0 supera il limite "{1}" definito da "{2}".
+        TotalEntitySizeLimit=JAXP00010004: le dimensioni accumulate delle entit\u00E0 sono pari a "{0}". Tale valore supera il limite "{1}" definito da "{2}".
         MaxXMLNameLimit=JAXP00010005: il nome "{0}" supera il limite "{1}" definito da "{2}".
         MaxElementDepthLimit=JAXP00010006: la profondit\u00E0 dell''elemento "{0}" \u00E8 "{1}". Tale valore supera il limite "{2}" definito da "{3}".
+        EntityReplacementLimit=JAXP00010007: il numero totale di nodi nei riferimenti entit\u00E0 \u00E8 "{0}". Tale valore supera il limite di "{1}" impostato da "{2}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -300,4 +300,5 @@
         TotalEntitySizeLimit=JAXP00010004: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u306E\u7D2F\u7A4D\u30B5\u30A4\u30BA"{0}"\u306F\u3001"{2}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{1}"\u3092\u8D85\u3048\u307E\u3057\u305F\u3002
         MaxXMLNameLimit=JAXP00010005: \u540D\u524D"{0}"\u306F\u3001"{2}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{1}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
         MaxElementDepthLimit=JAXP00010006: \u8981\u7D20"{0}"\u306E\u6DF1\u3055\u306F"{1}"\u3067\u3001"{3}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{2}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
+        EntityReplacementLimit=JAXP00010007: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u53C2\u7167\u306E\u5408\u8A08\u30CE\u30FC\u30C9\u6570\u306F"{0}"\u3067\u3001"{2}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{1}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: \uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC774 \uBB38\uC11C\uC5D0\uC11C "{0}"\uAC1C\uB97C \uCD08\uACFC\uD558\uB294 \uC5D4\uD2F0\uD2F0 \uD655\uC7A5\uC744 \uBC1C\uACAC\uD588\uC2B5\uB2C8\uB2E4. \uC774\uB294 JDK\uC5D0\uC11C \uC801\uC6A9\uD558\uB294 \uC81C\uD55C\uC785\uB2C8\uB2E4.
         ElementAttributeLimit=JAXP00010002:  "{0}" \uC694\uC18C\uC5D0 "{1}"\uAC1C\uB97C \uCD08\uACFC\uD558\uB294 \uC18D\uC131\uC774 \uC788\uC2B5\uB2C8\uB2E4. "{1}"\uC740(\uB294) JDK\uC5D0\uC11C \uC801\uC6A9\uD558\uB294 \uC81C\uD55C\uC785\uB2C8\uB2E4.
         MaxEntitySizeLimit=JAXP00010003: "{0}" \uC5D4\uD2F0\uD2F0\uC758 \uAE38\uC774\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uB41C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
-        TotalEntitySizeLimit=JAXP00010004: \uC5D4\uD2F0\uD2F0\uC758 \uB204\uC801 \uD06C\uAE30 "{0}"\uC774(\uAC00) "{2}"\uC5D0\uC11C \uC124\uC815\uB41C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4.
+        TotalEntitySizeLimit=JAXP00010004: \uC5D4\uD2F0\uD2F0\uC758 \uB204\uC801 \uD06C\uAE30\uAC00 "{2}"\uC5D0\uC11C \uC124\uC815\uD55C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{0}"\uC785\uB2C8\uB2E4.
         MaxXMLNameLimit=JAXP00010005: "{0}" \uC774\uB984\uC774 "{2}"\uC5D0\uC11C \uC124\uC815\uB41C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4.
         MaxElementDepthLimit=JAXP00010006: "{0}" \uC694\uC18C\uC758 \uAE4A\uC774\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uB41C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
+        EntityReplacementLimit=JAXP00010007: \uC5D4\uD2F0\uD2F0 \uCC38\uC870\uC758 \uCD1D \uB178\uB4DC \uC218\uAC00 "{2}"\uC5D0\uC11C \uC124\uC815\uD55C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{0}"\uC785\uB2C8\uB2E4.
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: O parser detectou mais de "{0}" expans\u00F5es da entidade neste documento. Este \u00E9 o limite imposto pelo JDK.
         ElementAttributeLimit=JAXP00010002: o elemento "{0}" tem mais de "{1}" atributos. "{1}" \u00E9 o limite imposto pelo JDK.
         MaxEntitySizeLimit=JAXP00010003: o tamanho da entidade "{0}" \u00E9 "{1}", o que excede o limite de "{2}" definido por "{3}".
-        TotalEntitySizeLimit=JAXP00010004: o tamanho acumulado  "{0}" de entidades excedeu o limite de "{1}" definido por "{2}".
+        TotalEntitySizeLimit=JAXP00010004: o tamanho acumulado de entidades \u00E9 "{0}", o que excedeu o limite de "{1}" definido por "{2}".
         MaxXMLNameLimit=JAXP00010005: o nome "{0}" excedeu o limite de "{1}" definido por "{2}".
         MaxElementDepthLimit=JAXP00010006: o elemento "{0}" tem uma profundidade de "{1}" que excede o limite de "{2}" definido por "{3}".
+        EntityReplacementLimit=JAXP00010007: O n\u00FAmero total de n\u00F3s nas refer\u00EAncias da entidade \u00E9 de "{0}", o que est\u00E1 acima do limite de "{1}" definido por "{2}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: Parsern har p\u00E5tr\u00E4ffat fler \u00E4n "{0}" enhetstill\u00E4gg i dokumentet - gr\u00E4nsv\u00E4rdet f\u00F6r JDK har uppn\u00E5tts.
         ElementAttributeLimit=JAXP00010002:  Elementet "{0}" har fler \u00E4n "{1}" attribut, "{1}" \u00E4r gr\u00E4nsv\u00E4rdet f\u00F6r JDK.
         MaxEntitySizeLimit=JAXP00010003: L\u00E4ngden p\u00E5 enheten "{0}" \u00E4r "{1}" som \u00F6verskriver gr\u00E4nsv\u00E4rdet p\u00E5 "{2}" som anges av "{3}".
-        TotalEntitySizeLimit=JAXP00010004: Den ackumulerade storleken "{0}" f\u00F6r enheter \u00F6verskred gr\u00E4nsv\u00E4rdet p\u00E5 "{1}" som anges av "{2}".
+        TotalEntitySizeLimit=JAXP00010004: Den ackumulerade storleken f\u00F6r enheter \u00E4r "{0}", vilket \u00F6verskrider gr\u00E4nsv\u00E4rdet "{1}" som anges av "{2}".
         MaxXMLNameLimit=JAXP00010005: Namnet "{0}" \u00F6verskred gr\u00E4nsv\u00E4rdet p\u00E5 "{1}" som anges av "{2}".
         MaxElementDepthLimit=JAXP00010006: Elementet "{0}" har djupet "{1}" vilket \u00E4r st\u00F6rre \u00E4n gr\u00E4nsen "{2}" som anges av "{3}".
+        EntityReplacementLimit=JAXP00010007: Det totala antalet noder i enhetsreferenser \u00E4r "{0}", vilket \u00E4r \u00F6ver gr\u00E4nsen "{1}" som har angetts av "{2}".
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -297,7 +297,8 @@
         EntityExpansionLimitExceeded=JAXP00010001: \u89E3\u6790\u5668\u5728\u6B64\u6587\u6863\u4E2D\u9047\u5230\u591A\u4E2A "{0}" \u5B9E\u4F53\u6269\u5C55; \u8FD9\u662F JDK \u65BD\u52A0\u7684\u9650\u5236\u3002
         ElementAttributeLimit=JAXP00010002: \u5143\u7D20 "{0}" \u5177\u6709\u591A\u4E2A "{1}" \u5C5E\u6027, "{1}" \u662F JDK \u65BD\u52A0\u7684\u9650\u5236\u3002
         MaxEntitySizeLimit=JAXP00010003: \u5B9E\u4F53 "{0}" \u7684\u957F\u5EA6\u4E3A "{1}", \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684 "{2}" \u9650\u5236\u3002
-        TotalEntitySizeLimit=JAXP00010004: \u5B9E\u4F53\u7684\u7D2F\u8BA1\u5927\u5C0F "{0}" \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684 "{1}" \u9650\u5236\u3002
+        TotalEntitySizeLimit=JAXP00010004: \u5B9E\u4F53\u7684\u7D2F\u8BA1\u5927\u5C0F\u4E3A "{0}", \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684 "{1}" \u9650\u5236\u3002
         MaxXMLNameLimit=JAXP00010005: \u540D\u79F0 "{0}" \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684 "{1}" \u9650\u5236\u3002
         MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6 "{1}" \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684\u9650\u5236 "{2}"\u3002
+        EntityReplacementLimit=JAXP00010007: \u5B9E\u4F53\u5F15\u7528\u4E2D\u7684\u8282\u70B9\u603B\u6570\u4E3A "{0}", \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684\u9650\u5236 "{1}"\u3002
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -198,7 +198,7 @@
         MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL = \u5728\u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u4E2D\uFF0C"NDATA" \u4E4B\u524D\u9700\u8981\u7A7A\u683C\u3002
         MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL = \u5728\u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u4E2D\uFF0C"NDATA" \u4E4B\u5F8C\u9700\u8981\u8868\u793A\u6CD5\u540D\u7A31\u3002
         EntityDeclUnterminated = \u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u7D50\u5C3E\u5FC5\u9808\u70BA ''>''\u3002
-	MSG_DUPLICATE_ENTITY_DEFINITION = \u5BE6\u9AD4 "{0}" \u5BA3\u544A\u8D85\u904E\u4E00\u6B21\u4EE5\u4E0A\u3002        
+	MSG_DUPLICATE_ENTITY_DEFINITION = \u5BE6\u9AD4 "{0}" \u5BA3\u544A\u8D85\u904E\u4E00\u6B21\u4EE5\u4E0A\u3002
 # 4.2.2 External Entities
         ExternalIDRequired = \u5916\u90E8\u5BE6\u9AD4\u5BA3\u544A\u7684\u958B\u982D\u5FC5\u9808\u70BA "SYSTEM" \u6216 "PUBLIC"\u3002
         MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID = "PUBLIC" \u8207\u516C\u7528 ID \u4E4B\u9593\u9700\u8981\u7A7A\u683C\u3002
@@ -254,7 +254,7 @@
         RootElementTypeMustMatchDoctypedecl = \u6587\u4EF6\u6839\u5143\u7D20 "{1}" \u5FC5\u9808\u914D\u5C0D DOCTYPE \u6839 "{0}"\u3002
         UndeclaredElementInContentSpec = \u5143\u7D20 "{0}" \u7684\u5167\u5BB9\u6A21\u578B\u53C3\u7167\u672A\u5BA3\u544A\u7684\u5143\u7D20 "{1}"\u3002
         UniqueNotationName = \u8868\u793A\u6CD5 "{0}" \u7684\u5BA3\u544A\u4E26\u975E\u552F\u4E00\u3002\u6307\u5B9A\u7684 Name \u4E0D\u80FD\u5728\u4E00\u500B\u4EE5\u4E0A\u7684\u8868\u793A\u6CD5\u5BA3\u544A\u4E2D\u5BA3\u544A\u3002
-        ENTITYFailedInitializeGrammar =  ENTITYDatatype \u9A57\u8B49\u7A0B\u5F0F: \u5931\u6557\u3002\u9700\u8981\u4F7F\u7528\u6709\u6548\u7684\u6587\u6CD5\u53C3\u7167\u4F86\u547C\u53EB\u8D77\u59CB\u65B9\u6CD5\u3002 \t
+        ENTITYFailedInitializeGrammar =  ENTITYDatatype \u9A57\u8B49\u7A0B\u5F0F: \u5931\u6557\u3002\u9700\u8981\u4F7F\u7528\u6709\u6548\u7684\u6587\u6CD5\u53C3\u7167\u4F86\u547C\u53EB\u8D77\u59CB\u65B9\u6CD5\u3002\t
         ENTITYNotUnparsed = ENTITY "{0}" \u4E26\u975E\u672A\u7D93\u5256\u6790\u3002
         ENTITYNotValid = ENTITY "{0}" \u7121\u6548\u3002
         EmptyList = \u985E\u578B ENTITIES\u3001IDREFS \u8207 NMTOKENS \u7684\u503C\u4E0D\u53EF\u70BA\u7A7A\u767D\u6E05\u55AE\u3002
@@ -277,7 +277,7 @@
         
 # Namespaces support
 # 4. Using Qualified Names
-        IllegalQName = \u5143\u7D20\u6216\u5C6C\u6027\u4E0D\u7B26\u5408 QName \u7522\u751F: QName::=(NCName':')?NCName\u3002 
+        IllegalQName = \u5143\u7D20\u6216\u5C6C\u6027\u4E0D\u7B26\u5408 QName \u7522\u751F: QName::=(NCName':')?NCName\u3002
         ElementXMLNSPrefix = \u5143\u7D20 "{0}" \u4E0D\u80FD\u4F7F\u7528 "xmlns" \u4F5C\u70BA\u524D\u7F6E\u78BC\u3002
         ElementPrefixUnbound = \u5143\u7D20 "{1}" \u7684\u524D\u7F6E\u78BC "{0}" \u672A\u9023\u7D50\u3002
         AttributePrefixUnbound = \u95DC\u806F\u5143\u7D20\u985E\u578B "{0}" \u4E4B\u5C6C\u6027 "{1}" \u7684\u524D\u7F6E\u78BC "{2}" \u672A\u9023\u7D50\u3002
@@ -298,6 +298,8 @@
         ElementAttributeLimit=JAXP00010002: \u5143\u7D20 "{0}" \u5177\u6709\u8D85\u904E "{1}" \u500B\u4EE5\u4E0A\u7684\u5C6C\u6027\uFF0C"{1}" \u662F JDK \u6240\u898F\u5B9A\u7684\u9650\u5236\u3002
         MaxEntitySizeLimit=JAXP00010003: \u5BE6\u9AD4 "{0}" \u7684\u9577\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
         TotalEntitySizeLimit=JAXP00010004: \u5BE6\u9AD4\u7684\u7D2F\u7A4D\u5927\u5C0F "{0}" \u8D85\u904E "{2}" \u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
+        TotalEntitySizeLimit=JAXP00010004: \u5BE6\u9AD4\u7684\u7D2F\u7A4D\u5927\u5C0F\u70BA "{0}"\uFF0C\u8D85\u904E "{2}" \u6240\u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
         MaxXMLNameLimit=JAXP00010005: \u540D\u7A31 "{0}" \u8D85\u904E "{2}" \u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
-        MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
+        MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
+        EntityReplacementLimit=JAXP00010007: \u5BE6\u9AD4\u53C3\u7167\u4E2D\u7684\u7BC0\u9EDE\u7E3D\u6578\u70BA "{0}"\uFF0C\u8D85\u904E "{2}" \u6240\u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
 
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -283,7 +283,7 @@
         FacetValueFromBase = FacetValueFromBase: In the declaration of type ''{0}'', value ''{1}'' of facet ''{2}'' must be from the value space of the base type, ''{3}''.
         FixedFacetValue = FixedFacetValue: In the definition of {3}, the value ''{1}'' for the facet ''{0}'' is invalid, because the value for ''{0}'' has been set to ''{2}'' in one of the ancestor types, and '{'fixed'}' = true.
         InvalidRegex = InvalidRegex: Pattern value ''{0}'' is not a valid regular expression. The reported error was: ''{1}'' at column ''{2}''.
-        maxOccurLimit = Current configuration of the parser doesn''t allow a maxOccurs attribute value to be set greater than the value {0}.
+        MaxOccurLimit = Current configuration of the parser doesn''t allow a maxOccurs attribute value to be set greater than the value {0}.
         PublicSystemOnNotation = PublicSystemOnNotation: At least one of ''public'' and ''system'' must appear in element ''notation''.
         SchemaLocation = SchemaLocation: schemaLocation value = ''{0}'' must have even number of URI''s.
         TargetNamespace.1 = TargetNamespace.1: Expecting namespace ''{0}'', but the target namespace of the schema document is ''{1}''.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -288,5 +288,5 @@
         SchemaLocation = SchemaLocation: schemaLocation-Wert = "{0}" muss eine gerade Anzahl an URIs haben.
         TargetNamespace.1 = TargetNamespace.1: Namespace "{0}" wird erwartet, aber der Ziel-Namespace des Schemadokuments ist "{1}".
         TargetNamespace.2 = TargetNamespace.2: Kein Namespace wird erwartet, aber das Schemadokument hat den Ziel-Namespace "{1}".
-        UndeclaredEntity = UndeclaredEntity: Entit\u00E4t "{0}" ist nicht deklariert.
+        UndeclaredEntity = UndeclaredEntity: Entity ''{0}'' ist nicht deklariert.
         UndeclaredPrefix = UndeclaredPrefix: "{0}" kann nicht als QName aufgel\u00F6st werden: Pr\u00E4fix "{1}" ist nicht deklariert.
--- a/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties	Wed Sep 07 06:06:32 2016 +0100
@@ -189,7 +189,7 @@
         e-props-correct.5 = e-props-correct.5: '{'value constraint'}' \u4E0D\u53EF\u51FA\u73FE\u5728\u5143\u7D20 ''{0}'' \u4E0A\uFF0C\u56E0\u70BA\u5143\u7D20\u7684 '{'type definition'}' \u6216 '{'type definition'}' \u7684 '{'content type'}' \u70BA ID\uFF0C\u6216\u884D\u751F\u81EA ID\u3002
         e-props-correct.6 = e-props-correct.6: \u5075\u6E2C\u5230 ''{0}'' \u7684\u5FAA\u74B0\u66FF\u4EE3\u7FA4\u7D44\u3002
         fractionDigits-valid-restriction = fractionDigits-valid-restriction: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0Cfacet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u5B83\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''fractionDigits'' \u7684\u503C\uFF0C\u6B64\u503C\u4EE5\u5176\u4E2D\u4E00\u500B\u7956\u7CFB\u985E\u578B\u8A2D\u70BA ''{1}''\u3002
-        fractionDigits-totalDigits = fractionDigits-totalDigits: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0C facet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u503C\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''totalDigits'' \u7684\u503C\uFF0C\u4EA6\u5373 ''{1}''\u3002
+        fractionDigits-totalDigits = fractionDigits-totalDigits: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0Cfacet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u503C\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''totalDigits'' \u7684\u503C\uFF0C\u4EA6\u5373 ''{1}''\u3002
         length-minLength-maxLength.1.1 = length-minLength-maxLength.1.1: \u91DD\u5C0D\u985E\u578B {0}\uFF0Clength ''{1}'' \u7684\u503C\u5C0F\u65BC minLength ''{2}'' \u7684\u503C\u662F\u4E00\u9805\u932F\u8AA4\u3002
         length-minLength-maxLength.1.2.a = length-minLength-maxLength.1.2.a: \u91DD\u5C0D\u985E\u578B {0}\uFF0C\u82E5\u76EE\u524D\u9650\u5236\u5177\u6709 minLength facet \u4E14\u76EE\u524D\u7684\u9650\u5236\u6216\u57FA\u790E\u5177\u6709 length facet\uFF0C\u5247\u57FA\u790E\u6C92\u6709 minLength facet \u662F\u4E00\u9805\u932F\u8AA4\u3002
         length-minLength-maxLength.1.2.b = length-minLength-maxLength.1.2.b: \u91DD\u5C0D\u985E\u578B {0}\uFF0C\u76EE\u524D\u7684 minLength ''{1}'' \u4E0D\u7B49\u65BC\u57FA\u790E minLength ''{2}'' \u662F\u4E00\u9805\u932F\u8AA4\u3002
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,13 +20,14 @@
 
 package com.sun.org.apache.xerces.internal.impl.xpath;
 
-import java.util.Vector;
-
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.QName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
 
 /**
  * Bare minimum XPath parser.
@@ -858,10 +859,10 @@
         private SymbolTable fSymbolTable;
 
         // REVISIT: Code something better here. -Ac
-        private java.util.Hashtable fSymbolMapping = new java.util.Hashtable();
+        private Map<String, Integer> fSymbolMapping = new HashMap<>();
 
         // REVISIT: Code something better here. -Ac
-        private java.util.Hashtable fTokenNames = new java.util.Hashtable();
+        private Map<Integer, String> fTokenNames = new HashMap<>();
 
         /**
          * Current position in the token list.
@@ -882,57 +883,57 @@
                 "self",
             };
             for (int i = 0; i < symbols.length; i++) {
-                fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), new Integer(i));
+                fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), i);
             }
-            fTokenNames.put(new Integer(EXPRTOKEN_OPEN_PAREN), "EXPRTOKEN_OPEN_PAREN");
-            fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_PAREN), "EXPRTOKEN_CLOSE_PAREN");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPEN_BRACKET), "EXPRTOKEN_OPEN_BRACKET");
-            fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_BRACKET), "EXPRTOKEN_CLOSE_BRACKET");
-            fTokenNames.put(new Integer(EXPRTOKEN_PERIOD), "EXPRTOKEN_PERIOD");
-            fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_PERIOD), "EXPRTOKEN_DOUBLE_PERIOD");
-            fTokenNames.put(new Integer(EXPRTOKEN_ATSIGN), "EXPRTOKEN_ATSIGN");
-            fTokenNames.put(new Integer(EXPRTOKEN_COMMA), "EXPRTOKEN_COMMA");
-            fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_COLON), "EXPRTOKEN_DOUBLE_COLON");
-            fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_ANY), "EXPRTOKEN_NAMETEST_ANY");
-            fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_NAMESPACE), "EXPRTOKEN_NAMETEST_NAMESPACE");
-            fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_QNAME), "EXPRTOKEN_NAMETEST_QNAME");
-            fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_COMMENT), "EXPRTOKEN_NODETYPE_COMMENT");
-            fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_TEXT), "EXPRTOKEN_NODETYPE_TEXT");
-            fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_PI), "EXPRTOKEN_NODETYPE_PI");
-            fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_NODE), "EXPRTOKEN_NODETYPE_NODE");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_AND), "EXPRTOKEN_OPERATOR_AND");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_OR), "EXPRTOKEN_OPERATOR_OR");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MOD), "EXPRTOKEN_OPERATOR_MOD");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DIV), "EXPRTOKEN_OPERATOR_DIV");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MULT), "EXPRTOKEN_OPERATOR_MULT");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_SLASH), "EXPRTOKEN_OPERATOR_SLASH");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DOUBLE_SLASH), "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_UNION), "EXPRTOKEN_OPERATOR_UNION");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_PLUS), "EXPRTOKEN_OPERATOR_PLUS");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MINUS), "EXPRTOKEN_OPERATOR_MINUS");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_EQUAL), "EXPRTOKEN_OPERATOR_EQUAL");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_NOT_EQUAL), "EXPRTOKEN_OPERATOR_NOT_EQUAL");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS), "EXPRTOKEN_OPERATOR_LESS");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS_EQUAL), "EXPRTOKEN_OPERATOR_LESS_EQUAL");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER), "EXPRTOKEN_OPERATOR_GREATER");
-            fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER_EQUAL), "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
-            fTokenNames.put(new Integer(EXPRTOKEN_FUNCTION_NAME), "EXPRTOKEN_FUNCTION_NAME");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR), "EXPRTOKEN_AXISNAME_ANCESTOR");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF), "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ATTRIBUTE), "EXPRTOKEN_AXISNAME_ATTRIBUTE");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_CHILD), "EXPRTOKEN_AXISNAME_CHILD");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT), "EXPRTOKEN_AXISNAME_DESCENDANT");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF), "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING), "EXPRTOKEN_AXISNAME_FOLLOWING");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING), "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_NAMESPACE), "EXPRTOKEN_AXISNAME_NAMESPACE");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PARENT), "EXPRTOKEN_AXISNAME_PARENT");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING), "EXPRTOKEN_AXISNAME_PRECEDING");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING), "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
-            fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_SELF), "EXPRTOKEN_AXISNAME_SELF");
-            fTokenNames.put(new Integer(EXPRTOKEN_LITERAL), "EXPRTOKEN_LITERAL");
-            fTokenNames.put(new Integer(EXPRTOKEN_NUMBER), "EXPRTOKEN_NUMBER");
-            fTokenNames.put(new Integer(EXPRTOKEN_VARIABLE_REFERENCE), "EXPRTOKEN_VARIABLE_REFERENCE");
+            fTokenNames.put(EXPRTOKEN_OPEN_PAREN, "EXPRTOKEN_OPEN_PAREN");
+            fTokenNames.put(EXPRTOKEN_CLOSE_PAREN, "EXPRTOKEN_CLOSE_PAREN");
+            fTokenNames.put(EXPRTOKEN_OPEN_BRACKET, "EXPRTOKEN_OPEN_BRACKET");
+            fTokenNames.put(EXPRTOKEN_CLOSE_BRACKET, "EXPRTOKEN_CLOSE_BRACKET");
+            fTokenNames.put(EXPRTOKEN_PERIOD, "EXPRTOKEN_PERIOD");
+            fTokenNames.put(EXPRTOKEN_DOUBLE_PERIOD, "EXPRTOKEN_DOUBLE_PERIOD");
+            fTokenNames.put(EXPRTOKEN_ATSIGN, "EXPRTOKEN_ATSIGN");
+            fTokenNames.put(EXPRTOKEN_COMMA, "EXPRTOKEN_COMMA");
+            fTokenNames.put(EXPRTOKEN_DOUBLE_COLON, "EXPRTOKEN_DOUBLE_COLON");
+            fTokenNames.put(EXPRTOKEN_NAMETEST_ANY, "EXPRTOKEN_NAMETEST_ANY");
+            fTokenNames.put(EXPRTOKEN_NAMETEST_NAMESPACE, "EXPRTOKEN_NAMETEST_NAMESPACE");
+            fTokenNames.put(EXPRTOKEN_NAMETEST_QNAME, "EXPRTOKEN_NAMETEST_QNAME");
+            fTokenNames.put(EXPRTOKEN_NODETYPE_COMMENT, "EXPRTOKEN_NODETYPE_COMMENT");
+            fTokenNames.put(EXPRTOKEN_NODETYPE_TEXT, "EXPRTOKEN_NODETYPE_TEXT");
+            fTokenNames.put(EXPRTOKEN_NODETYPE_PI, "EXPRTOKEN_NODETYPE_PI");
+            fTokenNames.put(EXPRTOKEN_NODETYPE_NODE, "EXPRTOKEN_NODETYPE_NODE");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_AND, "EXPRTOKEN_OPERATOR_AND");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_OR, "EXPRTOKEN_OPERATOR_OR");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_MOD, "EXPRTOKEN_OPERATOR_MOD");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_DIV, "EXPRTOKEN_OPERATOR_DIV");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_MULT, "EXPRTOKEN_OPERATOR_MULT");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_SLASH, "EXPRTOKEN_OPERATOR_SLASH");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_DOUBLE_SLASH, "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_UNION, "EXPRTOKEN_OPERATOR_UNION");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_PLUS, "EXPRTOKEN_OPERATOR_PLUS");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_MINUS, "EXPRTOKEN_OPERATOR_MINUS");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_EQUAL, "EXPRTOKEN_OPERATOR_EQUAL");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_NOT_EQUAL, "EXPRTOKEN_OPERATOR_NOT_EQUAL");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_LESS, "EXPRTOKEN_OPERATOR_LESS");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_LESS_EQUAL, "EXPRTOKEN_OPERATOR_LESS_EQUAL");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER, "EXPRTOKEN_OPERATOR_GREATER");
+            fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER_EQUAL, "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
+            fTokenNames.put(EXPRTOKEN_FUNCTION_NAME, "EXPRTOKEN_FUNCTION_NAME");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR, "EXPRTOKEN_AXISNAME_ANCESTOR");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF, "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_ATTRIBUTE, "EXPRTOKEN_AXISNAME_ATTRIBUTE");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_CHILD, "EXPRTOKEN_AXISNAME_CHILD");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT, "EXPRTOKEN_AXISNAME_DESCENDANT");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF, "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING, "EXPRTOKEN_AXISNAME_FOLLOWING");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING, "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_NAMESPACE, "EXPRTOKEN_AXISNAME_NAMESPACE");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_PARENT, "EXPRTOKEN_AXISNAME_PARENT");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING, "EXPRTOKEN_AXISNAME_PRECEDING");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING, "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
+            fTokenNames.put(EXPRTOKEN_AXISNAME_SELF, "EXPRTOKEN_AXISNAME_SELF");
+            fTokenNames.put(EXPRTOKEN_LITERAL, "EXPRTOKEN_LITERAL");
+            fTokenNames.put(EXPRTOKEN_NUMBER, "EXPRTOKEN_NUMBER");
+            fTokenNames.put(EXPRTOKEN_VARIABLE_REFERENCE, "EXPRTOKEN_VARIABLE_REFERENCE");
         }
 
         //
@@ -946,16 +947,21 @@
 //        }
 //
         public String getTokenString(int token) {
-            return (String)fTokenNames.get(new Integer(token));
+            return fTokenNames.get(token);
         }
 
         public void addToken(String tokenStr) {
-            Integer tokenInt = (Integer)fTokenNames.get(tokenStr);
+            Integer tokenInt = null;
+            for (Map.Entry<Integer, String> entry : fTokenNames.entrySet()) {
+                if (entry.getValue().equals(tokenStr)) {
+                    tokenInt = entry.getKey();
+                }
+            }
             if (tokenInt == null) {
-                tokenInt = new Integer(fTokenNames.size());
+                tokenInt = fTokenNames.size();
                 fTokenNames.put(tokenInt, tokenStr);
             }
-            addToken(tokenInt.intValue());
+            addToken(tokenInt);
         }
 
         public void addToken(int token) {
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,8 +20,9 @@
 
 package com.sun.org.apache.xerces.internal.impl.xpath.regex;
 
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 /**
  * A regular expression parser for the XML Schema.
@@ -369,12 +370,12 @@
         return c;
     }
 
-    static private Hashtable ranges = null;
-    static private Hashtable ranges2 = null;
+    static private Map<String, Token> ranges = null;
+    static private Map<String, Token> ranges2 = null;
     static synchronized protected RangeToken getRange(String name, boolean positive) {
         if (ranges == null) {
-            ranges = new Hashtable();
-            ranges2 = new Hashtable();
+            ranges = new HashMap<>();
+            ranges2 = new HashMap<>();
 
             Token tok = Token.createRange();
             setupRange(tok, SPACES);
@@ -390,7 +391,7 @@
             tok = Token.createRange();
             setupRange(tok, LETTERS);
             setupRange(tok, LETTERS_INT);
-            tok.mergeRanges((Token)ranges.get("xml:isDigit"));
+            tok.mergeRanges(ranges.get("xml:isDigit"));
             ranges.put("xml:isWord", tok);
             ranges2.put("xml:isWord", Token.complementRanges(tok));
 
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,8 +20,18 @@
 
 package com.sun.org.apache.xerces.internal.impl.xpath.regex;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.Vector;
-import java.util.Hashtable;
 
 /**
  * This class represents a node in parse tree.
@@ -583,8 +593,8 @@
     }
 
     // ------------------------------------------------------
-    private final static Hashtable categories = new Hashtable();
-    private final static Hashtable categories2 = new Hashtable();
+    private final static Map<String, Token> categories = new HashMap<>();
+    private final static Map<String, Token> categories2 = new HashMap<>();
     private static final String[] categoryNames = {
         "Cn", "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Me", "Mc", "Nd",
         "Nl", "No", "Zs", "Zl", "Zp", "Cc", "Cf", null, "Co", "Cs",
@@ -820,7 +830,7 @@
                 //REVISIT: do we really need to support block names as in Unicode 3.1
                 //         or we can just create all the names in IsBLOCKNAME format (XML Schema REC)?
                 //
-                StringBuffer buffer = new StringBuffer(50);
+                StringBuilder buffer = new StringBuilder(50);
                 for (int i = 0;  i < Token.blockNames.length;  i ++) {
                     Token r1 = Token.createRange();
                     int location;
@@ -972,22 +982,17 @@
         return range;
     }
 
-    static Hashtable nonxs = null;
+    static final Set<String> nonxs = Collections.synchronizedSet(new HashSet<String>());
     /**
      * This method is called by only getRange().
      * So this method need not MT-safe.
      */
     static protected void registerNonXS(String name) {
-        if (Token.nonxs == null)
-            Token.nonxs = new Hashtable();
-        Token.nonxs.put(name, name);
+        Token.nonxs.add(name);
     }
+
     static protected boolean isRegisterNonXS(String name) {
-        if (Token.nonxs == null)
-            return false;
-        //DEBUG
-        //System.err.println("isRegisterNonXS: "+name);
-        return Token.nonxs.containsKey(name);
+        return Token.nonxs.contains(name);
     }
 
     private static void setAlias(String newName, String name, boolean positive) {
@@ -1423,17 +1428,26 @@
 
         private static final long serialVersionUID = -2568843945989489861L;
 
-        Vector children;
+        List<Token> children;
+
+        /**
+         * @serialField children Vector children
+         */
+        private static final ObjectStreamField[] serialPersistentFields =
+            new ObjectStreamField[] {
+                new ObjectStreamField("children", Vector.class),
+            };
 
         UnionToken(int type) {
             super(type);
         }
 
+        @Override
         void addChild(Token tok) {
             if (tok == null)  return;
-            if (this.children == null)  this.children = new Vector();
+            if (this.children == null)  this.children = new ArrayList<>();
             if (this.type == UNION) {
-                this.children.addElement(tok);
+                this.children.add(tok);
                 return;
             }
                                                 // This is CONCAT, and new child is CONCAT.
@@ -1444,31 +1458,31 @@
             }
             int size = this.children.size();
             if (size == 0) {
-                this.children.addElement(tok);
+                this.children.add(tok);
                 return;
             }
-            Token previous = (Token)this.children.elementAt(size-1);
+            Token previous = this.children.get(size - 1);
             if (!((previous.type == CHAR || previous.type == STRING)
                   && (tok.type == CHAR || tok.type == STRING))) {
-                this.children.addElement(tok);
+                this.children.add(tok);
                 return;
             }
 
             //System.err.println("Merge '"+previous+"' and '"+tok+"'.");
 
-            StringBuffer buffer;
+            StringBuilder buffer;
             int nextMaxLength = (tok.type == CHAR ? 2 : tok.getString().length());
             if (previous.type == CHAR) {        // Replace previous token by STRING
-                buffer = new StringBuffer(2 + nextMaxLength);
+                buffer = new StringBuilder(2 + nextMaxLength);
                 int ch = previous.getChar();
                 if (ch >= 0x10000)
                     buffer.append(REUtil.decomposeToSurrogates(ch));
                 else
                     buffer.append((char)ch);
                 previous = Token.createString(null);
-                this.children.setElementAt(previous, size-1);
+                this.children.set(size - 1, previous);
             } else {                            // STRING
-                buffer = new StringBuffer(previous.getString().length() + nextMaxLength);
+                buffer = new StringBuilder(previous.getString().length() + nextMaxLength);
                 buffer.append(previous.getString());
             }
 
@@ -1485,13 +1499,16 @@
             ((StringToken)previous).string = new String(buffer);
         }
 
+        @Override
         int size() {
             return this.children == null ? 0 : this.children.size();
         }
+        @Override
         Token getChild(int index) {
-            return (Token)this.children.elementAt(index);
+            return this.children.get(index);
         }
 
+        @Override
         public String toString(int options) {
             String ret;
             if (this.type == CONCAT) {
@@ -1505,9 +1522,9 @@
                     } else
                         ret = ch.toString(options)+ch2.toString(options);
                 } else {
-                    StringBuffer sb = new StringBuffer();
+                    StringBuilder sb = new StringBuilder();
                     for (int i = 0;  i < this.children.size();  i ++) {
-                        sb.append(((Token)this.children.elementAt(i)).toString(options));
+                        sb.append(((Token)this.children.get(i)).toString(options));
                     }
                     ret = new String(sb);
                 }
@@ -1519,15 +1536,39 @@
                        && this.getChild(0).type == EMPTY) {
                 ret = this.getChild(1).toString(options)+"??";
             } else {
-                StringBuffer sb = new StringBuffer();
-                sb.append(((Token)this.children.elementAt(0)).toString(options));
+                StringBuilder sb = new StringBuilder();
+                sb.append((this.children.get(0)).toString(options));
                 for (int i = 1;  i < this.children.size();  i ++) {
                     sb.append((char)'|');
-                    sb.append(((Token)this.children.elementAt(i)).toString(options));
+                    sb.append((this.children.get(i)).toString(options));
                 }
                 ret = new String(sb);
             }
             return ret;
         }
+
+        /**
+         * @serialData Serialized fields. Convert the List to Vector for backward compatibility.
+         */
+        private void writeObject(ObjectOutputStream out) throws IOException {
+            // Convert List to Vector
+            Vector<Token> vChildren = (children == null)? null : new Vector<>(children);
+
+            // Write serialized fields
+            ObjectOutputStream.PutField pf = out.putFields();
+            pf.put("children", vChildren);
+            out.writeFields();
+        }
+
+        @SuppressWarnings("unchecked")
+        private void readObject(ObjectInputStream in)
+                            throws IOException, ClassNotFoundException {
+            // We have to read serialized fields first.
+            ObjectInputStream.GetField gf = in.readFields();
+            Vector<Token> vChildren = (Vector<Token>)gf.get("children", null);
+
+            //convert Vector back to List
+            if (vChildren != null) children = new ArrayList<>(vChildren);
+        }
     }
 }
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -20,12 +19,13 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs;
 
+import com.sun.org.apache.xerces.internal.xni.QName;
 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.XSSimpleTypeDefinition;
 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import com.sun.org.apache.xerces.internal.xni.QName;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Vector;
 
 /**
@@ -172,14 +172,14 @@
     }
 
     // to store substitution group information
-    // the key to the hashtable is an element decl, and the value is
+    // the key to the map is an element decl, and the value is
     // - a Vector, which contains all elements that has this element as their
     //   substitution group affilication
     // - an array of OneSubGroup, which contains its substitution group before block.
-    Hashtable fSubGroupsB = new Hashtable();
+    Map<XSElementDecl, Object> fSubGroupsB = new HashMap<>();
     private static final OneSubGroup[] EMPTY_VECTOR = new OneSubGroup[0];
     // The real substitution groups (after "block")
-    Hashtable fSubGroups = new Hashtable();
+    Map<XSElementDecl, XSElementDecl[]> fSubGroups = new HashMap<>();
 
     /**
      * clear the internal registry of substitutionGroup information
@@ -221,9 +221,9 @@
      */
     public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
         // If we already have sub group for this element, just return it.
-        Object subGroup = fSubGroups.get(element);
+        XSElementDecl[] subGroup = fSubGroups.get(element);
         if (subGroup != null)
-            return (XSElementDecl[])subGroup;
+            return subGroup;
 
         if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
             fSubGroups.put(element, EMPTY_GROUP);
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,26 +20,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
 import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
 import com.sun.org.apache.xerces.internal.dom.DOMStringListImpl;
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
-import com.sun.org.apache.xerces.internal.impl.dv.DVFactoryException;
 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
 import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
 import com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl;
@@ -72,14 +58,25 @@
 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.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
 import javax.xml.XMLConstants;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
+import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMStringList;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.ls.LSInput;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
@@ -596,9 +593,8 @@
      * @throws IOException
      * @throws XNIException
      */
-    SchemaGrammar loadSchema(XSDDescription desc,
-            XMLInputSource source,
-            Map locationPairs) throws IOException, XNIException {
+    SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
+            Map<String, LocationArray> locationPairs) throws IOException, XNIException {
 
         // this should only be done once per invocation of this object;
         // unless application alters JAXPSource in the mean time.
@@ -620,9 +616,9 @@
     } // loadSchema(XSDDescription, XMLInputSource):  SchemaGrammar
 
     /** This method tries to resolve location of the given schema.
-     * The loader stores the namespace/location pairs in a hashtable (use "" as the
+     * The loader stores the namespace/location pairs in a map (use "" as the
      * namespace of absent namespace). When resolving an entity, loader first tries
-     * to find in the hashtable whether there is a value for that namespace,
+     * to find in the map whether there is a value for that namespace,
      * if so, pass that location value to the user-defined entity resolver.
      *
      * @param desc
@@ -631,7 +627,8 @@
      * @return
      * @throws IOException
      */
-    public static XMLInputSource resolveDocument(XSDDescription desc, Map locationPairs,
+    public static XMLInputSource resolveDocument(XSDDescription desc,
+            Map<String, LocationArray> locationPairs,
             XMLEntityResolver entityResolver) throws IOException {
         String loc = null;
         // we consider the schema location properties for import
@@ -641,7 +638,7 @@
             String namespace = desc.getTargetNamespace();
             String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
             // get the location hint for that namespace
-            LocationArray tempLA = (LocationArray)locationPairs.get(ns);
+            LocationArray tempLA = locationPairs.get(ns);
             if(tempLA != null)
                 loc = tempLA.getFirstLocation();
         }
@@ -662,7 +659,7 @@
 
     // add external schema locations to the location pairs
     public static void processExternalHints(String sl, String nsl,
-            Map locations,
+            Map<String, XMLSchemaLoader.LocationArray> locations,
             XMLErrorReporter er) {
         if (sl != null) {
             try {
@@ -715,7 +712,8 @@
     // @param schemaStr     The schemaLocation string to tokenize
     // @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, Map locations) {
+    public static boolean tokenizeSchemaLocationStr(String schemaStr,
+            Map<String, XMLSchemaLoader.LocationArray> locations) {
         if (schemaStr!= null) {
             StringTokenizer t = new StringTokenizer(schemaStr, " \n\t\r");
             String namespace, location;
@@ -725,7 +723,7 @@
                     return false; // error!
                 }
                 location = t.nextToken();
-                LocationArray la = ((LocationArray)locations.get(namespace));
+                LocationArray la = locations.get(namespace);
                 if(la == null) {
                     la = new LocationArray();
                     locations.put(namespace, la);
@@ -746,7 +744,8 @@
      * Note: all JAXP schema files will be checked for full-schema validity if the feature was set up
      *
      */
-    private void processJAXPSchemaSource(Map locationPairs) throws IOException {
+    private void processJAXPSchemaSource(
+            Map<String, LocationArray> locationPairs) throws IOException {
         fJAXPProcessed = true;
         if (fJAXPSource == null) {
             return;
@@ -925,7 +924,7 @@
         return new XMLInputSource(publicId, systemId, null);
     }
 
-    static class LocationArray{
+    public static class LocationArray{
 
         int length ;
         String [] locations = new String[2];
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,16 +20,6 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.ArrayList;
-import javax.xml.XMLConstants;
 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.XMLEntityManager;
@@ -51,13 +41,14 @@
 import com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder;
 import com.sun.org.apache.xerces.internal.impl.xs.models.CMNodeFactory;
 import com.sun.org.apache.xerces.internal.impl.xs.models.XSCMValidator;
+import com.sun.org.apache.xerces.internal.parsers.XMLParser;
 import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
 import com.sun.org.apache.xerces.internal.util.IntStack;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.QName;
@@ -83,7 +74,13 @@
 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 com.sun.org.apache.xerces.internal.parsers.XMLParser;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+import java.util.Vector;
 
 /**
  * The XML Schema validator. The validator implements a document
@@ -308,9 +305,6 @@
     protected static final int ID_CONSTRAINT_NUM = 1;
 
     //
-    private static final Hashtable EMPTY_TABLE = new Hashtable();
-
-    //
     // Data
     //
 
@@ -495,7 +489,7 @@
 
     /** 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 Map<String, XMLSchemaLoader.LocationArray> fLocationPairs = new HashMap<>();
 
 
     // handlers
@@ -2358,8 +2352,7 @@
             }
         }
         if (nsLocation != null) {
-            XMLSchemaLoader.LocationArray la =
-                ((XMLSchemaLoader.LocationArray) fLocationPairs.get(XMLSymbols.EMPTY_STRING));
+            XMLSchemaLoader.LocationArray la = fLocationPairs.get(XMLSymbols.EMPTY_STRING);
             if (la == null) {
                 la = new XMLSchemaLoader.LocationArray();
                 fLocationPairs.put(XMLSymbols.EMPTY_STRING, la);
@@ -2414,11 +2407,11 @@
                 fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
             }
 
-            Hashtable locationPairs = fLocationPairs;
-            Object locationArray =
+            Map<String, XMLSchemaLoader.LocationArray> locationPairs = fLocationPairs;
+            XMLSchemaLoader.LocationArray locationArray =
                 locationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
             if (locationArray != null) {
-                String[] temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
+                String[] temp = locationArray.getLocationArray();
                 if (temp.length != 0) {
                     setLocationHints(fXSDDescription, temp, grammar);
                 }
@@ -2428,7 +2421,7 @@
                 boolean toParseSchema = true;
                 if (grammar != null) {
                      // use location hints instead
-                    locationPairs = EMPTY_TABLE;
+                    locationPairs = Collections.emptyMap();
                 }
 
                 // try to parse the grammar using location hints from that namespace..
@@ -3688,7 +3681,7 @@
 
         protected void checkDuplicateValues() {
             // no-op
-        } // duplicateValue(Hashtable)
+        } // duplicateValue(Map)
 
         /** Returns a string of the specified values. */
         protected String toString(Object[] values) {
@@ -3861,7 +3854,7 @@
                 String cName = fIdentityConstraint.getIdentityConstraintName();
                 reportSchemaError(code, new Object[] { value, eName, cName });
             }
-        } // duplicateValue(Hashtable)
+        } // duplicateValue(Map)
 
     } // class UniqueValueStore
 
@@ -3898,7 +3891,7 @@
                 String cName = fIdentityConstraint.getIdentityConstraintName();
                 reportSchemaError(code, new Object[] { value, eName, cName });
             }
-        } // duplicateValue(Hashtable)
+        } // duplicateValue(Map)
 
     } // class KeyValueStore
 
@@ -3990,14 +3983,15 @@
 
         /**
          * Values stores associated to specific identity constraints.
-         * This hashtable maps IdentityConstraints and
+         * This map maps IdentityConstraints and
          * the 0-based element on which their selectors first matched to
          * a corresponding ValueStore.  This should take care
          * of all cases, including where ID constraints with
          * descendant-or-self axes occur on recursively-defined
          * elements.
          */
-        protected final Hashtable fIdentityConstraint2ValueStoreMap = new Hashtable();
+        protected final Map<LocalIDKey, ValueStoreBase>
+                fIdentityConstraint2ValueStoreMap = new HashMap<>();
 
         // sketch of algorithm:
         // - when a constraint is first encountered, its
@@ -4010,7 +4004,7 @@
         // The fGlobalIDMapStack has the following structure:
         // - validation always occurs against the fGlobalIDConstraintMap
         // (which comprises all the "eligible" id constraints);
-        // When an endElement is found, this Hashtable is merged with the one
+        // When an endElement is found, this Map is merged with the one
         // below in the stack.
         // When a start tag is encountered, we create a new
         // fGlobalIDConstraintMap.
@@ -4018,8 +4012,10 @@
         // the preceding siblings' eligible id constraints;
         // the fGlobalIDConstraintMap contains descendants+self.
         // keyrefs can only match descendants+self.
-        protected final Stack fGlobalMapStack = new Stack();
-        protected final Hashtable fGlobalIDConstraintMap = new Hashtable();
+        protected final Stack<Map<IdentityConstraint, ValueStoreBase>>
+                fGlobalMapStack = new Stack<>();
+        protected final Map<IdentityConstraint, ValueStoreBase>
+                fGlobalIDConstraintMap = new HashMap<>();
 
         //
         // Constructors
@@ -4046,7 +4042,8 @@
         public void startElement() {
             // only clone the hashtable when there are elements
             if (fGlobalIDConstraintMap.size() > 0)
-                fGlobalMapStack.push(fGlobalIDConstraintMap.clone());
+                fGlobalMapStack.push((Map<IdentityConstraint, ValueStoreBase>)
+                        ((HashMap)fGlobalIDConstraintMap).clone());
             else
                 fGlobalMapStack.push(null);
             fGlobalIDConstraintMap.clear();
@@ -4059,19 +4056,17 @@
             if (fGlobalMapStack.isEmpty()) {
                 return; // must be an invalid doc!
             }
-            Hashtable oldMap = (Hashtable) fGlobalMapStack.pop();
+            Map<IdentityConstraint, ValueStoreBase> oldMap = fGlobalMapStack.pop();
             // return if there is no element
             if (oldMap == null) {
                 return;
             }
 
-            Iterator entries = oldMap.entrySet().iterator();
-            while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry) entries.next();
-                IdentityConstraint id = (IdentityConstraint) entry.getKey();
-                ValueStoreBase oldVal = (ValueStoreBase) entry.getValue();
+            for (Map.Entry<IdentityConstraint, ValueStoreBase> entry : oldMap.entrySet()) {
+                IdentityConstraint id = entry.getKey();
+                ValueStoreBase oldVal = entry.getValue();
                 if (oldVal != null) {
-                    ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
+                    ValueStoreBase currVal = fGlobalIDConstraintMap.get(id);
                     if (currVal == null) {
                         fGlobalIDConstraintMap.put(id, oldVal);
                     }
@@ -4145,26 +4140,25 @@
         public ValueStoreBase getValueStoreFor(IdentityConstraint id, int initialDepth) {
             fLocalId.fDepth = initialDepth;
             fLocalId.fId = id;
-            return (ValueStoreBase) fIdentityConstraint2ValueStoreMap.get(fLocalId);
+            return fIdentityConstraint2ValueStoreMap.get(fLocalId);
         } // getValueStoreFor(IdentityConstraint, int):ValueStoreBase
 
         /** Returns the global value store associated to the specified IdentityConstraint. */
         public ValueStoreBase getGlobalValueStoreFor(IdentityConstraint id) {
-            return (ValueStoreBase) fGlobalIDConstraintMap.get(id);
+            return fGlobalIDConstraintMap.get(id);
         } // getValueStoreFor(IdentityConstraint):ValueStoreBase
 
         // This method takes the contents of the (local) ValueStore
         // associated with id and moves them into the global
-        // hashtable, if id is a <unique> or a <key>.
+        // map, if id is a <unique> or a <key>.
         // If it's a <keyRef>, then we leave it for later.
         public void transplant(IdentityConstraint id, int initialDepth) {
             fLocalId.fDepth = initialDepth;
             fLocalId.fId = id;
-            ValueStoreBase newVals =
-                (ValueStoreBase) fIdentityConstraint2ValueStoreMap.get(fLocalId);
+            ValueStoreBase newVals = fIdentityConstraint2ValueStoreMap.get(fLocalId);
             if (id.getCategory() == IdentityConstraint.IC_KEYREF)
                 return;
-            ValueStoreBase currVals = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
+            ValueStoreBase currVals = fGlobalIDConstraintMap.get(id);
             if (currVals != null) {
                 currVals.append(newVals);
                 fGlobalIDConstraintMap.put(id, currVals);
@@ -4205,7 +4199,7 @@
     } // class ValueStoreCache
 
     // the purpose of this class is to enable IdentityConstraint,int
-    // pairs to be used easily as keys in Hashtables.
+    // pairs to be used easily as keys in Maps.
     protected class LocalIDKey {
 
         public IdentityConstraint fId;
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,7 +20,6 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs;
 
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Vector;
@@ -38,7 +37,7 @@
     // Data
 
     /**
-     * Hashtable that maps between Namespace and a Grammar
+     * Map that maps between Namespace and a Grammar
      */
     Map<String, SchemaGrammar> fGrammarRegistry = new HashMap();
     SchemaGrammar fNoNSGrammar = null;
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java	Wed Sep 07 06:06:32 2016 +0100
@@ -115,7 +115,7 @@
                 System.out.println("nodeCount = " + nodeCount ) ;
                 System.out.println("nodeLimit = " + maxNodeLimit ) ;
             }
-            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "maxOccurLimit", new Object[]{ new Integer(maxNodeLimit) }, XMLErrorReporter.SEVERITY_FATAL_ERROR);
+            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "MaxOccurLimit", new Object[]{ new Integer(maxNodeLimit) }, XMLErrorReporter.SEVERITY_FATAL_ERROR);
             // similarly to entity manager behaviour, take into accont
             // behaviour if continue-after-fatal-error is set.
             nodeCount = 0;
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,12 +20,6 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
 
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
@@ -44,6 +38,10 @@
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xs.XSConstants;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
@@ -64,7 +62,7 @@
  * - Whether to return non-schema attributes/values
  * - Do we need to update NamespaceScope and ErrorReporter when reset()?
  * - Should have the datatype validators return compiled value
- * - use symbol table instead of many hashtables
+ * - use symbol table instead of many maps
  *
  * @xerces.internal
  *
@@ -1026,9 +1024,7 @@
             return null;
         }
 
-        //Hashtable attrValues = new Hashtable();
         Object[] attrValues = getAvailableArray();
-        //Hashtable otherValues = new Hashtable();
         long fromDefault = 0;
 
         // clear the "seen" flag.
@@ -1197,7 +1193,7 @@
                     // maxOccurNodeLimit.
                     int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
                     if (max > maxOccurNodeLimit && !fSchemaHandler.fSecureProcessing.isNoLimit(maxOccurNodeLimit)) {
-                        reportSchemaFatalError("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);
--- a/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,21 +20,6 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
 
-import java.io.IOException;
-import java.io.StringReader;
-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;
-
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
@@ -74,8 +59,8 @@
 import com.sun.org.apache.xerces.internal.util.StAXLocationWrapper;
 import com.sun.org.apache.xerces.internal.util.SymbolHash;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
@@ -107,7 +92,19 @@
 import com.sun.org.apache.xerces.internal.xs.XSTerm;
 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
 import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Stack;
+import java.util.Vector;
 import javax.xml.XMLConstants;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -277,9 +274,9 @@
     private Map<String, Element> fUnparsedIdentityConstraintRegistry =  new HashMap();
     private Map<String, Element> fUnparsedNotationRegistry =  new HashMap();
     private Map<String, Element> fUnparsedTypeRegistry =  new HashMap();
-    // Compensation for the above hashtables to locate XSDocumentInfo,
+    // Compensation for the above maps to locate XSDocumentInfo,
     // Since we may take Schema Element directly, so can not get the
-    // corresponding XSDocumentInfo object just using above hashtables.
+    // corresponding XSDocumentInfo object just using above maps.
     private Map<String, XSDocumentInfo> fUnparsedAttributeRegistrySub =  new HashMap();
     private Map<String, XSDocumentInfo> fUnparsedAttributeGroupRegistrySub =  new HashMap();
     private Map<String, XSDocumentInfo> fUnparsedElementRegistrySub =  new HashMap();
@@ -301,26 +298,25 @@
         null, // TYPEDECL_TYPE
     };
 
-    // this hashtable is keyed on by XSDocumentInfo objects.  Its values
+    // this map is keyed on by XSDocumentInfo objects.  Its values
     // are Vectors containing the XSDocumentInfo objects <include>d,
     // <import>ed or <redefine>d by the key XSDocumentInfo.
     private Map<XSDocumentInfo, Vector> fDependencyMap = new HashMap();
 
-    // this hashtable is keyed on by a target namespace.  Its values
+    // this map 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 Map<String, Vector> 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.)
+    // (because the key of a map can't be null.)
     private Vector fAllTNSs = new Vector();
     // stores instance document mappings between namespaces and schema hints
-    private Map fLocationPairs = null;
-    private static final Map EMPTY_TABLE = new HashMap();
+    private Map<String, XMLSchemaLoader.LocationArray> fLocationPairs = null;
 
     // Records which nodes are hidden when the input is a DOMInputSource.
-    Hashtable fHiddenNodes = null;
+    Map<Node, String> fHiddenNodes = null;
 
     // convenience methods
     private String null2EmptyString(String ns) {
@@ -348,14 +344,14 @@
     // schema document that is included in multiple other schemas.
     private Map fTraversed = new HashMap();
 
-    // this hashtable contains a mapping from Schema Element to its systemId
+    // this map contains a mapping from Schema Element to its systemId
     // this is useful to resolve a uri relative to the referring document
     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
+    // This map's job is to act as a link between the Schema Element and its
     // XSDocumentInfo object.
     private Map fDoc2XSDocumentMap = new HashMap();
 
@@ -461,17 +457,17 @@
     private String [][] fKeyrefNamespaceContext = new String[INIT_KEYREF_STACK][1];
 
     // global decls: map from decl name to decl object
-    SymbolHash fGlobalAttrDecls = new SymbolHash();
-    SymbolHash fGlobalAttrGrpDecls = new SymbolHash();
-    SymbolHash fGlobalElemDecls = new SymbolHash();
-    SymbolHash fGlobalGroupDecls = new SymbolHash();
-    SymbolHash fGlobalNotationDecls = new SymbolHash();
-    SymbolHash fGlobalIDConstraintDecls = new SymbolHash();
-    SymbolHash fGlobalTypeDecls = new SymbolHash();
+    SymbolHash fGlobalAttrDecls = new SymbolHash(12);
+    SymbolHash fGlobalAttrGrpDecls = new SymbolHash(5);
+    SymbolHash fGlobalElemDecls = new SymbolHash(25);
+    SymbolHash fGlobalGroupDecls = new SymbolHash(5);
+    SymbolHash fGlobalNotationDecls = new SymbolHash(1);
+    SymbolHash fGlobalIDConstraintDecls = new SymbolHash(3);
+    SymbolHash fGlobalTypeDecls = new SymbolHash(25);
 
     // Constructors
     public XSDHandler(){
-        fHiddenNodes = new Hashtable();
+        fHiddenNodes = new HashMap<>();
         fSchemaParser = new SchemaDOMParser(new SchemaParsingConfig());
     }
 
@@ -500,7 +496,7 @@
      * @throws IOException
      */
     public SchemaGrammar parseSchema(XMLInputSource is, XSDDescription desc,
-            Map locationPairs)
+            Map<String, XMLSchemaLoader.LocationArray> locationPairs)
     throws IOException {
         fLocationPairs = locationPairs;
         fSchemaParser.resetNodePool();
@@ -1002,7 +998,7 @@
 
                 // If "findGrammar" returns a grammar, then this is not the
                 // the first time we see a location for a given namespace.
-                // Don't consult the location pair hashtable in this case,
+                // Don't consult the location pair map in this case,
                 // otherwise the location will be ignored because it'll get
                 // resolved to the same location as the first hint.
                 newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child, isg == null);
@@ -2048,7 +2044,7 @@
                                   Element referElement, boolean usePairs) {
         XMLInputSource schemaSource = null;
         try {
-            Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
+            Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.<String, XMLSchemaLoader.LocationArray>emptyMap();
             schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
         }
         catch (IOException ex) {
@@ -2101,7 +2097,7 @@
 
         XMLInputSource schemaSource = null;
         try {
-            Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
+            Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.<String, XMLSchemaLoader.LocationArray>emptyMap();
             schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
         }
         catch (IOException ex) {
@@ -3791,7 +3787,7 @@
             fUnparsedRegistriesExt[declType].put(qName, currSchema);
         }
 
-    } // checkForDuplicateNames(String, Hashtable, Element, XSDocumentInfo):void
+    } // checkForDuplicateNames(String, Map, Element, XSDocumentInfo):void
 
     void checkForDuplicateNames(String qName, int declType, Element currComp) {
         int namespaceEnd = qName.indexOf(',');
@@ -3962,7 +3958,7 @@
     // this method takes a name of the form a:b, determines the URI mapped
     // to by a in the current SchemaNamespaceSupport object, and returns this
     // information in the form (nsURI,b) suitable for lookups in the global
-    // decl Hashtables.
+    // decl maps.
     // REVISIT: should have it return QName, instead of String. this would
     //          save lots of string concatenation time. we can use
     //          QName#equals() to compare two QNames, and use QName directly
--- a/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,16 +20,15 @@
 
 package com.sun.org.apache.xerces.internal.jaxp;
 
-import java.util.Hashtable;
-
+import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+import java.util.HashMap;
+import java.util.Map;
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.validation.Schema;
-
-import com.sun.org.apache.xerces.internal.parsers.DOMParser;
-import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
@@ -41,8 +40,8 @@
  */
 public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
     /** These are DocumentBuilderFactory attributes not DOM attributes */
-    private Hashtable attributes;
-    private Hashtable features;
+    private Map<String, Object> attributes;
+    private Map<String, Boolean> features;
     private Schema grammar;
     private boolean isXIncludeAware;
 
@@ -101,9 +100,9 @@
         // This is ugly.  We have to collect the attributes and then
         // later create a DocumentBuilderImpl to verify the attributes.
 
-        // Create Hashtable if none existed before
+        // Create the Map if none existed before
         if (attributes == null) {
-            attributes = new Hashtable();
+            attributes = new HashMap<>();
         }
 
         attributes.put(name, value);
@@ -124,7 +123,7 @@
     public Object getAttribute(String name)
         throws IllegalArgumentException
     {
-        // See if it's in the attributes Hashtable
+        // See if it's in the attributes Map
         if (attributes != null) {
             Object val = attributes.get(name);
             if (val != null) {
@@ -135,7 +134,7 @@
         DOMParser domParser = null;
         try {
             // We create a dummy DocumentBuilderImpl in case the attribute
-            // name is not one that is in the attributes hashtable.
+            // name is not one that is in the attributes map.
             domParser =
                 new DocumentBuilderImpl(this, attributes, features).getDOMParser();
             return domParser.getProperty(name);
@@ -173,11 +172,11 @@
         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
             return fSecureProcess;
         }
-        // See if it's in the features Hashtable
+        // See if it's in the features map
         if (features != null) {
-            Object val = features.get(name);
+            Boolean val = features.get(name);
             if (val != null) {
-                return ((Boolean) val).booleanValue();
+                return val;
             }
         }
         try {
@@ -192,7 +191,7 @@
     public void setFeature(String name, boolean value)
         throws ParserConfigurationException {
         if (features == null) {
-            features = new Hashtable();
+            features = new HashMap<>();
         }
         // If this is the secure processing feature, save it then return.
         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
--- a/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,15 +20,6 @@
 
 package com.sun.org.apache.xerces.internal.jaxp;
 
-import java.io.IOException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.validation.Schema;
-import javax.xml.XMLConstants;
-
 import com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl;
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
 import com.sun.org.apache.xerces.internal.impl.Constants;
@@ -46,6 +37,11 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+import java.io.IOException;
+import java.util.Map;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.validation.Schema;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.xml.sax.EntityResolver;
@@ -126,12 +122,14 @@
     private XMLSecurityManager fSecurityManager;
     private XMLSecurityPropertyManager fSecurityPropertyMgr;
 
-    DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Hashtable dbfAttrs, Hashtable features)
+    DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Map<String, Object> dbfAttrs,
+            Map<String, Boolean> features)
         throws SAXNotRecognizedException, SAXNotSupportedException {
         this(dbf, dbfAttrs, features, false);
     }
 
-    DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Hashtable dbfAttrs, Hashtable features, boolean secureProcessing)
+    DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Map<String, Object> dbfAttrs,
+            Map<String, Boolean> features, boolean secureProcessing)
         throws SAXNotRecognizedException, SAXNotSupportedException
     {
         domParser = new DOMParser();
@@ -182,10 +180,9 @@
              * System Properties or jaxp.properties are set
              */
             if (features != null) {
-                Object temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
+                Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
                 if (temp != null) {
-                    boolean value = ((Boolean) temp).booleanValue();
-                    if (value && Constants.IS_JDK8_OR_ABOVE) {
+                    if (temp && Constants.IS_JDK8_OR_ABOVE) {
                         fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
                                 State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
                         fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_SCHEMA,
@@ -240,15 +237,11 @@
         fInitEntityResolver = domParser.getEntityResolver();
     }
 
-    private void setFeatures(Hashtable features)
+    private void setFeatures( Map<String, Boolean> features)
         throws SAXNotSupportedException, SAXNotRecognizedException {
         if (features != null) {
-            Iterator entries = features.entrySet().iterator();
-            while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry) entries.next();
-                String feature = (String) entry.getKey();
-                boolean value = ((Boolean) entry.getValue()).booleanValue();
-                domParser.setFeature(feature, value);
+            for (Map.Entry<String, Boolean> entry : features.entrySet()) {
+                domParser.setFeature(entry.getKey(), entry.getValue());
         }
     }
     }
@@ -260,7 +253,7 @@
      * attribute names and JAXP specific attribute names,
      * eg. DocumentBuilderFactory.setValidating()
      */
-    private void setDocumentBuilderFactoryAttributes(Hashtable dbfAttrs)
+    private void setDocumentBuilderFactoryAttributes( Map<String, Object> dbfAttrs)
         throws SAXNotSupportedException, SAXNotRecognizedException
     {
         if (dbfAttrs == null) {
@@ -268,14 +261,12 @@
             return;
         }
 
-        Iterator entries = dbfAttrs.entrySet().iterator();
-        while (entries.hasNext()) {
-            Map.Entry entry = (Map.Entry) entries.next();
-            String name = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : dbfAttrs.entrySet()) {
+            String name = entry.getKey();
             Object val = entry.getValue();
             if (val instanceof Boolean) {
                 // Assume feature
-                domParser.setFeature(name, ((Boolean)val).booleanValue());
+                domParser.setFeature(name, (Boolean)val);
             } else {
                 // Assume property
                 if (JAXP_SCHEMA_LANGUAGE.equals(name)) {
--- a/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,21 +20,19 @@
 
 package com.sun.org.apache.xerces.internal.jaxp;
 
-import java.util.Hashtable;
-
+import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+import java.util.HashMap;
+import java.util.Map;
 import javax.xml.XMLConstants;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.validation.Schema;
-
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
 
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
-
 /**
  * This is the implementation specific class for the
  * <code>javax.xml.parsers.SAXParserFactory</code>. This is the platform
@@ -59,7 +57,7 @@
     private static final String XINCLUDE_FEATURE =
         Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FEATURE;
 
-    private Hashtable features;
+    private Map<String, Boolean> features;
     private Schema grammar;
     private boolean isXIncludeAware;
 
@@ -188,7 +186,7 @@
 
     private void putInFeatures(String name, boolean value){
          if (features == null) {
-            features = new Hashtable();
+            features = new HashMap<>();
         }
         features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
     }
@@ -198,8 +196,8 @@
             return false;
          }
          else {
-             Object value = features.get(name);
-             return (value == null) ? false : Boolean.valueOf(value.toString()).booleanValue();
+             Boolean value = features.get(name);
+             return (value == null) ? false : value;
          }
     }
 
--- a/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -39,7 +39,6 @@
 import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
@@ -116,18 +115,18 @@
 
     /**
      * Create a SAX parser with the associated features
-     * @param features Hashtable of SAX features, may be null
+     * @param features Map of SAX features, may be null
      */
-    SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features)
+    SAXParserImpl(SAXParserFactoryImpl spf, Map<String, Boolean> features)
         throws SAXException {
         this(spf, features, false);
     }
 
     /**
      * Create a SAX parser with the associated features
-     * @param features Hashtable of SAX features, may be null
+     * @param features Map of SAX features, may be null
      */
-    SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing)
+    SAXParserImpl(SAXParserFactoryImpl spf, Map<String, Boolean> features, boolean secureProcessing)
         throws SAXException
     {
         fSecurityManager = new XMLSecurityManager(secureProcessing);
@@ -165,10 +164,9 @@
              */
             if (features != null) {
 
-                Object temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
+                Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
                 if (temp != null) {
-                    boolean value = ((Boolean) temp).booleanValue();
-                    if (value && Constants.IS_JDK8_OR_ABOVE) {
+                    if (temp && Constants.IS_JDK8_OR_ABOVE) {
                         fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
                                 XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
                         fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
@@ -241,15 +239,11 @@
      * XXX Does not handle possible conflicts between SAX feature names and
      * JAXP specific feature names, eg. SAXParserFactory.isValidating()
      */
-    private void setFeatures(Hashtable features)
+    private void setFeatures(Map<String, Boolean> features)
         throws SAXNotSupportedException, SAXNotRecognizedException {
         if (features != null) {
-            Iterator entries = features.entrySet().iterator();
-            while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry) entries.next();
-                String feature = (String) entry.getKey();
-                boolean value = ((Boolean) entry.getValue()).booleanValue();
-                xmlReader.setFeature0(feature, value);
+            for (Map.Entry<String, Boolean> entry : features.entrySet()) {
+                xmlReader.setFeature0(entry.getKey(), entry.getValue());
             }
         }
     }
--- a/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,15 +20,11 @@
 
 package com.sun.org.apache.xerces.internal.parsers;
 
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
@@ -37,7 +33,11 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
 
 /**
  * <p> This class provides an easy way for a user to preparse grammars
@@ -82,13 +82,15 @@
         Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
 
     // the "built-in" grammar loaders
-    private static final Hashtable KNOWN_LOADERS = new Hashtable();
+    private static final Map<String, String> KNOWN_LOADERS;
 
     static {
-        KNOWN_LOADERS.put(XMLGrammarDescription.XML_SCHEMA,
+        Map<String, String> loaders = new HashMap<>();
+        loaders.put(XMLGrammarDescription.XML_SCHEMA,
             "com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader");
-        KNOWN_LOADERS.put(XMLGrammarDescription.XML_DTD,
+        loaders.put(XMLGrammarDescription.XML_DTD,
             "com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDLoader");
+        KNOWN_LOADERS = Collections.unmodifiableMap(loaders);
     }
 
     /** Recognized properties. */
@@ -108,8 +110,8 @@
 
     protected Locale fLocale;
 
-    // Hashtable holding our loaders
-    private Hashtable fLoaders;
+    // Map holding our loaders
+    private Map<String, XMLGrammarLoader> fLoaders;
 
     //
     // Constructors
@@ -128,7 +130,7 @@
     public XMLGrammarPreparser (SymbolTable symbolTable) {
         fSymbolTable = symbolTable;
 
-        fLoaders = new Hashtable();
+        fLoaders = new HashMap<>();
         fErrorReporter = new XMLErrorReporter();
         setLocale(Locale.getDefault());
         fEntityResolver = new XMLEntityManager();
@@ -189,7 +191,7 @@
     public Grammar preparseGrammar(String type, XMLInputSource
                 is) throws XNIException, IOException {
         if(fLoaders.containsKey(type)) {
-            XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
+            XMLGrammarLoader gl = fLoaders.get(type);
             // make sure gl's been set up with all the "basic" properties:
             gl.setProperty(SYMBOL_TABLE, fSymbolTable);
             gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
@@ -271,7 +273,7 @@
     // it's possible the application may want access to a certain loader to do
     // some custom work.
     public XMLGrammarLoader getLoader(String type) {
-        return (XMLGrammarLoader)fLoaders.get(type);
+        return fLoaders.get(type);
     } // getLoader(String):  XMLGrammarLoader
 
     // set a feature.  This method tries to set it on all
@@ -280,10 +282,9 @@
     // by a grammar loader of a particular type, it will have
     // to retrieve that loader and use the loader's setFeature method.
     public void setFeature(String featureId, boolean value) {
-        Enumeration loaders = fLoaders.elements();
-        while(loaders.hasMoreElements()){
-            XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
+        for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
             try {
+                XMLGrammarLoader gl = entry.getValue();
                 gl.setFeature(featureId, value);
             } catch(Exception e) {
                 // eat it up...
@@ -304,10 +305,9 @@
     // <p> <strong>An application should use the explicit method
     // in this class to set "standard" properties like error handler etc.</strong>
     public void setProperty(String propId, Object value) {
-        Enumeration loaders = fLoaders.elements();
-        while(loaders.hasMoreElements()){
-            XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
+        for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
             try {
+                XMLGrammarLoader gl = entry.getValue();
                 gl.setProperty(propId, value);
             } catch(Exception e) {
                 // eat it up...
@@ -322,7 +322,7 @@
     // @param featureId the feature string to query.
     // @return the value of the feature.
     public boolean getFeature(String type, String featureId) {
-        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
+        XMLGrammarLoader gl = fLoaders.get(type);
         return gl.getFeature(featureId);
     } // getFeature (String, String):  boolean
 
@@ -335,7 +335,7 @@
     // @param propertyId the property string to query.
     // @return the value of the property.
     public Object getProperty(String type, String propertyId) {
-        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
+        XMLGrammarLoader gl = fLoaders.get(type);
         return gl.getProperty(propertyId);
     } // getProperty(String, String):  Object
 } // class XMLGrammarPreparser
--- a/src/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2000-2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,14 +20,15 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xerces.internal.xni.Augmentations;
+import java.util.Collections;
 import java.util.Enumeration;
-
-import com.sun.org.apache.xerces.internal.xni.Augmentations;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This class provides an implementation for Augmentations interface.
- * Augmentations interface defines a hashtable of additional data that could
+ * Augmentations interface defines a map of additional data that could
  * be passed along the document pipeline. The information can contain extra
  * arguments or infoset augmentations, for example PSVI. This additional
  * information is identified by a String key.
@@ -194,18 +195,18 @@
         }
 
         public String toString() {
-            StringBuffer buff = new StringBuffer();
-            buff.append("SmallContainer - fNumEntries == " + fNumEntries);
+            StringBuilder buff = new StringBuilder();
+            buff.append("SmallContainer - fNumEntries == ").append(fNumEntries);
 
             for (int i = 0; i < SIZE_LIMIT*2; i=i+2) {
-                buff.append("\nfAugmentations[");
-                buff.append(i);
-                buff.append("] == ");
-                buff.append(fAugmentations[i]);
-                buff.append("; fAugmentations[");
-                buff.append(i+1);
-                buff.append("] == ");
-                buff.append(fAugmentations[i+1]);
+                buff.append("\nfAugmentations[")
+                    .append(i)
+                    .append("] == ")
+                    .append(fAugmentations[i])
+                    .append("; fAugmentations[")
+                    .append(i+1)
+                    .append("] == ")
+                    .append(fAugmentations[i+1]);
             }
 
             return buff.toString();
@@ -240,7 +241,7 @@
     }
 
     class LargeContainer extends AugmentationsItemsContainer {
-        final Hashtable fAugmentations = new Hashtable();
+        final Map<Object, Object> fAugmentations = new HashMap<>();
 
         public Object getItem(Object key) {
             return fAugmentations.get(key);
@@ -255,7 +256,7 @@
         }
 
         public Enumeration keys() {
-            return fAugmentations.keys();
+            return Collections.enumeration(fAugmentations.keySet());
         }
 
         public void clear() {
@@ -271,18 +272,14 @@
         }
 
         public String toString() {
-            StringBuffer buff = new StringBuffer();
+            StringBuilder buff = new StringBuilder();
             buff.append("LargeContainer");
-            Enumeration keys = fAugmentations.keys();
-
-            while (keys.hasMoreElements()) {
-                Object key = keys.nextElement();
+            for(Object key : fAugmentations.keySet()) {
                 buff.append("\nkey == ");
                 buff.append(key);
                 buff.append("; value == ");
                 buff.append(fAugmentations.get(key));
             }
-
             return buff.toString();
         }
     }
--- a/src/com/sun/org/apache/xerces/internal/util/DOMErrorHandlerWrapper.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/DOMErrorHandlerWrapper.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002, 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,20 +20,20 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
+import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
+import com.sun.org.apache.xerces.internal.dom.DOMLocatorImpl;
+import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
-
-import org.w3c.dom.Node;
+import java.io.PrintWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMLocator;
 import org.w3c.dom.DOMErrorHandler;
-import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
-import com.sun.org.apache.xerces.internal.dom.DOMLocatorImpl;
-import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
-
-import java.io.PrintWriter;
-import java.util.Hashtable;
+import org.w3c.dom.DOMLocator;
+import org.w3c.dom.Node;
 
 /**
  * This class handles DOM errors .
@@ -287,131 +287,133 @@
     private static class DOMErrorTypeMap {
 
         /** Map for converting internal error codes to DOM error types. **/
-        private static Hashtable fgDOMErrorTypeTable;
+        private static final Map<XMLErrorCode, String> fgDOMErrorTypeTable;
 
         static {
             // initialize error type table: internal error codes (represented by domain and key) need to be mapped to a DOM error type.
 
             // REVISIT: do well-formedness issues involving XML declaration <?xml ... ?> need to be added to hash table (no XML declaration node in DOM, but Document includes xmlEncoding, xmlStandalone, xmlVersion, etc.
 
-            fgDOMErrorTypeTable = new Hashtable();
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInCDSect"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInContent"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "TwoColonsInQName"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ColonNotLegalWithNS"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInProlog"), "wf-invalid-character");  // e.g. in Processing Instruction
+            Map<XMLErrorCode, String> aDOMErrorTypeTable = new HashMap<>();
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInCDSect"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInContent"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "TwoColonsInQName"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ColonNotLegalWithNS"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInProlog"), "wf-invalid-character");  // e.g. in Processing Instruction
 
             // InvalidCharInXMLDecl omitted because XML declaration is not a DOM Node
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDEndInContent"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDSectUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeNotAllowed"), "doctype-not-allowed");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagRequired"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementUnterminated"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EqRequiredInAttribute"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "OpenQuoteExpected"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CloseQuoteExpected"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagUnterminated"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MarkupNotRecognizedInContent"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeIllegalInContent"), "doctype-not-allowed");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInAttValue"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPI"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInInternalSubset"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInAttValue"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "LessthanInAttValue"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributeValueUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PITargetRequired"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredInPI"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PIUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReservedPITarget"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PI_NOT_IN_ONE_ENTITY"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PINotInOneEntity"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingDeclInvalid"), "unsupported-encoding");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingByteOrderUnsupported"), "unsupported-encoding");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInEntityValue"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInExternalSubset"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInIgnoreSect"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPublicID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInSystemID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterSYSTEM"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInSystemID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SystemIDUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterPUBLIC"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInPublicID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PublicIDUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PubidCharIllegal"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredBetweenPublicAndSystem"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !DOCTYPE)
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ROOT_ELEMENT_TYPE_REQUIRED"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypedeclUnterminated"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PEReferenceWithinMarkup"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_MARKUP_NOT_RECOGNIZED_IN_DTD"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CONTENTSPEC_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementDeclUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_MIXED"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MixedContentUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttNameRequiredInAttDef"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttTypeRequiredInAttDef"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ATTRIBUTE_DEFINITION"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NAME_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationTypeUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NMTOKEN_REQUIRED_IN_ENUMERATION"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EnumerationUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_TOKENS_IN_ENUMERATION"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_NOTATION_IN_ENUMERATION"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IncludeSectUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IgnoreSectUnterminated"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NameRequiredInPEReference"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SemicolonRequiredInPEReference"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY)
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY %)
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY %)
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY)
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EntityDeclUnterminated"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDRequired"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_URI_FRAGMENT_IN_SYSTEMID"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDorPublicIDRequired"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationDeclUnterminated"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToExternalEntity"), "wf-invalid-character");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToUnparsedEntity"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDEndInContent"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDSectUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeNotAllowed"), "doctype-not-allowed");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagRequired"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementUnterminated"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EqRequiredInAttribute"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "OpenQuoteExpected"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CloseQuoteExpected"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagUnterminated"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MarkupNotRecognizedInContent"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeIllegalInContent"), "doctype-not-allowed");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInAttValue"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPI"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInInternalSubset"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInAttValue"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "LessthanInAttValue"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributeValueUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PITargetRequired"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredInPI"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PIUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReservedPITarget"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PI_NOT_IN_ONE_ENTITY"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PINotInOneEntity"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingDeclInvalid"), "unsupported-encoding");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingByteOrderUnsupported"), "unsupported-encoding");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInEntityValue"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInExternalSubset"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInIgnoreSect"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPublicID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInSystemID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterSYSTEM"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInSystemID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SystemIDUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterPUBLIC"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInPublicID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PublicIDUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PubidCharIllegal"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredBetweenPublicAndSystem"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !DOCTYPE)
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ROOT_ELEMENT_TYPE_REQUIRED"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypedeclUnterminated"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PEReferenceWithinMarkup"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_MARKUP_NOT_RECOGNIZED_IN_DTD"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CONTENTSPEC_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementDeclUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_MIXED"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MixedContentUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttNameRequiredInAttDef"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttTypeRequiredInAttDef"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ATTRIBUTE_DEFINITION"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NAME_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationTypeUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NMTOKEN_REQUIRED_IN_ENUMERATION"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EnumerationUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_TOKENS_IN_ENUMERATION"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_NOTATION_IN_ENUMERATION"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IncludeSectUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IgnoreSectUnterminated"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NameRequiredInPEReference"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SemicolonRequiredInPEReference"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY)
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY %)
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY %)
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node (which follows !ENTITY)
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EntityDeclUnterminated"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDRequired"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_URI_FRAGMENT_IN_SYSTEMID"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name");  // considered error in name of node, which follows !NOTATION
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDorPublicIDRequired"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationDeclUnterminated"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToExternalEntity"), "wf-invalid-character");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToUnparsedEntity"), "wf-invalid-character");
 
             // REVISIT: do EntityNotDeclared, RecursiveReference, RecursiveGeneralReference, RecursivePEReference belong here?
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingNotSupported"), "unsupported-encoding");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingRequired"), "unsupported-encoding");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IllegalQName"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementXMLNSPrefix"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementPrefixUnbound"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributePrefixUnbound"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EmptyPrefixedAttName"), "wf-invalid-character-in-node-name");
-            fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PrefixDeclared"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingNotSupported"), "unsupported-encoding");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingRequired"), "unsupported-encoding");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IllegalQName"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementXMLNSPrefix"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementPrefixUnbound"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributePrefixUnbound"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EmptyPrefixedAttName"), "wf-invalid-character-in-node-name");
+            aDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PrefixDeclared"), "wf-invalid-character-in-node-name");
+
+            fgDOMErrorTypeTable = Collections.unmodifiableMap(aDOMErrorTypeTable);
         }
 
         public static String getDOMErrorType (XMLErrorCode error) {
-            return (String) fgDOMErrorTypeTable.get(error);
+            return fgDOMErrorTypeTable.get(error);
         }
 
         private DOMErrorTypeMap () {}
--- a/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -20,11 +20,10 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
-import java.util.Hashtable;
-
 import com.sun.org.apache.xerces.internal.dom.AttrImpl;
 import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
 import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl;
+import java.util.Map;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -184,7 +183,7 @@
     } // getFirstChildElement(Node):Element
 
     /** Finds and returns the first visible child element node. */
-    public static Element getFirstVisibleChildElement(Node parent, Hashtable hiddenNodes) {
+    public static Element getFirstVisibleChildElement(Node parent, Map<Node, String> hiddenNodes) {
 
         // search for node
         Node child = parent.getFirstChild();
@@ -241,7 +240,7 @@
     /** Finds and returns the last visible child element node.
      *  Overload previous method for non-Xerces node impl
      */
-    public static Element getLastVisibleChildElement(Node parent, Hashtable hiddenNodes) {
+    public static Element getLastVisibleChildElement(Node parent, Map<Node, String> hiddenNodes) {
 
         // search for node
         Node child = parent.getLastChild();
@@ -293,7 +292,7 @@
     } // getNextSiblingdElement(Node):Element
 
     // get next visible (un-hidden) node, overload previous method for non Xerces node impl
-    public static Element getNextVisibleSiblingElement(Node node, Hashtable hiddenNodes) {
+    public static Element getNextVisibleSiblingElement(Node node, Map<Node, String> hiddenNodes) {
 
         // search for node
         Node sibling = node.getNextSibling();
@@ -319,7 +318,7 @@
     } // setHidden(node):void
 
     // set this Node as being hidden, overloaded method
-    public static void setHidden(Node node, Hashtable hiddenNodes) {
+    public static void setHidden(Node node, Map<Node, String> hiddenNodes) {
         if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
             ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(true, false);
         }
@@ -337,7 +336,7 @@
     } // setVisible(node):void
 
     // set this Node as being visible, overloaded method
-    public static void setVisible(Node node, Hashtable hiddenNodes) {
+    public static void setVisible(Node node, Map<Node, String> hiddenNodes) {
         if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
             ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(false, false);
         }
@@ -356,7 +355,7 @@
     } // isHidden(Node):boolean
 
     // is this node hidden? overloaded method
-    public static boolean isHidden(Node node, Hashtable hiddenNodes) {
+    public static boolean isHidden(Node node, Map<Node, String> hiddenNodes) {
         if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
             return ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).getReadOnly();
         }
--- a/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,7 +20,9 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * EncodingMap is a convenience class which handles conversions between
@@ -477,469 +479,473 @@
     //
 
     /** fIANA2JavaMap */
-    protected final static Hashtable fIANA2JavaMap = new Hashtable();
+    protected final static Map<String, String> fIANA2JavaMap;
 
     /** fJava2IANAMap */
-    protected final static Hashtable fJava2IANAMap = new Hashtable();
+    protected final static Map<String, String> fJava2IANAMap;
 
     //
     // Static initialization
     //
 
     static {
+        Map<String, String> aIANA2JavaMap = new HashMap<>();
+        Map<String, String> aJava2IANAMap = new HashMap<>();
 
         // add IANA to Java encoding mappings.
-        fIANA2JavaMap.put("BIG5",            "Big5");
-        fIANA2JavaMap.put("CSBIG5",            "Big5");
-        fIANA2JavaMap.put("CP037",    "CP037");
-        fIANA2JavaMap.put("IBM037",    "CP037");
-        fIANA2JavaMap.put("CSIBM037",    "CP037");
-        fIANA2JavaMap.put("EBCDIC-CP-US",    "CP037");
-        fIANA2JavaMap.put("EBCDIC-CP-CA",    "CP037");
-        fIANA2JavaMap.put("EBCDIC-CP-NL",    "CP037");
-        fIANA2JavaMap.put("EBCDIC-CP-WT",    "CP037");
-        fIANA2JavaMap.put("IBM273",    "CP273");
-        fIANA2JavaMap.put("CP273",    "CP273");
-        fIANA2JavaMap.put("CSIBM273",    "CP273");
-        fIANA2JavaMap.put("IBM277",    "CP277");
-        fIANA2JavaMap.put("CP277",    "CP277");
-        fIANA2JavaMap.put("CSIBM277",    "CP277");
-        fIANA2JavaMap.put("EBCDIC-CP-DK",    "CP277");
-        fIANA2JavaMap.put("EBCDIC-CP-NO",    "CP277");
-        fIANA2JavaMap.put("IBM278",    "CP278");
-        fIANA2JavaMap.put("CP278",    "CP278");
-        fIANA2JavaMap.put("CSIBM278",    "CP278");
-        fIANA2JavaMap.put("EBCDIC-CP-FI",    "CP278");
-        fIANA2JavaMap.put("EBCDIC-CP-SE",    "CP278");
-        fIANA2JavaMap.put("IBM280",    "CP280");
-        fIANA2JavaMap.put("CP280",    "CP280");
-        fIANA2JavaMap.put("CSIBM280",    "CP280");
-        fIANA2JavaMap.put("EBCDIC-CP-IT",    "CP280");
-        fIANA2JavaMap.put("IBM284",    "CP284");
-        fIANA2JavaMap.put("CP284",    "CP284");
-        fIANA2JavaMap.put("CSIBM284",    "CP284");
-        fIANA2JavaMap.put("EBCDIC-CP-ES",    "CP284");
-        fIANA2JavaMap.put("EBCDIC-CP-GB",    "CP285");
-        fIANA2JavaMap.put("IBM285",    "CP285");
-        fIANA2JavaMap.put("CP285",    "CP285");
-        fIANA2JavaMap.put("CSIBM285",    "CP285");
-        fIANA2JavaMap.put("EBCDIC-JP-KANA",    "CP290");
-        fIANA2JavaMap.put("IBM290",    "CP290");
-        fIANA2JavaMap.put("CP290",    "CP290");
-        fIANA2JavaMap.put("CSIBM290",    "CP290");
-        fIANA2JavaMap.put("EBCDIC-CP-FR",    "CP297");
-        fIANA2JavaMap.put("IBM297",    "CP297");
-        fIANA2JavaMap.put("CP297",    "CP297");
-        fIANA2JavaMap.put("CSIBM297",    "CP297");
-        fIANA2JavaMap.put("EBCDIC-CP-AR1",   "CP420");
-        fIANA2JavaMap.put("IBM420",    "CP420");
-        fIANA2JavaMap.put("CP420",    "CP420");
-        fIANA2JavaMap.put("CSIBM420",    "CP420");
-        fIANA2JavaMap.put("EBCDIC-CP-HE",    "CP424");
-        fIANA2JavaMap.put("IBM424",    "CP424");
-        fIANA2JavaMap.put("CP424",    "CP424");
-        fIANA2JavaMap.put("CSIBM424",    "CP424");
-        fIANA2JavaMap.put("IBM437",    "CP437");
-        fIANA2JavaMap.put("437",    "CP437");
-        fIANA2JavaMap.put("CP437",    "CP437");
-        fIANA2JavaMap.put("CSPC8CODEPAGE437",    "CP437");
-        fIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
-        fIANA2JavaMap.put("IBM500",    "CP500");
-        fIANA2JavaMap.put("CP500",    "CP500");
-        fIANA2JavaMap.put("CSIBM500",    "CP500");
-        fIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
-        fIANA2JavaMap.put("EBCDIC-CP-BE",    "CP500");
-        fIANA2JavaMap.put("IBM775",    "CP775");
-        fIANA2JavaMap.put("CP775",    "CP775");
-        fIANA2JavaMap.put("CSPC775BALTIC",    "CP775");
-        fIANA2JavaMap.put("IBM850",    "CP850");
-        fIANA2JavaMap.put("850",    "CP850");
-        fIANA2JavaMap.put("CP850",    "CP850");
-        fIANA2JavaMap.put("CSPC850MULTILINGUAL",    "CP850");
-        fIANA2JavaMap.put("IBM852",    "CP852");
-        fIANA2JavaMap.put("852",    "CP852");
-        fIANA2JavaMap.put("CP852",    "CP852");
-        fIANA2JavaMap.put("CSPCP852",    "CP852");
-        fIANA2JavaMap.put("IBM855",    "CP855");
-        fIANA2JavaMap.put("855",    "CP855");
-        fIANA2JavaMap.put("CP855",    "CP855");
-        fIANA2JavaMap.put("CSIBM855",    "CP855");
-        fIANA2JavaMap.put("IBM857",    "CP857");
-        fIANA2JavaMap.put("857",    "CP857");
-        fIANA2JavaMap.put("CP857",    "CP857");
-        fIANA2JavaMap.put("CSIBM857",    "CP857");
-        fIANA2JavaMap.put("IBM00858",    "CP858");
-        fIANA2JavaMap.put("CP00858",    "CP858");
-        fIANA2JavaMap.put("CCSID00858",    "CP858");
-        fIANA2JavaMap.put("IBM860",    "CP860");
-        fIANA2JavaMap.put("860",    "CP860");
-        fIANA2JavaMap.put("CP860",    "CP860");
-        fIANA2JavaMap.put("CSIBM860",    "CP860");
-        fIANA2JavaMap.put("IBM861",    "CP861");
-        fIANA2JavaMap.put("861",    "CP861");
-        fIANA2JavaMap.put("CP861",    "CP861");
-        fIANA2JavaMap.put("CP-IS",    "CP861");
-        fIANA2JavaMap.put("CSIBM861",    "CP861");
-        fIANA2JavaMap.put("IBM862",    "CP862");
-        fIANA2JavaMap.put("862",    "CP862");
-        fIANA2JavaMap.put("CP862",    "CP862");
-        fIANA2JavaMap.put("CSPC862LATINHEBREW",    "CP862");
-        fIANA2JavaMap.put("IBM863",    "CP863");
-        fIANA2JavaMap.put("863",    "CP863");
-        fIANA2JavaMap.put("CP863",    "CP863");
-        fIANA2JavaMap.put("CSIBM863",    "CP863");
-        fIANA2JavaMap.put("IBM864",    "CP864");
-        fIANA2JavaMap.put("CP864",    "CP864");
-        fIANA2JavaMap.put("CSIBM864",    "CP864");
-        fIANA2JavaMap.put("IBM865",    "CP865");
-        fIANA2JavaMap.put("865",    "CP865");
-        fIANA2JavaMap.put("CP865",    "CP865");
-        fIANA2JavaMap.put("CSIBM865",    "CP865");
-        fIANA2JavaMap.put("IBM866",    "CP866");
-        fIANA2JavaMap.put("866",    "CP866");
-        fIANA2JavaMap.put("CP866",    "CP866");
-        fIANA2JavaMap.put("CSIBM866",    "CP866");
-        fIANA2JavaMap.put("IBM868",    "CP868");
-        fIANA2JavaMap.put("CP868",    "CP868");
-        fIANA2JavaMap.put("CSIBM868",    "CP868");
-        fIANA2JavaMap.put("CP-AR",        "CP868");
-        fIANA2JavaMap.put("IBM869",    "CP869");
-        fIANA2JavaMap.put("CP869",    "CP869");
-        fIANA2JavaMap.put("CSIBM869",    "CP869");
-        fIANA2JavaMap.put("CP-GR",        "CP869");
-        fIANA2JavaMap.put("IBM870",    "CP870");
-        fIANA2JavaMap.put("CP870",    "CP870");
-        fIANA2JavaMap.put("CSIBM870",    "CP870");
-        fIANA2JavaMap.put("EBCDIC-CP-ROECE", "CP870");
-        fIANA2JavaMap.put("EBCDIC-CP-YU",    "CP870");
-        fIANA2JavaMap.put("IBM871",    "CP871");
-        fIANA2JavaMap.put("CP871",    "CP871");
-        fIANA2JavaMap.put("CSIBM871",    "CP871");
-        fIANA2JavaMap.put("EBCDIC-CP-IS",    "CP871");
-        fIANA2JavaMap.put("IBM918",    "CP918");
-        fIANA2JavaMap.put("CP918",    "CP918");
-        fIANA2JavaMap.put("CSIBM918",    "CP918");
-        fIANA2JavaMap.put("EBCDIC-CP-AR2",   "CP918");
-        fIANA2JavaMap.put("IBM00924",    "CP924");
-        fIANA2JavaMap.put("CP00924",    "CP924");
-        fIANA2JavaMap.put("CCSID00924",    "CP924");
+        aIANA2JavaMap.put("BIG5",            "Big5");
+        aIANA2JavaMap.put("CSBIG5",            "Big5");
+        aIANA2JavaMap.put("CP037",    "CP037");
+        aIANA2JavaMap.put("IBM037",    "CP037");
+        aIANA2JavaMap.put("CSIBM037",    "CP037");
+        aIANA2JavaMap.put("EBCDIC-CP-US",    "CP037");
+        aIANA2JavaMap.put("EBCDIC-CP-CA",    "CP037");
+        aIANA2JavaMap.put("EBCDIC-CP-NL",    "CP037");
+        aIANA2JavaMap.put("EBCDIC-CP-WT",    "CP037");
+        aIANA2JavaMap.put("IBM273",    "CP273");
+        aIANA2JavaMap.put("CP273",    "CP273");
+        aIANA2JavaMap.put("CSIBM273",    "CP273");
+        aIANA2JavaMap.put("IBM277",    "CP277");
+        aIANA2JavaMap.put("CP277",    "CP277");
+        aIANA2JavaMap.put("CSIBM277",    "CP277");
+        aIANA2JavaMap.put("EBCDIC-CP-DK",    "CP277");
+        aIANA2JavaMap.put("EBCDIC-CP-NO",    "CP277");
+        aIANA2JavaMap.put("IBM278",    "CP278");
+        aIANA2JavaMap.put("CP278",    "CP278");
+        aIANA2JavaMap.put("CSIBM278",    "CP278");
+        aIANA2JavaMap.put("EBCDIC-CP-FI",    "CP278");
+        aIANA2JavaMap.put("EBCDIC-CP-SE",    "CP278");
+        aIANA2JavaMap.put("IBM280",    "CP280");
+        aIANA2JavaMap.put("CP280",    "CP280");
+        aIANA2JavaMap.put("CSIBM280",    "CP280");
+        aIANA2JavaMap.put("EBCDIC-CP-IT",    "CP280");
+        aIANA2JavaMap.put("IBM284",    "CP284");
+        aIANA2JavaMap.put("CP284",    "CP284");
+        aIANA2JavaMap.put("CSIBM284",    "CP284");
+        aIANA2JavaMap.put("EBCDIC-CP-ES",    "CP284");
+        aIANA2JavaMap.put("EBCDIC-CP-GB",    "CP285");
+        aIANA2JavaMap.put("IBM285",    "CP285");
+        aIANA2JavaMap.put("CP285",    "CP285");
+        aIANA2JavaMap.put("CSIBM285",    "CP285");
+        aIANA2JavaMap.put("EBCDIC-JP-KANA",    "CP290");
+        aIANA2JavaMap.put("IBM290",    "CP290");
+        aIANA2JavaMap.put("CP290",    "CP290");
+        aIANA2JavaMap.put("CSIBM290",    "CP290");
+        aIANA2JavaMap.put("EBCDIC-CP-FR",    "CP297");
+        aIANA2JavaMap.put("IBM297",    "CP297");
+        aIANA2JavaMap.put("CP297",    "CP297");
+        aIANA2JavaMap.put("CSIBM297",    "CP297");
+        aIANA2JavaMap.put("EBCDIC-CP-AR1",   "CP420");
+        aIANA2JavaMap.put("IBM420",    "CP420");
+        aIANA2JavaMap.put("CP420",    "CP420");
+        aIANA2JavaMap.put("CSIBM420",    "CP420");
+        aIANA2JavaMap.put("EBCDIC-CP-HE",    "CP424");
+        aIANA2JavaMap.put("IBM424",    "CP424");
+        aIANA2JavaMap.put("CP424",    "CP424");
+        aIANA2JavaMap.put("CSIBM424",    "CP424");
+        aIANA2JavaMap.put("IBM437",    "CP437");
+        aIANA2JavaMap.put("437",    "CP437");
+        aIANA2JavaMap.put("CP437",    "CP437");
+        aIANA2JavaMap.put("CSPC8CODEPAGE437",    "CP437");
+        aIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
+        aIANA2JavaMap.put("IBM500",    "CP500");
+        aIANA2JavaMap.put("CP500",    "CP500");
+        aIANA2JavaMap.put("CSIBM500",    "CP500");
+        aIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
+        aIANA2JavaMap.put("EBCDIC-CP-BE",    "CP500");
+        aIANA2JavaMap.put("IBM775",    "CP775");
+        aIANA2JavaMap.put("CP775",    "CP775");
+        aIANA2JavaMap.put("CSPC775BALTIC",    "CP775");
+        aIANA2JavaMap.put("IBM850",    "CP850");
+        aIANA2JavaMap.put("850",    "CP850");
+        aIANA2JavaMap.put("CP850",    "CP850");
+        aIANA2JavaMap.put("CSPC850MULTILINGUAL",    "CP850");
+        aIANA2JavaMap.put("IBM852",    "CP852");
+        aIANA2JavaMap.put("852",    "CP852");
+        aIANA2JavaMap.put("CP852",    "CP852");
+        aIANA2JavaMap.put("CSPCP852",    "CP852");
+        aIANA2JavaMap.put("IBM855",    "CP855");
+        aIANA2JavaMap.put("855",    "CP855");
+        aIANA2JavaMap.put("CP855",    "CP855");
+        aIANA2JavaMap.put("CSIBM855",    "CP855");
+        aIANA2JavaMap.put("IBM857",    "CP857");
+        aIANA2JavaMap.put("857",    "CP857");
+        aIANA2JavaMap.put("CP857",    "CP857");
+        aIANA2JavaMap.put("CSIBM857",    "CP857");
+        aIANA2JavaMap.put("IBM00858",    "CP858");
+        aIANA2JavaMap.put("CP00858",    "CP858");
+        aIANA2JavaMap.put("CCSID00858",    "CP858");
+        aIANA2JavaMap.put("IBM860",    "CP860");
+        aIANA2JavaMap.put("860",    "CP860");
+        aIANA2JavaMap.put("CP860",    "CP860");
+        aIANA2JavaMap.put("CSIBM860",    "CP860");
+        aIANA2JavaMap.put("IBM861",    "CP861");
+        aIANA2JavaMap.put("861",    "CP861");
+        aIANA2JavaMap.put("CP861",    "CP861");
+        aIANA2JavaMap.put("CP-IS",    "CP861");
+        aIANA2JavaMap.put("CSIBM861",    "CP861");
+        aIANA2JavaMap.put("IBM862",    "CP862");
+        aIANA2JavaMap.put("862",    "CP862");
+        aIANA2JavaMap.put("CP862",    "CP862");
+        aIANA2JavaMap.put("CSPC862LATINHEBREW",    "CP862");
+        aIANA2JavaMap.put("IBM863",    "CP863");
+        aIANA2JavaMap.put("863",    "CP863");
+        aIANA2JavaMap.put("CP863",    "CP863");
+        aIANA2JavaMap.put("CSIBM863",    "CP863");
+        aIANA2JavaMap.put("IBM864",    "CP864");
+        aIANA2JavaMap.put("CP864",    "CP864");
+        aIANA2JavaMap.put("CSIBM864",    "CP864");
+        aIANA2JavaMap.put("IBM865",    "CP865");
+        aIANA2JavaMap.put("865",    "CP865");
+        aIANA2JavaMap.put("CP865",    "CP865");
+        aIANA2JavaMap.put("CSIBM865",    "CP865");
+        aIANA2JavaMap.put("IBM866",    "CP866");
+        aIANA2JavaMap.put("866",    "CP866");
+        aIANA2JavaMap.put("CP866",    "CP866");
+        aIANA2JavaMap.put("CSIBM866",    "CP866");
+        aIANA2JavaMap.put("IBM868",    "CP868");
+        aIANA2JavaMap.put("CP868",    "CP868");
+        aIANA2JavaMap.put("CSIBM868",    "CP868");
+        aIANA2JavaMap.put("CP-AR",        "CP868");
+        aIANA2JavaMap.put("IBM869",    "CP869");
+        aIANA2JavaMap.put("CP869",    "CP869");
+        aIANA2JavaMap.put("CSIBM869",    "CP869");
+        aIANA2JavaMap.put("CP-GR",        "CP869");
+        aIANA2JavaMap.put("IBM870",    "CP870");
+        aIANA2JavaMap.put("CP870",    "CP870");
+        aIANA2JavaMap.put("CSIBM870",    "CP870");
+        aIANA2JavaMap.put("EBCDIC-CP-ROECE", "CP870");
+        aIANA2JavaMap.put("EBCDIC-CP-YU",    "CP870");
+        aIANA2JavaMap.put("IBM871",    "CP871");
+        aIANA2JavaMap.put("CP871",    "CP871");
+        aIANA2JavaMap.put("CSIBM871",    "CP871");
+        aIANA2JavaMap.put("EBCDIC-CP-IS",    "CP871");
+        aIANA2JavaMap.put("IBM918",    "CP918");
+        aIANA2JavaMap.put("CP918",    "CP918");
+        aIANA2JavaMap.put("CSIBM918",    "CP918");
+        aIANA2JavaMap.put("EBCDIC-CP-AR2",   "CP918");
+        aIANA2JavaMap.put("IBM00924",    "CP924");
+        aIANA2JavaMap.put("CP00924",    "CP924");
+        aIANA2JavaMap.put("CCSID00924",    "CP924");
         // is this an error???
-        fIANA2JavaMap.put("EBCDIC-LATIN9--EURO",    "CP924");
-        fIANA2JavaMap.put("IBM1026",    "CP1026");
-        fIANA2JavaMap.put("CP1026",    "CP1026");
-        fIANA2JavaMap.put("CSIBM1026",    "CP1026");
-        fIANA2JavaMap.put("IBM01140",    "Cp1140");
-        fIANA2JavaMap.put("CP01140",    "Cp1140");
-        fIANA2JavaMap.put("CCSID01140",    "Cp1140");
-        fIANA2JavaMap.put("IBM01141",    "Cp1141");
-        fIANA2JavaMap.put("CP01141",    "Cp1141");
-        fIANA2JavaMap.put("CCSID01141",    "Cp1141");
-        fIANA2JavaMap.put("IBM01142",    "Cp1142");
-        fIANA2JavaMap.put("CP01142",    "Cp1142");
-        fIANA2JavaMap.put("CCSID01142",    "Cp1142");
-        fIANA2JavaMap.put("IBM01143",    "Cp1143");
-        fIANA2JavaMap.put("CP01143",    "Cp1143");
-        fIANA2JavaMap.put("CCSID01143",    "Cp1143");
-        fIANA2JavaMap.put("IBM01144",    "Cp1144");
-        fIANA2JavaMap.put("CP01144",    "Cp1144");
-        fIANA2JavaMap.put("CCSID01144",    "Cp1144");
-        fIANA2JavaMap.put("IBM01145",    "Cp1145");
-        fIANA2JavaMap.put("CP01145",    "Cp1145");
-        fIANA2JavaMap.put("CCSID01145",    "Cp1145");
-        fIANA2JavaMap.put("IBM01146",    "Cp1146");
-        fIANA2JavaMap.put("CP01146",    "Cp1146");
-        fIANA2JavaMap.put("CCSID01146",    "Cp1146");
-        fIANA2JavaMap.put("IBM01147",    "Cp1147");
-        fIANA2JavaMap.put("CP01147",    "Cp1147");
-        fIANA2JavaMap.put("CCSID01147",    "Cp1147");
-        fIANA2JavaMap.put("IBM01148",    "Cp1148");
-        fIANA2JavaMap.put("CP01148",    "Cp1148");
-        fIANA2JavaMap.put("CCSID01148",    "Cp1148");
-        fIANA2JavaMap.put("IBM01149",    "Cp1149");
-        fIANA2JavaMap.put("CP01149",    "Cp1149");
-        fIANA2JavaMap.put("CCSID01149",    "Cp1149");
-        fIANA2JavaMap.put("EUC-JP",          "EUCJIS");
-        fIANA2JavaMap.put("CSEUCPKDFMTJAPANESE",          "EUCJIS");
-        fIANA2JavaMap.put("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE",          "EUCJIS");
-        fIANA2JavaMap.put("EUC-KR",          "KSC5601");
-        fIANA2JavaMap.put("CSEUCKR",          "KSC5601");
-        fIANA2JavaMap.put("KS_C_5601-1987",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("ISO-IR-149",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("KS_C_5601-1989",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("KSC_5601",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("KOREAN",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("CSKSC56011987",          "KS_C_5601-1987");
-        fIANA2JavaMap.put("GB2312",          "GB2312");
-        fIANA2JavaMap.put("CSGB2312",          "GB2312");
-        fIANA2JavaMap.put("ISO-2022-JP",     "JIS");
-        fIANA2JavaMap.put("CSISO2022JP",     "JIS");
-        fIANA2JavaMap.put("ISO-2022-KR",     "ISO2022KR");
-        fIANA2JavaMap.put("CSISO2022KR",     "ISO2022KR");
-        fIANA2JavaMap.put("ISO-2022-CN",     "ISO2022CN");
+        aIANA2JavaMap.put("EBCDIC-LATIN9--EURO",    "CP924");
+        aIANA2JavaMap.put("IBM1026",    "CP1026");
+        aIANA2JavaMap.put("CP1026",    "CP1026");
+        aIANA2JavaMap.put("CSIBM1026",    "CP1026");
+        aIANA2JavaMap.put("IBM01140",    "Cp1140");
+        aIANA2JavaMap.put("CP01140",    "Cp1140");
+        aIANA2JavaMap.put("CCSID01140",    "Cp1140");
+        aIANA2JavaMap.put("IBM01141",    "Cp1141");
+        aIANA2JavaMap.put("CP01141",    "Cp1141");
+        aIANA2JavaMap.put("CCSID01141",    "Cp1141");
+        aIANA2JavaMap.put("IBM01142",    "Cp1142");
+        aIANA2JavaMap.put("CP01142",    "Cp1142");
+        aIANA2JavaMap.put("CCSID01142",    "Cp1142");
+        aIANA2JavaMap.put("IBM01143",    "Cp1143");
+        aIANA2JavaMap.put("CP01143",    "Cp1143");
+        aIANA2JavaMap.put("CCSID01143",    "Cp1143");
+        aIANA2JavaMap.put("IBM01144",    "Cp1144");
+        aIANA2JavaMap.put("CP01144",    "Cp1144");
+        aIANA2JavaMap.put("CCSID01144",    "Cp1144");
+        aIANA2JavaMap.put("IBM01145",    "Cp1145");
+        aIANA2JavaMap.put("CP01145",    "Cp1145");
+        aIANA2JavaMap.put("CCSID01145",    "Cp1145");
+        aIANA2JavaMap.put("IBM01146",    "Cp1146");
+        aIANA2JavaMap.put("CP01146",    "Cp1146");
+        aIANA2JavaMap.put("CCSID01146",    "Cp1146");
+        aIANA2JavaMap.put("IBM01147",    "Cp1147");
+        aIANA2JavaMap.put("CP01147",    "Cp1147");
+        aIANA2JavaMap.put("CCSID01147",    "Cp1147");
+        aIANA2JavaMap.put("IBM01148",    "Cp1148");
+        aIANA2JavaMap.put("CP01148",    "Cp1148");
+        aIANA2JavaMap.put("CCSID01148",    "Cp1148");
+        aIANA2JavaMap.put("IBM01149",    "Cp1149");
+        aIANA2JavaMap.put("CP01149",    "Cp1149");
+        aIANA2JavaMap.put("CCSID01149",    "Cp1149");
+        aIANA2JavaMap.put("EUC-JP",          "EUCJIS");
+        aIANA2JavaMap.put("CSEUCPKDFMTJAPANESE",          "EUCJIS");
+        aIANA2JavaMap.put("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE",          "EUCJIS");
+        aIANA2JavaMap.put("EUC-KR",          "KSC5601");
+        aIANA2JavaMap.put("CSEUCKR",          "KSC5601");
+        aIANA2JavaMap.put("KS_C_5601-1987",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("ISO-IR-149",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("KS_C_5601-1989",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("KSC_5601",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("KOREAN",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("CSKSC56011987",          "KS_C_5601-1987");
+        aIANA2JavaMap.put("GB2312",          "GB2312");
+        aIANA2JavaMap.put("CSGB2312",          "GB2312");
+        aIANA2JavaMap.put("ISO-2022-JP",     "JIS");
+        aIANA2JavaMap.put("CSISO2022JP",     "JIS");
+        aIANA2JavaMap.put("ISO-2022-KR",     "ISO2022KR");
+        aIANA2JavaMap.put("CSISO2022KR",     "ISO2022KR");
+        aIANA2JavaMap.put("ISO-2022-CN",     "ISO2022CN");
 
-        fIANA2JavaMap.put("X0201",  "JIS0201");
-        fIANA2JavaMap.put("CSISO13JISC6220JP", "JIS0201");
-        fIANA2JavaMap.put("X0208",  "JIS0208");
-        fIANA2JavaMap.put("ISO-IR-87",  "JIS0208");
-        fIANA2JavaMap.put("X0208dbiJIS_X0208-1983",  "JIS0208");
-        fIANA2JavaMap.put("CSISO87JISX0208",  "JIS0208");
-        fIANA2JavaMap.put("X0212",  "JIS0212");
-        fIANA2JavaMap.put("ISO-IR-159",  "JIS0212");
-        fIANA2JavaMap.put("CSISO159JISX02121990",  "JIS0212");
-        fIANA2JavaMap.put("GB18030",       "GB18030");
-        fIANA2JavaMap.put("GBK",       "GBK");
-        fIANA2JavaMap.put("CP936",       "GBK");
-        fIANA2JavaMap.put("MS936",       "GBK");
-        fIANA2JavaMap.put("WINDOWS-936",       "GBK");
-        fIANA2JavaMap.put("SHIFT_JIS",       "SJIS");
-        fIANA2JavaMap.put("CSSHIFTJIS",       "SJIS");
-        fIANA2JavaMap.put("MS_KANJI",       "SJIS");
-        fIANA2JavaMap.put("WINDOWS-31J",       "MS932");
-        fIANA2JavaMap.put("CSWINDOWS31J",       "MS932");
+        aIANA2JavaMap.put("X0201",  "JIS0201");
+        aIANA2JavaMap.put("CSISO13JISC6220JP", "JIS0201");
+        aIANA2JavaMap.put("X0208",  "JIS0208");
+        aIANA2JavaMap.put("ISO-IR-87",  "JIS0208");
+        aIANA2JavaMap.put("X0208dbiJIS_X0208-1983",  "JIS0208");
+        aIANA2JavaMap.put("CSISO87JISX0208",  "JIS0208");
+        aIANA2JavaMap.put("X0212",  "JIS0212");
+        aIANA2JavaMap.put("ISO-IR-159",  "JIS0212");
+        aIANA2JavaMap.put("CSISO159JISX02121990",  "JIS0212");
+        aIANA2JavaMap.put("GB18030",       "GB18030");
+        aIANA2JavaMap.put("GBK",       "GBK");
+        aIANA2JavaMap.put("CP936",       "GBK");
+        aIANA2JavaMap.put("MS936",       "GBK");
+        aIANA2JavaMap.put("WINDOWS-936",       "GBK");
+        aIANA2JavaMap.put("SHIFT_JIS",       "SJIS");
+        aIANA2JavaMap.put("CSSHIFTJIS",       "SJIS");
+        aIANA2JavaMap.put("MS_KANJI",       "SJIS");
+        aIANA2JavaMap.put("WINDOWS-31J",       "MS932");
+        aIANA2JavaMap.put("CSWINDOWS31J",       "MS932");
 
             // Add support for Cp1252 and its friends
-        fIANA2JavaMap.put("WINDOWS-1250",   "Cp1250");
-        fIANA2JavaMap.put("WINDOWS-1251",   "Cp1251");
-        fIANA2JavaMap.put("WINDOWS-1252",   "Cp1252");
-        fIANA2JavaMap.put("WINDOWS-1253",   "Cp1253");
-        fIANA2JavaMap.put("WINDOWS-1254",   "Cp1254");
-        fIANA2JavaMap.put("WINDOWS-1255",   "Cp1255");
-        fIANA2JavaMap.put("WINDOWS-1256",   "Cp1256");
-        fIANA2JavaMap.put("WINDOWS-1257",   "Cp1257");
-        fIANA2JavaMap.put("WINDOWS-1258",   "Cp1258");
-        fIANA2JavaMap.put("TIS-620",   "TIS620");
+        aIANA2JavaMap.put("WINDOWS-1250",   "Cp1250");
+        aIANA2JavaMap.put("WINDOWS-1251",   "Cp1251");
+        aIANA2JavaMap.put("WINDOWS-1252",   "Cp1252");
+        aIANA2JavaMap.put("WINDOWS-1253",   "Cp1253");
+        aIANA2JavaMap.put("WINDOWS-1254",   "Cp1254");
+        aIANA2JavaMap.put("WINDOWS-1255",   "Cp1255");
+        aIANA2JavaMap.put("WINDOWS-1256",   "Cp1256");
+        aIANA2JavaMap.put("WINDOWS-1257",   "Cp1257");
+        aIANA2JavaMap.put("WINDOWS-1258",   "Cp1258");
+        aIANA2JavaMap.put("TIS-620",   "TIS620");
 
-        fIANA2JavaMap.put("ISO-8859-1",      "ISO8859_1");
-        fIANA2JavaMap.put("ISO-IR-100",      "ISO8859_1");
-        fIANA2JavaMap.put("ISO_8859-1",      "ISO8859_1");
-        fIANA2JavaMap.put("LATIN1",      "ISO8859_1");
-        fIANA2JavaMap.put("CSISOLATIN1",      "ISO8859_1");
-        fIANA2JavaMap.put("L1",      "ISO8859_1");
-        fIANA2JavaMap.put("IBM819",      "ISO8859_1");
-        fIANA2JavaMap.put("CP819",      "ISO8859_1");
+        aIANA2JavaMap.put("ISO-8859-1",      "ISO8859_1");
+        aIANA2JavaMap.put("ISO-IR-100",      "ISO8859_1");
+        aIANA2JavaMap.put("ISO_8859-1",      "ISO8859_1");
+        aIANA2JavaMap.put("LATIN1",      "ISO8859_1");
+        aIANA2JavaMap.put("CSISOLATIN1",      "ISO8859_1");
+        aIANA2JavaMap.put("L1",      "ISO8859_1");
+        aIANA2JavaMap.put("IBM819",      "ISO8859_1");
+        aIANA2JavaMap.put("CP819",      "ISO8859_1");
 
-        fIANA2JavaMap.put("ISO-8859-2",      "ISO8859_2");
-        fIANA2JavaMap.put("ISO-IR-101",      "ISO8859_2");
-        fIANA2JavaMap.put("ISO_8859-2",      "ISO8859_2");
-        fIANA2JavaMap.put("LATIN2",      "ISO8859_2");
-        fIANA2JavaMap.put("CSISOLATIN2",      "ISO8859_2");
-        fIANA2JavaMap.put("L2",      "ISO8859_2");
+        aIANA2JavaMap.put("ISO-8859-2",      "ISO8859_2");
+        aIANA2JavaMap.put("ISO-IR-101",      "ISO8859_2");
+        aIANA2JavaMap.put("ISO_8859-2",      "ISO8859_2");
+        aIANA2JavaMap.put("LATIN2",      "ISO8859_2");
+        aIANA2JavaMap.put("CSISOLATIN2",      "ISO8859_2");
+        aIANA2JavaMap.put("L2",      "ISO8859_2");
 
-        fIANA2JavaMap.put("ISO-8859-3",      "ISO8859_3");
-        fIANA2JavaMap.put("ISO-IR-109",      "ISO8859_3");
-        fIANA2JavaMap.put("ISO_8859-3",      "ISO8859_3");
-        fIANA2JavaMap.put("LATIN3",      "ISO8859_3");
-        fIANA2JavaMap.put("CSISOLATIN3",      "ISO8859_3");
-        fIANA2JavaMap.put("L3",      "ISO8859_3");
+        aIANA2JavaMap.put("ISO-8859-3",      "ISO8859_3");
+        aIANA2JavaMap.put("ISO-IR-109",      "ISO8859_3");
+        aIANA2JavaMap.put("ISO_8859-3",      "ISO8859_3");
+        aIANA2JavaMap.put("LATIN3",      "ISO8859_3");
+        aIANA2JavaMap.put("CSISOLATIN3",      "ISO8859_3");
+        aIANA2JavaMap.put("L3",      "ISO8859_3");
 
-        fIANA2JavaMap.put("ISO-8859-4",      "ISO8859_4");
-        fIANA2JavaMap.put("ISO-IR-110",      "ISO8859_4");
-        fIANA2JavaMap.put("ISO_8859-4",      "ISO8859_4");
-        fIANA2JavaMap.put("LATIN4",      "ISO8859_4");
-        fIANA2JavaMap.put("CSISOLATIN4",      "ISO8859_4");
-        fIANA2JavaMap.put("L4",      "ISO8859_4");
+        aIANA2JavaMap.put("ISO-8859-4",      "ISO8859_4");
+        aIANA2JavaMap.put("ISO-IR-110",      "ISO8859_4");
+        aIANA2JavaMap.put("ISO_8859-4",      "ISO8859_4");
+        aIANA2JavaMap.put("LATIN4",      "ISO8859_4");
+        aIANA2JavaMap.put("CSISOLATIN4",      "ISO8859_4");
+        aIANA2JavaMap.put("L4",      "ISO8859_4");
 
-        fIANA2JavaMap.put("ISO-8859-5",      "ISO8859_5");
-        fIANA2JavaMap.put("ISO-IR-144",      "ISO8859_5");
-        fIANA2JavaMap.put("ISO_8859-5",      "ISO8859_5");
-        fIANA2JavaMap.put("CYRILLIC",      "ISO8859_5");
-        fIANA2JavaMap.put("CSISOLATINCYRILLIC",      "ISO8859_5");
+        aIANA2JavaMap.put("ISO-8859-5",      "ISO8859_5");
+        aIANA2JavaMap.put("ISO-IR-144",      "ISO8859_5");
+        aIANA2JavaMap.put("ISO_8859-5",      "ISO8859_5");
+        aIANA2JavaMap.put("CYRILLIC",      "ISO8859_5");
+        aIANA2JavaMap.put("CSISOLATINCYRILLIC",      "ISO8859_5");
 
-        fIANA2JavaMap.put("ISO-8859-6",      "ISO8859_6");
-        fIANA2JavaMap.put("ISO-IR-127",      "ISO8859_6");
-        fIANA2JavaMap.put("ISO_8859-6",      "ISO8859_6");
-        fIANA2JavaMap.put("ECMA-114",      "ISO8859_6");
-        fIANA2JavaMap.put("ASMO-708",      "ISO8859_6");
-        fIANA2JavaMap.put("ARABIC",      "ISO8859_6");
-        fIANA2JavaMap.put("CSISOLATINARABIC",      "ISO8859_6");
+        aIANA2JavaMap.put("ISO-8859-6",      "ISO8859_6");
+        aIANA2JavaMap.put("ISO-IR-127",      "ISO8859_6");
+        aIANA2JavaMap.put("ISO_8859-6",      "ISO8859_6");
+        aIANA2JavaMap.put("ECMA-114",      "ISO8859_6");
+        aIANA2JavaMap.put("ASMO-708",      "ISO8859_6");
+        aIANA2JavaMap.put("ARABIC",      "ISO8859_6");
+        aIANA2JavaMap.put("CSISOLATINARABIC",      "ISO8859_6");
 
-        fIANA2JavaMap.put("ISO-8859-7",      "ISO8859_7");
-        fIANA2JavaMap.put("ISO-IR-126",      "ISO8859_7");
-        fIANA2JavaMap.put("ISO_8859-7",      "ISO8859_7");
-        fIANA2JavaMap.put("ELOT_928",      "ISO8859_7");
-        fIANA2JavaMap.put("ECMA-118",      "ISO8859_7");
-        fIANA2JavaMap.put("GREEK",      "ISO8859_7");
-        fIANA2JavaMap.put("CSISOLATINGREEK",      "ISO8859_7");
-        fIANA2JavaMap.put("GREEK8",      "ISO8859_7");
+        aIANA2JavaMap.put("ISO-8859-7",      "ISO8859_7");
+        aIANA2JavaMap.put("ISO-IR-126",      "ISO8859_7");
+        aIANA2JavaMap.put("ISO_8859-7",      "ISO8859_7");
+        aIANA2JavaMap.put("ELOT_928",      "ISO8859_7");
+        aIANA2JavaMap.put("ECMA-118",      "ISO8859_7");
+        aIANA2JavaMap.put("GREEK",      "ISO8859_7");
+        aIANA2JavaMap.put("CSISOLATINGREEK",      "ISO8859_7");
+        aIANA2JavaMap.put("GREEK8",      "ISO8859_7");
 
-        fIANA2JavaMap.put("ISO-8859-8",      "ISO8859_8");
-        fIANA2JavaMap.put("ISO-8859-8-I",      "ISO8859_8"); // added since this encoding only differs w.r.t. presentation
-        fIANA2JavaMap.put("ISO-IR-138",      "ISO8859_8");
-        fIANA2JavaMap.put("ISO_8859-8",      "ISO8859_8");
-        fIANA2JavaMap.put("HEBREW",      "ISO8859_8");
-        fIANA2JavaMap.put("CSISOLATINHEBREW",      "ISO8859_8");
+        aIANA2JavaMap.put("ISO-8859-8",      "ISO8859_8");
+        aIANA2JavaMap.put("ISO-8859-8-I",      "ISO8859_8"); // added since this encoding only differs w.r.t. presentation
+        aIANA2JavaMap.put("ISO-IR-138",      "ISO8859_8");
+        aIANA2JavaMap.put("ISO_8859-8",      "ISO8859_8");
+        aIANA2JavaMap.put("HEBREW",      "ISO8859_8");
+        aIANA2JavaMap.put("CSISOLATINHEBREW",      "ISO8859_8");
 
-        fIANA2JavaMap.put("ISO-8859-9",      "ISO8859_9");
-        fIANA2JavaMap.put("ISO-IR-148",      "ISO8859_9");
-        fIANA2JavaMap.put("ISO_8859-9",      "ISO8859_9");
-        fIANA2JavaMap.put("LATIN5",      "ISO8859_9");
-        fIANA2JavaMap.put("CSISOLATIN5",      "ISO8859_9");
-        fIANA2JavaMap.put("L5",      "ISO8859_9");
+        aIANA2JavaMap.put("ISO-8859-9",      "ISO8859_9");
+        aIANA2JavaMap.put("ISO-IR-148",      "ISO8859_9");
+        aIANA2JavaMap.put("ISO_8859-9",      "ISO8859_9");
+        aIANA2JavaMap.put("LATIN5",      "ISO8859_9");
+        aIANA2JavaMap.put("CSISOLATIN5",      "ISO8859_9");
+        aIANA2JavaMap.put("L5",      "ISO8859_9");
 
-        fIANA2JavaMap.put("ISO-8859-13",      "ISO8859_13");
+        aIANA2JavaMap.put("ISO-8859-13",      "ISO8859_13");
 
-        fIANA2JavaMap.put("ISO-8859-15",      "ISO8859_15_FDIS");
-        fIANA2JavaMap.put("ISO_8859-15",      "ISO8859_15_FDIS");
-        fIANA2JavaMap.put("LATIN-9",          "ISO8859_15_FDIS");
+        aIANA2JavaMap.put("ISO-8859-15",      "ISO8859_15_FDIS");
+        aIANA2JavaMap.put("ISO_8859-15",      "ISO8859_15_FDIS");
+        aIANA2JavaMap.put("LATIN-9",          "ISO8859_15_FDIS");
 
-        fIANA2JavaMap.put("KOI8-R",          "KOI8_R");
-        fIANA2JavaMap.put("CSKOI8R",          "KOI8_R");
-        fIANA2JavaMap.put("US-ASCII",        "ASCII");
-        fIANA2JavaMap.put("ISO-IR-6",        "ASCII");
-        fIANA2JavaMap.put("ANSI_X3.4-1968",        "ASCII");
-        fIANA2JavaMap.put("ANSI_X3.4-1986",        "ASCII");
-        fIANA2JavaMap.put("ISO_646.IRV:1991",        "ASCII");
-        fIANA2JavaMap.put("ASCII",        "ASCII");
-        fIANA2JavaMap.put("CSASCII",        "ASCII");
-        fIANA2JavaMap.put("ISO646-US",        "ASCII");
-        fIANA2JavaMap.put("US",        "ASCII");
-        fIANA2JavaMap.put("IBM367",        "ASCII");
-        fIANA2JavaMap.put("CP367",        "ASCII");
-        fIANA2JavaMap.put("UTF-8",           "UTF8");
-        fIANA2JavaMap.put("UTF-16",           "UTF-16");
-        fIANA2JavaMap.put("UTF-16BE",           "UnicodeBig");
-        fIANA2JavaMap.put("UTF-16LE",           "UnicodeLittle");
+        aIANA2JavaMap.put("KOI8-R",          "KOI8_R");
+        aIANA2JavaMap.put("CSKOI8R",          "KOI8_R");
+        aIANA2JavaMap.put("US-ASCII",        "ASCII");
+        aIANA2JavaMap.put("ISO-IR-6",        "ASCII");
+        aIANA2JavaMap.put("ANSI_X3.4-1968",        "ASCII");
+        aIANA2JavaMap.put("ANSI_X3.4-1986",        "ASCII");
+        aIANA2JavaMap.put("ISO_646.IRV:1991",        "ASCII");
+        aIANA2JavaMap.put("ASCII",        "ASCII");
+        aIANA2JavaMap.put("CSASCII",        "ASCII");
+        aIANA2JavaMap.put("ISO646-US",        "ASCII");
+        aIANA2JavaMap.put("US",        "ASCII");
+        aIANA2JavaMap.put("IBM367",        "ASCII");
+        aIANA2JavaMap.put("CP367",        "ASCII");
+        aIANA2JavaMap.put("UTF-8",           "UTF8");
+        aIANA2JavaMap.put("UTF-16",           "UTF-16");
+        aIANA2JavaMap.put("UTF-16BE",           "UnicodeBig");
+        aIANA2JavaMap.put("UTF-16LE",           "UnicodeLittle");
 
         // support for 1047, as proposed to be added to the
         // IANA registry in
         // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0049.html
-        fIANA2JavaMap.put("IBM-1047",    "Cp1047");
-        fIANA2JavaMap.put("IBM1047",    "Cp1047");
-        fIANA2JavaMap.put("CP1047",    "Cp1047");
+        aIANA2JavaMap.put("IBM-1047",    "Cp1047");
+        aIANA2JavaMap.put("IBM1047",    "Cp1047");
+        aIANA2JavaMap.put("CP1047",    "Cp1047");
 
         // Adding new aliases as proposed in
         // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0058.html
-        fIANA2JavaMap.put("IBM-37",    "CP037");
-        fIANA2JavaMap.put("IBM-273",    "CP273");
-        fIANA2JavaMap.put("IBM-277",    "CP277");
-        fIANA2JavaMap.put("IBM-278",    "CP278");
-        fIANA2JavaMap.put("IBM-280",    "CP280");
-        fIANA2JavaMap.put("IBM-284",    "CP284");
-        fIANA2JavaMap.put("IBM-285",    "CP285");
-        fIANA2JavaMap.put("IBM-290",    "CP290");
-        fIANA2JavaMap.put("IBM-297",    "CP297");
-        fIANA2JavaMap.put("IBM-420",    "CP420");
-        fIANA2JavaMap.put("IBM-424",    "CP424");
-        fIANA2JavaMap.put("IBM-437",    "CP437");
-        fIANA2JavaMap.put("IBM-500",    "CP500");
-        fIANA2JavaMap.put("IBM-775",    "CP775");
-        fIANA2JavaMap.put("IBM-850",    "CP850");
-        fIANA2JavaMap.put("IBM-852",    "CP852");
-        fIANA2JavaMap.put("IBM-855",    "CP855");
-        fIANA2JavaMap.put("IBM-857",    "CP857");
-        fIANA2JavaMap.put("IBM-858",    "CP858");
-        fIANA2JavaMap.put("IBM-860",    "CP860");
-        fIANA2JavaMap.put("IBM-861",    "CP861");
-        fIANA2JavaMap.put("IBM-862",    "CP862");
-        fIANA2JavaMap.put("IBM-863",    "CP863");
-        fIANA2JavaMap.put("IBM-864",    "CP864");
-        fIANA2JavaMap.put("IBM-865",    "CP865");
-        fIANA2JavaMap.put("IBM-866",    "CP866");
-        fIANA2JavaMap.put("IBM-868",    "CP868");
-        fIANA2JavaMap.put("IBM-869",    "CP869");
-        fIANA2JavaMap.put("IBM-870",    "CP870");
-        fIANA2JavaMap.put("IBM-871",    "CP871");
-        fIANA2JavaMap.put("IBM-918",    "CP918");
-        fIANA2JavaMap.put("IBM-924",    "CP924");
-        fIANA2JavaMap.put("IBM-1026",    "CP1026");
-        fIANA2JavaMap.put("IBM-1140",    "Cp1140");
-        fIANA2JavaMap.put("IBM-1141",    "Cp1141");
-        fIANA2JavaMap.put("IBM-1142",    "Cp1142");
-        fIANA2JavaMap.put("IBM-1143",    "Cp1143");
-        fIANA2JavaMap.put("IBM-1144",    "Cp1144");
-        fIANA2JavaMap.put("IBM-1145",    "Cp1145");
-        fIANA2JavaMap.put("IBM-1146",    "Cp1146");
-        fIANA2JavaMap.put("IBM-1147",    "Cp1147");
-        fIANA2JavaMap.put("IBM-1148",    "Cp1148");
-        fIANA2JavaMap.put("IBM-1149",    "Cp1149");
-        fIANA2JavaMap.put("IBM-819",      "ISO8859_1");
-        fIANA2JavaMap.put("IBM-367",        "ASCII");
+        aIANA2JavaMap.put("IBM-37",    "CP037");
+        aIANA2JavaMap.put("IBM-273",    "CP273");
+        aIANA2JavaMap.put("IBM-277",    "CP277");
+        aIANA2JavaMap.put("IBM-278",    "CP278");
+        aIANA2JavaMap.put("IBM-280",    "CP280");
+        aIANA2JavaMap.put("IBM-284",    "CP284");
+        aIANA2JavaMap.put("IBM-285",    "CP285");
+        aIANA2JavaMap.put("IBM-290",    "CP290");
+        aIANA2JavaMap.put("IBM-297",    "CP297");
+        aIANA2JavaMap.put("IBM-420",    "CP420");
+        aIANA2JavaMap.put("IBM-424",    "CP424");
+        aIANA2JavaMap.put("IBM-437",    "CP437");
+        aIANA2JavaMap.put("IBM-500",    "CP500");
+        aIANA2JavaMap.put("IBM-775",    "CP775");
+        aIANA2JavaMap.put("IBM-850",    "CP850");
+        aIANA2JavaMap.put("IBM-852",    "CP852");
+        aIANA2JavaMap.put("IBM-855",    "CP855");
+        aIANA2JavaMap.put("IBM-857",    "CP857");
+        aIANA2JavaMap.put("IBM-858",    "CP858");
+        aIANA2JavaMap.put("IBM-860",    "CP860");
+        aIANA2JavaMap.put("IBM-861",    "CP861");
+        aIANA2JavaMap.put("IBM-862",    "CP862");
+        aIANA2JavaMap.put("IBM-863",    "CP863");
+        aIANA2JavaMap.put("IBM-864",    "CP864");
+        aIANA2JavaMap.put("IBM-865",    "CP865");
+        aIANA2JavaMap.put("IBM-866",    "CP866");
+        aIANA2JavaMap.put("IBM-868",    "CP868");
+        aIANA2JavaMap.put("IBM-869",    "CP869");
+        aIANA2JavaMap.put("IBM-870",    "CP870");
+        aIANA2JavaMap.put("IBM-871",    "CP871");
+        aIANA2JavaMap.put("IBM-918",    "CP918");
+        aIANA2JavaMap.put("IBM-924",    "CP924");
+        aIANA2JavaMap.put("IBM-1026",    "CP1026");
+        aIANA2JavaMap.put("IBM-1140",    "Cp1140");
+        aIANA2JavaMap.put("IBM-1141",    "Cp1141");
+        aIANA2JavaMap.put("IBM-1142",    "Cp1142");
+        aIANA2JavaMap.put("IBM-1143",    "Cp1143");
+        aIANA2JavaMap.put("IBM-1144",    "Cp1144");
+        aIANA2JavaMap.put("IBM-1145",    "Cp1145");
+        aIANA2JavaMap.put("IBM-1146",    "Cp1146");
+        aIANA2JavaMap.put("IBM-1147",    "Cp1147");
+        aIANA2JavaMap.put("IBM-1148",    "Cp1148");
+        aIANA2JavaMap.put("IBM-1149",    "Cp1149");
+        aIANA2JavaMap.put("IBM-819",      "ISO8859_1");
+        aIANA2JavaMap.put("IBM-367",        "ASCII");
 
+        fIANA2JavaMap = Collections.unmodifiableMap(aIANA2JavaMap);
         // REVISIT:
         //   j:CNS11643 -> EUC-TW?
         //   ISO-2022-CN? ISO-2022-CN-EXT?
 
         // add Java to IANA encoding mappings
-        //fJava2IANAMap.put("8859_1",    "US-ASCII"); // ?
-        fJava2IANAMap.put("ISO8859_1",    "ISO-8859-1");
-        fJava2IANAMap.put("ISO8859_2",    "ISO-8859-2");
-        fJava2IANAMap.put("ISO8859_3",    "ISO-8859-3");
-        fJava2IANAMap.put("ISO8859_4",    "ISO-8859-4");
-        fJava2IANAMap.put("ISO8859_5",    "ISO-8859-5");
-        fJava2IANAMap.put("ISO8859_6",    "ISO-8859-6");
-        fJava2IANAMap.put("ISO8859_7",    "ISO-8859-7");
-        fJava2IANAMap.put("ISO8859_8",    "ISO-8859-8");
-        fJava2IANAMap.put("ISO8859_9",    "ISO-8859-9");
-        fJava2IANAMap.put("ISO8859_13",    "ISO-8859-13");
-        fJava2IANAMap.put("ISO8859_15",    "ISO-8859-15");
-        fJava2IANAMap.put("ISO8859_15_FDIS",    "ISO-8859-15");
-        fJava2IANAMap.put("Big5",      "BIG5");
-        fJava2IANAMap.put("CP037",     "EBCDIC-CP-US");
-        fJava2IANAMap.put("CP273",     "IBM273");
-        fJava2IANAMap.put("CP277",     "EBCDIC-CP-DK");
-        fJava2IANAMap.put("CP278",     "EBCDIC-CP-FI");
-        fJava2IANAMap.put("CP280",     "EBCDIC-CP-IT");
-        fJava2IANAMap.put("CP284",     "EBCDIC-CP-ES");
-        fJava2IANAMap.put("CP285",     "EBCDIC-CP-GB");
-        fJava2IANAMap.put("CP290",     "EBCDIC-JP-KANA");
-        fJava2IANAMap.put("CP297",     "EBCDIC-CP-FR");
-        fJava2IANAMap.put("CP420",     "EBCDIC-CP-AR1");
-        fJava2IANAMap.put("CP424",     "EBCDIC-CP-HE");
-        fJava2IANAMap.put("CP437",     "IBM437");
-        fJava2IANAMap.put("CP500",     "EBCDIC-CP-CH");
-        fJava2IANAMap.put("CP775",     "IBM775");
-        fJava2IANAMap.put("CP850",     "IBM850");
-        fJava2IANAMap.put("CP852",     "IBM852");
-        fJava2IANAMap.put("CP855",     "IBM855");
-        fJava2IANAMap.put("CP857",     "IBM857");
-        fJava2IANAMap.put("CP858",     "IBM00858");
-        fJava2IANAMap.put("CP860",     "IBM860");
-        fJava2IANAMap.put("CP861",     "IBM861");
-        fJava2IANAMap.put("CP862",     "IBM862");
-        fJava2IANAMap.put("CP863",     "IBM863");
-        fJava2IANAMap.put("CP864",     "IBM864");
-        fJava2IANAMap.put("CP865",     "IBM865");
-        fJava2IANAMap.put("CP866",     "IBM866");
-        fJava2IANAMap.put("CP868",     "IBM868");
-        fJava2IANAMap.put("CP869",     "IBM869");
-        fJava2IANAMap.put("CP870",     "EBCDIC-CP-ROECE");
-        fJava2IANAMap.put("CP871",     "EBCDIC-CP-IS");
-        fJava2IANAMap.put("CP918",     "EBCDIC-CP-AR2");
-        fJava2IANAMap.put("CP924",     "IBM00924");
-        fJava2IANAMap.put("CP1026",     "IBM1026");
-        fJava2IANAMap.put("Cp01140",     "IBM01140");
-        fJava2IANAMap.put("Cp01141",     "IBM01141");
-        fJava2IANAMap.put("Cp01142",     "IBM01142");
-        fJava2IANAMap.put("Cp01143",     "IBM01143");
-        fJava2IANAMap.put("Cp01144",     "IBM01144");
-        fJava2IANAMap.put("Cp01145",     "IBM01145");
-        fJava2IANAMap.put("Cp01146",     "IBM01146");
-        fJava2IANAMap.put("Cp01147",     "IBM01147");
-        fJava2IANAMap.put("Cp01148",     "IBM01148");
-        fJava2IANAMap.put("Cp01149",     "IBM01149");
-        fJava2IANAMap.put("EUCJIS",    "EUC-JP");
-        fJava2IANAMap.put("KS_C_5601-1987",          "KS_C_5601-1987");
-        fJava2IANAMap.put("GB2312",    "GB2312");
-        fJava2IANAMap.put("ISO2022KR", "ISO-2022-KR");
-        fJava2IANAMap.put("ISO2022CN", "ISO-2022-CN");
-        fJava2IANAMap.put("JIS",       "ISO-2022-JP");
-        fJava2IANAMap.put("KOI8_R",    "KOI8-R");
-        fJava2IANAMap.put("KSC5601",   "EUC-KR");
-        fJava2IANAMap.put("GB18030",      "GB18030");
-        fJava2IANAMap.put("GBK",       "GBK");
-        fJava2IANAMap.put("SJIS",      "SHIFT_JIS");
-        fJava2IANAMap.put("MS932",      "WINDOWS-31J");
-        fJava2IANAMap.put("UTF8",      "UTF-8");
-        fJava2IANAMap.put("Unicode",   "UTF-16");
-        fJava2IANAMap.put("UnicodeBig",   "UTF-16BE");
-        fJava2IANAMap.put("UnicodeLittle",   "UTF-16LE");
-        fJava2IANAMap.put("JIS0201",  "X0201");
-        fJava2IANAMap.put("JIS0208",  "X0208");
-        fJava2IANAMap.put("JIS0212",  "ISO-IR-159");
+        //aJava2IANAMap.put("8859_1",    "US-ASCII"); // ?
+        aJava2IANAMap.put("ISO8859_1",    "ISO-8859-1");
+        aJava2IANAMap.put("ISO8859_2",    "ISO-8859-2");
+        aJava2IANAMap.put("ISO8859_3",    "ISO-8859-3");
+        aJava2IANAMap.put("ISO8859_4",    "ISO-8859-4");
+        aJava2IANAMap.put("ISO8859_5",    "ISO-8859-5");
+        aJava2IANAMap.put("ISO8859_6",    "ISO-8859-6");
+        aJava2IANAMap.put("ISO8859_7",    "ISO-8859-7");
+        aJava2IANAMap.put("ISO8859_8",    "ISO-8859-8");
+        aJava2IANAMap.put("ISO8859_9",    "ISO-8859-9");
+        aJava2IANAMap.put("ISO8859_13",    "ISO-8859-13");
+        aJava2IANAMap.put("ISO8859_15",    "ISO-8859-15");
+        aJava2IANAMap.put("ISO8859_15_FDIS",    "ISO-8859-15");
+        aJava2IANAMap.put("Big5",      "BIG5");
+        aJava2IANAMap.put("CP037",     "EBCDIC-CP-US");
+        aJava2IANAMap.put("CP273",     "IBM273");
+        aJava2IANAMap.put("CP277",     "EBCDIC-CP-DK");
+        aJava2IANAMap.put("CP278",     "EBCDIC-CP-FI");
+        aJava2IANAMap.put("CP280",     "EBCDIC-CP-IT");
+        aJava2IANAMap.put("CP284",     "EBCDIC-CP-ES");
+        aJava2IANAMap.put("CP285",     "EBCDIC-CP-GB");
+        aJava2IANAMap.put("CP290",     "EBCDIC-JP-KANA");
+        aJava2IANAMap.put("CP297",     "EBCDIC-CP-FR");
+        aJava2IANAMap.put("CP420",     "EBCDIC-CP-AR1");
+        aJava2IANAMap.put("CP424",     "EBCDIC-CP-HE");
+        aJava2IANAMap.put("CP437",     "IBM437");
+        aJava2IANAMap.put("CP500",     "EBCDIC-CP-CH");
+        aJava2IANAMap.put("CP775",     "IBM775");
+        aJava2IANAMap.put("CP850",     "IBM850");
+        aJava2IANAMap.put("CP852",     "IBM852");
+        aJava2IANAMap.put("CP855",     "IBM855");
+        aJava2IANAMap.put("CP857",     "IBM857");
+        aJava2IANAMap.put("CP858",     "IBM00858");
+        aJava2IANAMap.put("CP860",     "IBM860");
+        aJava2IANAMap.put("CP861",     "IBM861");
+        aJava2IANAMap.put("CP862",     "IBM862");
+        aJava2IANAMap.put("CP863",     "IBM863");
+        aJava2IANAMap.put("CP864",     "IBM864");
+        aJava2IANAMap.put("CP865",     "IBM865");
+        aJava2IANAMap.put("CP866",     "IBM866");
+        aJava2IANAMap.put("CP868",     "IBM868");
+        aJava2IANAMap.put("CP869",     "IBM869");
+        aJava2IANAMap.put("CP870",     "EBCDIC-CP-ROECE");
+        aJava2IANAMap.put("CP871",     "EBCDIC-CP-IS");
+        aJava2IANAMap.put("CP918",     "EBCDIC-CP-AR2");
+        aJava2IANAMap.put("CP924",     "IBM00924");
+        aJava2IANAMap.put("CP1026",     "IBM1026");
+        aJava2IANAMap.put("CP1140",     "IBM01140");
+        aJava2IANAMap.put("CP1141",     "IBM01141");
+        aJava2IANAMap.put("CP1142",     "IBM01142");
+        aJava2IANAMap.put("CP1143",     "IBM01143");
+        aJava2IANAMap.put("CP1144",     "IBM01144");
+        aJava2IANAMap.put("CP1145",     "IBM01145");
+        aJava2IANAMap.put("CP1146",     "IBM01146");
+        aJava2IANAMap.put("CP1147",     "IBM01147");
+        aJava2IANAMap.put("CP1148",     "IBM01148");
+        aJava2IANAMap.put("CP1149",     "IBM01149");
+        aJava2IANAMap.put("EUCJIS",    "EUC-JP");
+        aJava2IANAMap.put("KS_C_5601-1987",          "KS_C_5601-1987");
+        aJava2IANAMap.put("GB2312",    "GB2312");
+        aJava2IANAMap.put("ISO2022KR", "ISO-2022-KR");
+        aJava2IANAMap.put("ISO2022CN", "ISO-2022-CN");
+        aJava2IANAMap.put("JIS",       "ISO-2022-JP");
+        aJava2IANAMap.put("KOI8_R",    "KOI8-R");
+        aJava2IANAMap.put("KSC5601",   "EUC-KR");
+        aJava2IANAMap.put("GB18030",      "GB18030");
+        aJava2IANAMap.put("GBK",       "GBK");
+        aJava2IANAMap.put("SJIS",      "SHIFT_JIS");
+        aJava2IANAMap.put("MS932",      "WINDOWS-31J");
+        aJava2IANAMap.put("UTF8",      "UTF-8");
+        aJava2IANAMap.put("Unicode",   "UTF-16");
+        aJava2IANAMap.put("UnicodeBig",   "UTF-16BE");
+        aJava2IANAMap.put("UnicodeLittle",   "UTF-16LE");
+        aJava2IANAMap.put("JIS0201",  "X0201");
+        aJava2IANAMap.put("JIS0208",  "X0208");
+        aJava2IANAMap.put("JIS0212",  "ISO-IR-159");
 
         // proposed addition (see above for details):
-        fJava2IANAMap.put("CP1047",    "IBM1047");
+        aJava2IANAMap.put("CP1047",    "IBM1047");
 
+        fJava2IANAMap = Collections.unmodifiableMap(aIANA2JavaMap);
     } // <clinit>()
 
     //
@@ -954,77 +960,22 @@
     //
 
     /**
-     * Adds an IANA to Java encoding name mapping.
-     *
-     * @param ianaEncoding The IANA encoding name.
-     * @param javaEncoding The Java encoding name.
-     *
-     * @deprecated Use of this method is not recommended. Its
-     * effect is JVM wide and may cause unforeseen behaviour
-     * for other applications running in the system.
-     */
-    public static void putIANA2JavaMapping(String ianaEncoding,
-                                           String javaEncoding) {
-        fIANA2JavaMap.put(ianaEncoding, javaEncoding);
-    } // putIANA2JavaMapping(String,String)
-
-    /**
      * Returns the Java encoding name for the specified IANA encoding name.
      *
      * @param ianaEncoding The IANA encoding name.
      */
     public static String getIANA2JavaMapping(String ianaEncoding) {
-        return (String)fIANA2JavaMap.get(ianaEncoding);
+        return fIANA2JavaMap.get(ianaEncoding);
     } // getIANA2JavaMapping(String):String
 
     /**
-     * Removes an IANA to Java encoding name mapping.
-     *
-     * @param ianaEncoding The IANA encoding name.
-     *
-     * @deprecated Use of this method is not recommended. Its
-     * effect is JVM wide and may cause unforeseen behaviour
-     * for other applications running in the system.
-     */
-    public static String removeIANA2JavaMapping(String ianaEncoding) {
-        return (String)fIANA2JavaMap.remove(ianaEncoding);
-    } // removeIANA2JavaMapping(String):String
-
-    /**
-     * Adds a Java to IANA encoding name mapping.
-     *
-     * @param javaEncoding The Java encoding name.
-     * @param ianaEncoding The IANA encoding name.
-     *
-     * @deprecated Use of this method is not recommended. Its
-     * effect is JVM wide and may cause unforeseen behaviour
-     * for other applications running in the system.
-     */
-    public static void putJava2IANAMapping(String javaEncoding,
-                                           String ianaEncoding) {
-        fJava2IANAMap.put(javaEncoding, ianaEncoding);
-    } // putJava2IANAMapping(String,String)
-
-    /**
      * Returns the IANA encoding name for the specified Java encoding name.
      *
      * @param javaEncoding The Java encoding name.
      */
     public static String getJava2IANAMapping(String javaEncoding) {
-        return (String)fJava2IANAMap.get(javaEncoding);
+        return fJava2IANAMap.get(javaEncoding);
     } // getJava2IANAMapping(String):String
 
-    /**
-     * Removes a Java to IANA encoding name mapping.
-     *
-     * @param javaEncoding The Java encoding name.
-     *
-     * @deprecated Use of this method is not recommended. Its
-     * effect is JVM wide and may cause unforeseen behaviour
-     * for other applications running in the system.
-     */
-    public static String removeJava2IANAMapping(String javaEncoding) {
-        return (String)fJava2IANAMap.remove(javaEncoding);
-    } // removeJava2IANAMapping
 
 } // class EncodingMap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/sun/org/apache/xerces/internal/util/PrimeNumberSequenceGenerator.java	Wed Sep 07 06:06:32 2016 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.org.apache.xerces.internal.util;
+
+import java.util.Random;
+
+ /**
+ * Fills an array with a random sequence of prime numbers.
+  */
+final class PrimeNumberSequenceGenerator {
+
+    private static final int [] PRIMES = {
+        3,   5,   7,  11,  13,  17,  19,  23,  29,  31,  37,  41,  43,  47,  53,  59,
+       61,  67,  71,  73,  79,  83,  89,  97, 101, 103, 107, 109, 113, 127, 131, 137,
+      139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
+      229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
+      317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
+      421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
+      521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617,
+      619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727};
+
+    static void generateSequence(int[] arrayToFill) {
+        Random r = new Random();
+        for (int i = 0; i < arrayToFill.length; i++) {
+            arrayToFill[i] = PRIMES[r.nextInt(PRIMES.length)];
+        }
+    }
+}
--- a/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -37,25 +37,40 @@
     //
 
     /** Default table size. */
-    protected int fTableSize = 101;
+    protected static final int TABLE_SIZE = 101;
+
+    /** Maximum hash collisions per bucket. */
+    protected static final int MAX_HASH_COLLISIONS = 40;
+
+    protected static final int MULTIPLIERS_SIZE = 1 << 5;
+    protected static final int MULTIPLIERS_MASK = MULTIPLIERS_SIZE - 1;
 
     //
     // Data
     //
 
+    /** Actual table size **/
+    protected int fTableSize;
+
     /** Buckets. */
     protected Entry[] fBuckets;
 
     /** Number of elements. */
     protected int fNum = 0;
 
+    /**
+     * Array of randomly selected hash function multipliers or <code>null</code>
+     * if the default String.hashCode() function should be used.
+     */
+    protected int[] fHashMultipliers;
+
     //
     // Constructors
     //
 
     /** Constructs a key table with the default size. */
     public SymbolHash() {
-        fBuckets = new Entry[fTableSize];
+        this(TABLE_SIZE);
     }
 
     /**
@@ -81,19 +96,37 @@
      * @param value
      */
     public void put(Object key, Object value) {
-        int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
-        Entry entry = search(key, bucket);
 
-        // replace old value
-        if (entry != null) {
-            entry.value = value;
+        // search for identical key
+        int collisionCount = 0;
+        final int hash = hash(key);
+        int bucket = hash % fTableSize;
+        for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+            if (key.equals(entry.key)) {
+                // replace old value
+                entry.value = value;
+                return;
+            }
+            ++collisionCount;
         }
+
+        if (fNum >= fTableSize) {
+            // Rehash the table if the number of entries
+            // would exceed the number of buckets.
+            rehash();
+            bucket = hash % fTableSize;
+        }
+        else if (collisionCount >= MAX_HASH_COLLISIONS && key instanceof String) {
+            // Select a new hash function and rehash the table if
+            // MAX_HASH_COLLISIONS is exceeded.
+            rebalance();
+            bucket = hash(key) % fTableSize;
+        }
+
         // create new entry
-        else {
-            entry = new Entry(key, value, fBuckets[bucket]);
-            fBuckets[bucket] = entry;
-            fNum++;
-        }
+        Entry entry = new Entry(key, value, fBuckets[bucket]);
+        fBuckets[bucket] = entry;
+        ++fNum;
     }
 
     /**
@@ -103,7 +136,7 @@
      * @return the value associated with the given key.
      */
     public Object get(Object key) {
-        int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
+        int bucket = hash(key) % fTableSize;
         Entry entry = search(key, bucket);
         if (entry != null) {
             return entry.value;
@@ -158,15 +191,17 @@
     public SymbolHash makeClone() {
         SymbolHash newTable = new SymbolHash(fTableSize);
         newTable.fNum = fNum;
+        newTable.fHashMultipliers = fHashMultipliers != null ? (int[]) fHashMultipliers.clone() : null;
         for (int i = 0; i < fTableSize; i++) {
-            if (fBuckets[i] != null)
+            if (fBuckets[i] != null) {
                 newTable.fBuckets[i] = fBuckets[i].makeClone();
+            }
         }
         return newTable;
     }
 
     /**
-     * Remove all key/value assocaition. This tries to save a bit of GC'ing
+     * Remove all key/value association. This tries to save a bit of GC'ing
      * by at least keeping the fBuckets array around.
      */
     public void clear() {
@@ -174,6 +209,7 @@
             fBuckets[i] = null;
         }
         fNum = 0;
+        fHashMultipliers = null;
     } // clear():  void
 
     protected Entry search(Object key, int bucket) {
@@ -185,6 +221,74 @@
         return null;
     }
 
+    /**
+     * Returns a hashcode value for the specified key.
+     *
+     * @param key The key to hash.
+     */
+    protected int hash(Object key) {
+        if (fHashMultipliers == null || !(key instanceof String)) {
+            return key.hashCode() & 0x7FFFFFFF;
+        }
+        return hash0((String) key);
+    } // hash(Object):int
+
+    private int hash0(String symbol) {
+        int code = 0;
+        final int length = symbol.length();
+        final int[] multipliers = fHashMultipliers;
+        for (int i = 0; i < length; ++i) {
+            code = code * multipliers[i & MULTIPLIERS_MASK] + symbol.charAt(i);
+        }
+        return code & 0x7FFFFFFF;
+    } // hash0(String):int
+
+    /**
+     * Increases the capacity of and internally reorganizes this
+     * SymbolHash, in order to accommodate and access its entries more
+     * efficiently.  This method is called automatically when the
+     * number of keys in the SymbolHash exceeds its number of buckets.
+     */
+    protected void rehash() {
+        rehashCommon((fBuckets.length << 1) + 1);
+    }
+
+    /**
+     * Randomly selects a new hash function and reorganizes this SymbolHash
+     * in order to more evenly distribute its entries across the table. This
+     * method is called automatically when the number keys in one of the
+     * SymbolHash's buckets exceeds MAX_HASH_COLLISIONS.
+     */
+    protected void rebalance() {
+        if (fHashMultipliers == null) {
+            fHashMultipliers = new int[MULTIPLIERS_SIZE];
+        }
+        PrimeNumberSequenceGenerator.generateSequence(fHashMultipliers);
+        rehashCommon(fBuckets.length);
+    }
+
+    private void rehashCommon(final int newCapacity) {
+
+        final int oldCapacity = fBuckets.length;
+        final Entry[] oldTable = fBuckets;
+
+        final Entry[] newTable = new Entry[newCapacity];
+
+        fBuckets = newTable;
+        fTableSize = fBuckets.length;
+
+        for (int i = oldCapacity; i-- > 0;) {
+            for (Entry old = oldTable[i]; old != null; ) {
+                Entry e = old;
+                old = old.next;
+
+                int index = hash(e.key) % newCapacity;
+                e.next = newTable[index];
+                newTable[index] = e;
+            }
+        }
+    }
+
     //
     // Classes
     //
--- a/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -55,28 +55,99 @@
     //
 
     /** Default table size. */
-    protected static final int TABLE_SIZE = 173;
+    protected static final int TABLE_SIZE = 101;
+
+    /** Maximum hash collisions per bucket for a table with load factor == 1. */
+    protected static final int MAX_HASH_COLLISIONS = 40;
 
+    protected static final int MULTIPLIERS_SIZE = 1 << 5;
+    protected static final int MULTIPLIERS_MASK = MULTIPLIERS_SIZE - 1;
+
+    //
+    // Data
+    //
 
     /** Buckets. */
     protected Entry[] fBuckets = null;
 
-    // actual table size
+    /** actual table size */
     protected int fTableSize;
 
+    /** The total number of entries in the hash table. */
+    protected transient int fCount;
+
+    /** The table is rehashed when its size exceeds this threshold.  (The
+     * value of this field is (int)(capacity * loadFactor).) */
+    protected int fThreshold;
+
+    /** The load factor for the SymbolTable. */
+    protected float fLoadFactor;
+
+    /**
+     * A new hash function is selected and the table is rehashed when
+     * the number of keys in the bucket exceeds this threshold.
+     */
+    protected final int fCollisionThreshold;
+
+    /**
+     * Array of randomly selected hash function multipliers or <code>null</code>
+     * if the default String.hashCode() function should be used.
+     */
+    protected int[] fHashMultipliers;
+
     //
     // Constructors
     //
 
-    /** Constructs a symbol table with a default number of buckets. */
-    public SymbolTable() {
-        this(TABLE_SIZE);
+    /**
+     * Constructs a new, empty SymbolTable with the specified initial
+     * capacity and the specified load factor.
+     *
+     * @param      initialCapacity   the initial capacity of the SymbolTable.
+     * @param      loadFactor        the load factor of the SymbolTable.
+     * @throws     IllegalArgumentException  if the initial capacity is less
+     *             than zero, or if the load factor is nonpositive.
+     */
+    public SymbolTable(int initialCapacity, float loadFactor) {
+
+        if (initialCapacity < 0) {
+            throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity);
+        }
+
+        if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
+            throw new IllegalArgumentException("Illegal Load: " + loadFactor);
+        }
+
+        if (initialCapacity == 0) {
+            initialCapacity = 1;
+        }
+
+        fLoadFactor = loadFactor;
+        fTableSize = initialCapacity;
+        fBuckets = new Entry[fTableSize];
+        fThreshold = (int)(fTableSize * loadFactor);
+        fCollisionThreshold = (int)(MAX_HASH_COLLISIONS * loadFactor);
+        fCount = 0;
     }
 
-    /** Constructs a symbol table with a specified number of buckets. */
-    public SymbolTable(int tableSize) {
-        fTableSize = tableSize;
-        fBuckets = new Entry[fTableSize];
+    /**
+     * Constructs a new, empty SymbolTable with the specified initial capacity
+     * and default load factor, which is <tt>0.75</tt>.
+     *
+     * @param     initialCapacity   the initial capacity of the hashtable.
+     * @throws    IllegalArgumentException if the initial capacity is less
+     *            than zero.
+     */
+    public SymbolTable(int initialCapacity) {
+        this(initialCapacity, 0.75f);
+    }
+
+    /**
+     * Constructs a new, empty SymbolTable with a default initial capacity (101)
+     * and load factor, which is <tt>0.75</tt>.
+     */
+    public SymbolTable() {
+        this(TABLE_SIZE, 0.75f);
     }
 
     //
@@ -94,36 +165,39 @@
     public String addSymbol(String symbol) {
 
         // search for identical symbol
-        final int hash = hash(symbol);
-        final int bucket = hash % fTableSize;
-        final int length = symbol.length();
-        OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
-            if (length == entry.characters.length && hash == entry.hashCode) {
-                if(symbol.regionMatches(0,entry.symbol,0,length)){
-                    return entry.symbol;
-                }
-                else{
-                    continue OUTER;
-                }
-                /**
-                for (int i = 0; i < length; i++) {
-                    if (symbol.charAt(i) != entry.characters[i]) {
-                        continue OUTER;
-                    }
-                }
-                symbolAsArray = entry.characters;
+        int collisionCount = 0;
+        int bucket = hash(symbol) % fTableSize;
+        for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+            if (entry.symbol.equals(symbol)) {
                 return entry.symbol;
-                 */
             }
+            ++collisionCount;
+        }
+        return addSymbol0(symbol, bucket, collisionCount);
+
+    } // addSymbol(String):String
+
+    private String addSymbol0(String symbol, int bucket, int collisionCount) {
+
+        if (fCount >= fThreshold) {
+            // Rehash the table if the threshold is exceeded
+            rehash();
+            bucket = hash(symbol) % fTableSize;
+        }
+        else if (collisionCount >= fCollisionThreshold) {
+            // Select a new hash function and rehash the table if
+            // the collision threshold is exceeded.
+            rebalance();
+            bucket = hash(symbol) % fTableSize;
         }
 
         // create new entry
         Entry entry = new Entry(symbol, fBuckets[bucket]);
-        entry.hashCode = hash;
         fBuckets[bucket] = entry;
+        ++fCount;
         return entry.symbol;
 
-    } // addSymbol(String):String
+    } // addSymbol0(String,int,int):String
 
     /**
      * Adds the specified symbol to the symbol table and returns a
@@ -136,27 +210,47 @@
      * @param length The length of the new symbol in the buffer.
      */
     public String addSymbol(char[] buffer, int offset, int length) {
+
         // search for identical symbol
-        int hash = hash(buffer, offset, length);
-        int bucket = hash % fTableSize;
+        int collisionCount = 0;
+        int bucket = hash(buffer, offset, length) % fTableSize;
         OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
-            if (length == entry.characters.length && hash ==entry.hashCode) {
+            if (length == entry.characters.length) {
                 for (int i = 0; i < length; i++) {
                     if (buffer[offset + i] != entry.characters[i]) {
+                        ++collisionCount;
                         continue OUTER;
                     }
                 }
                 return entry.symbol;
             }
+            ++collisionCount;
+        }
+        return addSymbol0(buffer, offset, length, bucket, collisionCount);
+
+    } // addSymbol(char[],int,int):String
+
+    private String addSymbol0(char[] buffer, int offset, int length, int bucket, int collisionCount) {
+
+        if (fCount >= fThreshold) {
+            // Rehash the table if the threshold is exceeded
+            rehash();
+            bucket = hash(buffer, offset, length) % fTableSize;
+        }
+        else if (collisionCount >= fCollisionThreshold) {
+            // Select a new hash function and rehash the table if
+            // the collision threshold is exceeded.
+            rebalance();
+            bucket = hash(buffer, offset, length) % fTableSize;
         }
 
         // add new entry
         Entry entry = new Entry(buffer, offset, length, fBuckets[bucket]);
         fBuckets[bucket] = entry;
-        entry.hashCode = hash;
+        ++fCount;
         return entry.symbol;
 
-    } // addSymbol(char[],int,int):String
+    } // addSymbol0(char[],int,int,int,int):String
 
     /**
      * Returns a hashcode value for the specified symbol. The value
@@ -167,15 +261,21 @@
      * @param symbol The symbol to hash.
      */
     public int hash(String symbol) {
+        if (fHashMultipliers == null) {
+            return symbol.hashCode() & 0x7FFFFFFF;
+        }
+        return hash0(symbol);
+    } // hash(String):int
 
+    private int hash0(String symbol) {
         int code = 0;
-        int length = symbol.length();
-        for (int i = 0; i < length; i++) {
-            code = code * 37 + symbol.charAt(i);
+        final int length = symbol.length();
+        final int[] multipliers = fHashMultipliers;
+        for (int i = 0; i < length; ++i) {
+            code = code * multipliers[i & MULTIPLIERS_MASK] + symbol.charAt(i);
         }
         return code & 0x7FFFFFFF;
-
-    } // hash(String):int
+    } // hash0(String):int
 
     /**
      * Returns a hashcode value for the specified symbol information.
@@ -189,14 +289,73 @@
      * @param length The length of the symbol.
      */
     public int hash(char[] buffer, int offset, int length) {
+        if (fHashMultipliers == null) {
+            int code = 0;
+            for (int i = 0; i < length; ++i) {
+                code = code * 31 + buffer[offset + i];
+            }
+            return code & 0x7FFFFFFF;
+        }
+        return hash0(buffer, offset, length);
 
+    } // hash(char[],int,int):int
+
+    private int hash0(char[] buffer, int offset, int length) {
         int code = 0;
-        for (int i = 0; i < length; i++) {
-            code = code * 37 + buffer[offset + i];
+        final int[] multipliers = fHashMultipliers;
+        for (int i = 0; i < length; ++i) {
+            code = code * multipliers[i & MULTIPLIERS_MASK] + buffer[offset + i];
         }
         return code & 0x7FFFFFFF;
+    } // hash0(char[],int,int):int
 
-    } // hash(char[],int,int):int
+    /**
+     * Increases the capacity of and internally reorganizes this
+     * SymbolTable, in order to accommodate and access its entries more
+     * efficiently.  This method is called automatically when the
+     * number of keys in the SymbolTable exceeds this hashtable's capacity
+     * and load factor.
+     */
+    protected void rehash() {
+        rehashCommon(fBuckets.length * 2 + 1);
+    }
+
+    /**
+     * Randomly selects a new hash function and reorganizes this SymbolTable
+     * in order to more evenly distribute its entries across the table. This
+     * method is called automatically when the number keys in one of the
+     * SymbolTable's buckets exceeds the given collision threshold.
+     */
+    protected void rebalance() {
+        if (fHashMultipliers == null) {
+            fHashMultipliers = new int[MULTIPLIERS_SIZE];
+        }
+        PrimeNumberSequenceGenerator.generateSequence(fHashMultipliers);
+        rehashCommon(fBuckets.length);
+    }
+
+    private void rehashCommon(final int newCapacity) {
+
+        int oldCapacity = fBuckets.length;
+        Entry[] oldTable = fBuckets;
+
+        Entry[] newTable = new Entry[newCapacity];
+
+        fThreshold = (int)(newCapacity * fLoadFactor);
+        fBuckets = newTable;
+        fTableSize = fBuckets.length;
+
+        for (int i = oldCapacity ; i-- > 0 ;) {
+            for (Entry old = oldTable[i] ; old != null ; ) {
+                Entry e = old;
+                old = old.next;
+
+                int index = hash(e.symbol) % newCapacity;
+                e.next = newTable[index];
+                newTable[index] = e;
+            }
+        }
+    }
 
     /**
      * Returns true if the symbol table already contains the specified
@@ -207,25 +366,16 @@
     public boolean containsSymbol(String symbol) {
 
         // search for identical symbol
-        int hash = hash(symbol);
-        int bucket = hash % fTableSize;
+        int bucket = hash(symbol) % fTableSize;
         int length = symbol.length();
         OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
-            if (length == entry.characters.length && hash == entry.hashCode) {
-                if(symbol.regionMatches(0,entry.symbol,0,length)){
-                    return true;
-                }
-                else {
-                    continue OUTER;
-                }
-                /**
+            if (length == entry.characters.length) {
                 for (int i = 0; i < length; i++) {
                     if (symbol.charAt(i) != entry.characters[i]) {
                         continue OUTER;
                     }
                 }
-                 return true;
-                 */
+                return true;
             }
         }
 
@@ -244,10 +394,9 @@
     public boolean containsSymbol(char[] buffer, int offset, int length) {
 
         // search for identical symbol
-        int hash = hash(buffer, offset, length) ;
-        int bucket = hash % fTableSize;
+        int bucket = hash(buffer, offset, length) % fTableSize;
         OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
-            if (length == entry.characters.length && hash == entry.hashCode) {
+            if (length == entry.characters.length) {
                 for (int i = 0; i < length; i++) {
                     if (buffer[offset + i] != entry.characters[i]) {
                         continue OUTER;
@@ -261,7 +410,6 @@
 
     } // containsSymbol(char[],int,int):boolean
 
-
     //
     // Classes
     //
@@ -277,14 +425,13 @@
         //
 
         /** Symbol. */
-        public String symbol;
-        int hashCode = 0;
+        public final String symbol;
 
         /**
          * Symbol characters. This information is duplicated here for
          * comparison performance.
          */
-        public char[] characters;
+        public final char[] characters;
 
         /** The next entry. */
         public Entry next;
--- a/src/com/sun/org/apache/xerces/internal/util/TypeInfoImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000-2002 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 "Xerces" and "Apache Software Foundation" 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",
- *    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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package com.sun.org.apache.xerces.internal.util;
-
-import java.util.Hashtable;
-
-import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import org.w3c.dom.TypeInfo;
-
-/**
- * Straight-forward implementation of {@link TypeInfo}.
- *
- * <p>
- * This class is immutable.
- *
- * @author
- *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
- */
-public class TypeInfoImpl implements TypeInfo {
-
-    private final String typeNamespace;
-    private final String typeName;
-        private final static String dtdNamespaceURI = "http://www.w3.org/TR/REC-xml";
-        public TypeInfoImpl(){
-                typeNamespace = null;
-                typeName = null;
-        }
-    public TypeInfoImpl(String typeNamespace, String typeName) {
-        this.typeNamespace = typeNamespace;
-        this.typeName = typeName;
-    }
-
-    public TypeInfoImpl(XSTypeDefinition t) {
-        this( t.getNamespace(), t.getName() );
-    }
-
-    public String getTypeName() {
-        return typeName;
-    }
-
-    public String getTypeNamespace() {
-        return typeNamespace;
-    }
-
-    /**
-     * Always returns false.
-     */
-    public boolean isDerivedFrom(String typeNamespaceArg,  String typeNameArg, int derivationMethod) {
-        return false;
-    }
-
-    /**
-     * Map from DTD type name ({@link String}) to {@link TypeInfo}.
-     */
-    private static final Hashtable dtdCache = new Hashtable();
-
-    /**
-     * Obtains a {@link TypeInfo} object from the DTD type name.
-     * <p>
-     * Since DTD has a very limited type names, we can actually
-     * cache the {@link TypeInfo} objects.
-     */
-    public static TypeInfo getDTDTypeInfo( String name ) {
-        TypeInfo t = (TypeInfo)dtdCache.get(name);
-        if(t==null) throw new IllegalArgumentException("Unknown DTD datatype "+name);
-        return t;
-    }
-
-    static {
-        String[] typeNames = new String[]{
-            "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS",
-            "ENTITY", "ENTITIES", "NOTATION"};
-        for( int i=0; i<typeNames.length; i++ )
-            dtdCache.put(typeNames[i],new TypeInfoImpl(dtdNamespaceURI,typeNames[i]));
-    }
-}
--- a/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,71 +1,30 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000-2002 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 4. The names "Xerces" and "Apache Software Foundation" 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",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * 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 and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.util;
 
-import com.sun.xml.internal.stream.XMLBufferListener;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
+import com.sun.xml.internal.stream.XMLBufferListener;
 /**
  * The XMLAttributesImpl class is an implementation of the XMLAttributes
  * interface which defines a collection of attributes for an element.
@@ -95,6 +54,12 @@
     /** Default table size. */
     protected static final int TABLE_SIZE = 101;
 
+    /** Maximum hash collisions per bucket. */
+    protected static final int MAX_HASH_COLLISIONS = 40;
+
+    protected static final int MULTIPLIERS_SIZE = 1 << 5;
+    protected static final int MULTIPLIERS_MASK = MULTIPLIERS_SIZE - 1;
+
     /**
      * Threshold at which an instance is treated
      * as a large attribute list.
@@ -126,7 +91,6 @@
     protected Attribute[] fAttributes = new Attribute[4];
 
     /**
-     * Hashtable of attribute information.
      * Provides an alternate view of the attribute specification.
      */
     protected Attribute[] fAttributeTableView;
@@ -149,6 +113,12 @@
      */
     protected boolean fIsTableViewConsistent;
 
+    /**
+     * Array of randomly selected hash function multipliers or <code>null</code>
+     * if the default String.hashCode() function should be used.
+     */
+    protected int[] fHashMultipliers;
+
     //
     // Constructors
     //
@@ -251,7 +221,8 @@
              * the user of this class adds attributes, removes them, and
              * then adds more.
              */
-            if (!fIsTableViewConsistent || fLength == SIZE_LIMIT) {
+            if (!fIsTableViewConsistent || fLength == SIZE_LIMIT ||
+                (fLength > SIZE_LIMIT && fLength > fTableViewBuckets)) {
                 prepareAndPopulateTableView();
                 fIsTableViewConsistent = true;
             }
@@ -280,12 +251,14 @@
             // We need to check if any of the attributes has the same rawname.
             else {
                 // Search the table.
+                int collisionCount = 0;
                 Attribute found = fAttributeTableView[bucket];
                 while (found != null) {
                     if (found.name.rawname == name.rawname) {
                         break;
                     }
                     found = found.next;
+                    ++collisionCount;
                 }
                 // This attribute is unique.
                 if (found == null) {
@@ -299,9 +272,19 @@
                         fAttributes = attributes;
                     }
 
-                    // Update table view
-                    fAttributes[index].next = fAttributeTableView[bucket];
-                    fAttributeTableView[bucket] = fAttributes[index];
+                    // Select a new hash function and rehash the table view
+                    // if the collision threshold is exceeded.
+                    if (collisionCount >= MAX_HASH_COLLISIONS) {
+                        // The current attribute will be processed in the rehash.
+                        // Need to set its name first.
+                        fAttributes[index].name.setValues(name);
+                        rebalanceTableView(fLength);
+                    }
+                    else {
+                        // Update table view
+                        fAttributes[index].next = fAttributeTableView[bucket];
+                        fAttributeTableView[bucket] = fAttributes[index];
+                    }
                 }
                 // Duplicate. We still need to find the index.
                 else {
@@ -807,56 +790,79 @@
      */
     public QName checkDuplicatesNS() {
         // If the list is small check for duplicates using pairwise comparison.
-        if (fLength <= SIZE_LIMIT) {
-            for (int i = 0; i < fLength - 1; ++i) {
-                Attribute att1 = fAttributes[i];
-                for (int j = i + 1; j < fLength; ++j) {
-                    Attribute att2 = fAttributes[j];
+        final int length = fLength;
+        if (length <= SIZE_LIMIT) {
+            final Attribute[] attributes = fAttributes;
+            for (int i = 0; i < length - 1; ++i) {
+                Attribute att1 = attributes[i];
+                for (int j = i + 1; j < length; ++j) {
+                    Attribute att2 = attributes[j];
                     if (att1.name.localpart == att2.name.localpart &&
                         att1.name.uri == att2.name.uri) {
                         return att2.name;
                     }
                 }
             }
+            return null;
         }
         // If the list is large check duplicates using a hash table.
         else {
-            // We don't want this table view to be read if someone calls
-            // addAttribute so we invalidate it up front.
-            fIsTableViewConsistent = false;
+            return checkManyDuplicatesNS();
+        }
+    }
 
-            prepareTableView();
+    private QName checkManyDuplicatesNS() {
+        // We don't want this table view to be read if someone calls
+        // addAttribute so we invalidate it up front.
+        fIsTableViewConsistent = false;
+
+        prepareTableView();
 
-            Attribute attr;
-            int bucket;
+        Attribute attr;
+        int bucket;
 
-            for (int i = fLength - 1; i >= 0; --i) {
-                attr = fAttributes[i];
-                bucket = getTableViewBucket(attr.name.localpart, attr.name.uri);
+        final int length = fLength;
+        final Attribute[] attributes = fAttributes;
+        final Attribute[] attributeTableView = fAttributeTableView;
+        final int[] attributeTableViewChainState = fAttributeTableViewChainState;
+        int largeCount = fLargeCount;
+
+        for (int i = 0; i < length; ++i) {
+            attr = attributes[i];
+            bucket = getTableViewBucket(attr.name.localpart, attr.name.uri);
 
-                // The chain is stale.
-                // This must be a unique attribute.
-                if (fAttributeTableViewChainState[bucket] != fLargeCount) {
-                    fAttributeTableViewChainState[bucket] = fLargeCount;
-                    attr.next = null;
-                    fAttributeTableView[bucket] = attr;
+            // The chain is stale.
+            // This must be a unique attribute.
+            if (attributeTableViewChainState[bucket] != largeCount) {
+                attributeTableViewChainState[bucket] = largeCount;
+                attr.next = null;
+                attributeTableView[bucket] = attr;
+            }
+            // This chain is active.
+            // We need to check if any of the attributes has the same name.
+            else {
+                // Search the table.
+                int collisionCount = 0;
+                Attribute found = attributeTableView[bucket];
+                while (found != null) {
+                    if (found.name.localpart == attr.name.localpart &&
+                        found.name.uri == attr.name.uri) {
+                        return attr.name;
+                    }
+                    found = found.next;
+                    ++collisionCount;
                 }
-                // This chain is active.
-                // We need to check if any of the attributes has the same name.
+                // Select a new hash function and rehash the table view
+                // if the collision threshold is exceeded.
+                if (collisionCount >= MAX_HASH_COLLISIONS) {
+                    // The current attribute will be processed in the rehash.
+                    rebalanceTableViewNS(i+1);
+                    largeCount = fLargeCount;
+                }
                 else {
-                    // Search the table.
-                    Attribute found = fAttributeTableView[bucket];
-                    while (found != null) {
-                        if (found.name.localpart == attr.name.localpart &&
-                            found.name.uri == attr.name.uri) {
-                            return attr.name;
-                        }
-                        found = found.next;
-                    }
-
                     // Update table view
-                    attr.next = fAttributeTableView[bucket];
-                    fAttributeTableView[bucket] = attr;
+                    attr.next = attributeTableView[bucket];
+                    attributeTableView[bucket] = attr;
                 }
             }
         }
@@ -911,7 +917,7 @@
      * would be hashed
      */
     protected int getTableViewBucket(String qname) {
-        return (qname.hashCode() & 0x7FFFFFFF) % fTableViewBuckets;
+        return (hash(qname) & 0x7FFFFFFF) % fTableViewBuckets;
     }
 
     /**
@@ -925,14 +931,37 @@
      */
     protected int getTableViewBucket(String localpart, String uri) {
         if (uri == null) {
-            return (localpart.hashCode() & 0x7FFFFFFF) % fTableViewBuckets;
+            return (hash(localpart) & 0x7FFFFFFF) % fTableViewBuckets;
         }
         else {
-            return ((localpart.hashCode() + uri.hashCode())
-               & 0x7FFFFFFF) % fTableViewBuckets;
+            return (hash(localpart, uri) & 0x7FFFFFFF) % fTableViewBuckets;
         }
     }
 
+    private int hash(String localpart) {
+        if (fHashMultipliers == null) {
+            return localpart.hashCode();
+        }
+        return hash0(localpart);
+    } // hash(String):int
+
+    private int hash(String localpart, String uri) {
+        if (fHashMultipliers == null) {
+            return localpart.hashCode() + uri.hashCode() * 31;
+        }
+        return hash0(localpart) + hash0(uri) * fHashMultipliers[MULTIPLIERS_SIZE];
+    } // hash(String,String):int
+
+    private int hash0(String symbol) {
+        int code = 0;
+        final int length = symbol.length();
+        final int[] multipliers = fHashMultipliers;
+        for (int i = 0; i < length; ++i) {
+            code = code * multipliers[i & MULTIPLIERS_MASK] + symbol.charAt(i);
+        }
+        return code;
+    } // hash0(String):int
+
     /**
      * Purges all elements from the table view.
      */
@@ -948,10 +977,32 @@
         }
     }
 
+     /**
+     * Increases the capacity of the table view.
+     */
+    private void growTableView() {
+        final int length = fLength;
+        int tableViewBuckets = fTableViewBuckets;
+        do {
+            tableViewBuckets = (tableViewBuckets << 1) + 1;
+            if (tableViewBuckets < 0) {
+                tableViewBuckets = Integer.MAX_VALUE;
+                break;
+            }
+        }
+       while (length > tableViewBuckets);
+        fTableViewBuckets = tableViewBuckets;
+        fAttributeTableView = null;
+        fLargeCount = 1;
+    }
+
     /**
      * Prepares the table view of the attributes list for use.
      */
     protected void prepareTableView() {
+        if (fLength > fTableViewBuckets) {
+            growTableView();
+        }
         if (fAttributeTableView == null) {
             fAttributeTableView = new Attribute[fTableViewBuckets];
             fAttributeTableViewChainState = new int[fTableViewBuckets];
@@ -967,11 +1018,15 @@
      * previously read.
      */
     protected void prepareAndPopulateTableView() {
+        prepareAndPopulateTableView(fLength);
+    }
+
+    private void prepareAndPopulateTableView(final int count) {
         prepareTableView();
-        // Need to populate the hash table with the attributes we've scanned so far.
+        // Need to populate the hash table with the attributes we've processed so far.
         Attribute attr;
         int bucket;
-        for (int i = 0; i < fLength; ++i) {
+        for (int i = 0; i < count; ++i) {
             attr = fAttributes[i];
             bucket = getTableViewBucket(attr.name.rawname);
             if (fAttributeTableViewChainState[bucket] != fLargeCount) {
@@ -1135,7 +1190,56 @@
         }
     }
     public void refresh(int pos) {
+    }
+
+    private void prepareAndPopulateTableViewNS(final int count) {
+        prepareTableView();
+        // Need to populate the hash table with the attributes we've processed so far.
+        Attribute attr;
+        int bucket;
+        for (int i = 0; i < count; ++i) {
+            attr = fAttributes[i];
+            bucket = getTableViewBucket(attr.name.localpart, attr.name.uri);
+            if (fAttributeTableViewChainState[bucket] != fLargeCount) {
+                fAttributeTableViewChainState[bucket] = fLargeCount;
+                attr.next = null;
+                fAttributeTableView[bucket] = attr;
+            }
+            else {
+                // Update table view
+                attr.next = fAttributeTableView[bucket];
+                fAttributeTableView[bucket] = attr;
+            }
         }
+    }
+
+    /**
+     * Randomly selects a new hash function and reorganizes the table view
+     * in order to more evenly distribute its entries. This method is called
+     * automatically when the number of attributes in one bucket exceeds
+     * MAX_HASH_COLLISIONS.
+     */
+    private void rebalanceTableView(final int count) {
+        if (fHashMultipliers == null) {
+            fHashMultipliers = new int[MULTIPLIERS_SIZE + 1];
+        }
+        PrimeNumberSequenceGenerator.generateSequence(fHashMultipliers);
+        prepareAndPopulateTableView(count);
+    }
+
+    /**
+     * Randomly selects a new hash function and reorganizes the table view
+     * in order to more evenly distribute its entries. This method is called
+     * automatically when the number of attributes in one bucket exceeds
+     * MAX_HASH_COLLISIONS.
+     */
+    private void rebalanceTableViewNS(final int count) {
+        if (fHashMultipliers == null) {
+            fHashMultipliers = new int[MULTIPLIERS_SIZE + 1];
+        }
+        PrimeNumberSequenceGenerator.generateSequence(fHashMultipliers);
+        prepareAndPopulateTableViewNS(count);
+    }
 
     //
     // Classes
--- a/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -128,18 +128,23 @@
     public void addValue(int index, String entityName, int value) {
         if (index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
                 index == Limit.MAX_OCCUR_NODE_LIMIT.ordinal() ||
-                index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal()) {
+                index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
+                index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal() ||
+                index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal()
+                ) {
             totalValue[index] += value;
             return;
         }
-        if (index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal()) {
+        if (index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal() ||
+                index == Limit.MAX_NAME_LIMIT.ordinal()) {
+            values[index] = value;
             totalValue[index] = value;
             return;
         }
 
         Map<String, Integer> cache;
         if (caches[index] == null) {
-            cache = new HashMap<String, Integer>(10);
+            cache = new HashMap<>(10);
             caches[index] = cache;
         } else {
             cache = caches[index];
@@ -147,10 +152,10 @@
 
         int accumulatedValue = value;
         if (cache.containsKey(entityName)) {
-            accumulatedValue += cache.get(entityName).intValue();
-            cache.put(entityName, Integer.valueOf(accumulatedValue));
+            accumulatedValue += cache.get(entityName);
+            cache.put(entityName, accumulatedValue);
         } else {
-            cache.put(entityName, Integer.valueOf(value));
+            cache.put(entityName, value);
         }
 
         if (accumulatedValue > values[index]) {
@@ -172,10 +177,13 @@
      * @return the value of the property
      */
     public int getValue(Limit limit) {
-        return values[limit.ordinal()];
+        return getValue(limit.ordinal());
     }
 
     public int getValue(int index) {
+        if (index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal()) {
+            return totalValue[index];
+        }
         return values[index];
     }
     /**
@@ -223,6 +231,21 @@
         }
     }
 
+    /**
+     * Resets the current value of the specified limit.
+     * @param limit The limit to be reset.
+     */
+    public void reset(Limit limit) {
+        if (limit.ordinal() == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()) {
+            totalValue[limit.ordinal()] = 0;
+        } else if (limit.ordinal() == Limit.GENEAL_ENTITY_SIZE_LIMIT.ordinal()) {
+            names[limit.ordinal()] = null;
+            values[limit.ordinal()] = 0;
+            caches[limit.ordinal()] = null;
+            totalValue[limit.ordinal()] = 0;
+        }
+    }
+
     public void debugPrint(XMLSecurityManager securityManager) {
         Formatter formatter = new Formatter();
         System.out.println(formatter.format("%30s %15s %15s %15s %30s",
--- a/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -61,20 +61,33 @@
      */
     public static enum Limit {
 
-        ENTITY_EXPANSION_LIMIT(Constants.JDK_ENTITY_EXPANSION_LIMIT, Constants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
-        MAX_OCCUR_NODE_LIMIT(Constants.JDK_MAX_OCCUR_LIMIT, Constants.SP_MAX_OCCUR_LIMIT, 0, 5000),
-        ELEMENT_ATTRIBUTE_LIMIT(Constants.JDK_ELEMENT_ATTRIBUTE_LIMIT, Constants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
-        TOTAL_ENTITY_SIZE_LIMIT(Constants.JDK_TOTAL_ENTITY_SIZE_LIMIT, Constants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
-        GENEAL_ENTITY_SIZE_LIMIT(Constants.JDK_GENEAL_ENTITY_SIZE_LIMIT, Constants.SP_GENEAL_ENTITY_SIZE_LIMIT, 0, 0),
-        PARAMETER_ENTITY_SIZE_LIMIT(Constants.JDK_PARAMETER_ENTITY_SIZE_LIMIT, Constants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000),
-        MAX_ELEMENT_DEPTH_LIMIT(Constants.JDK_MAX_ELEMENT_DEPTH, Constants.SP_MAX_ELEMENT_DEPTH, 0, 0);
+        ENTITY_EXPANSION_LIMIT("EntityExpansionLimit",
+                Constants.JDK_ENTITY_EXPANSION_LIMIT, Constants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
+        MAX_OCCUR_NODE_LIMIT("MaxOccurLimit",
+                Constants.JDK_MAX_OCCUR_LIMIT, Constants.SP_MAX_OCCUR_LIMIT, 0, 5000),
+        ELEMENT_ATTRIBUTE_LIMIT("ElementAttributeLimit",
+                Constants.JDK_ELEMENT_ATTRIBUTE_LIMIT, Constants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
+        TOTAL_ENTITY_SIZE_LIMIT("TotalEntitySizeLimit",
+                Constants.JDK_TOTAL_ENTITY_SIZE_LIMIT, Constants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
+        GENEAL_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit",
+                Constants.JDK_GENEAL_ENTITY_SIZE_LIMIT, Constants.SP_GENEAL_ENTITY_SIZE_LIMIT, 0, 0),
+        PARAMETER_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit",
+                Constants.JDK_PARAMETER_ENTITY_SIZE_LIMIT, Constants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000),
+        MAX_ELEMENT_DEPTH_LIMIT("MaxElementDepthLimit",
+                Constants.JDK_MAX_ELEMENT_DEPTH, Constants.SP_MAX_ELEMENT_DEPTH, 0, 0),
+        MAX_NAME_LIMIT("MaxXMLNameLimit",
+                Constants.JDK_XML_NAME_LIMIT, Constants.SP_XML_NAME_LIMIT, 1000, 1000),
+        ENTITY_REPLACEMENT_LIMIT("EntityReplacementLimit",
+                Constants.JDK_ENTITY_REPLACEMENT_LIMIT, Constants.SP_ENTITY_REPLACEMENT_LIMIT, 0, 3000000);
 
+        final String key;
         final String apiProperty;
         final String systemProperty;
         final int defaultValue;
         final int secureValue;
 
-        Limit(String apiProperty, String systemProperty, int value, int secureValue) {
+        Limit(String key, String apiProperty, String systemProperty, int value, int secureValue) {
+            this.key = key;
             this.apiProperty = apiProperty;
             this.systemProperty = systemProperty;
             this.defaultValue = value;
@@ -89,6 +102,10 @@
             return (propertyName == null) ? false : systemProperty.equals(propertyName);
         }
 
+        public String key() {
+            return key;
+        }
+
         public String apiProperty() {
             return apiProperty;
         }
@@ -97,7 +114,7 @@
             return systemProperty;
         }
 
-        int defaultValue() {
+        public int defaultValue() {
             return defaultValue;
         }
 
@@ -152,7 +169,7 @@
     /**
      * Index of the special entityCountInfo property
      */
-    private int indexEntityCountInfo = 10000;
+    private final int indexEntityCountInfo = 10000;
     private String printEntityCountInfo = "";
 
     /**
@@ -433,7 +450,10 @@
         if (index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
                 index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
                 index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal() ||
-                index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal()) {
+                index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal() ||
+                index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal() ||
+                index == Limit.MAX_NAME_LIMIT.ordinal()
+                ) {
             return (limitAnalyzer.getTotalValue(index) > values[index]);
         } else {
             return (limitAnalyzer.getValue(index) > values[index]);
--- a/src/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java	Wed Sep 07 06:06:32 2016 +0100
@@ -96,5 +96,14 @@
     public boolean scanDTDExternalSubset(boolean complete)
         throws IOException, XNIException;
 
+    /**
+     * Skip the DTD if javax.xml.stream.supportDTD is false.
+     * @param supportDTD The value of the property javax.xml.stream.supportDTD.
+     * @return true if DTD is skipped, false otherwise.
+     * @throws java.io.IOException if i/o error occurs
+     */
+    public boolean skipDTD(boolean supportDTD)
+        throws IOException;
+
     public void setLimitAnalyzer(XMLLimitAnalyzer limitAnalyzer);
 } // interface XMLDTDScanner
--- a/src/com/sun/org/apache/xml/internal/dtm/ref/CustomStringPool.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/dtm/ref/CustomStringPool.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -20,18 +20,20 @@
 /*
  * $Id: CustomStringPool.java,v 1.2.4.1 2005/09/15 08:14:59 suresh_emailid Exp $
  */
+package com.sun.org.apache.xml.internal.dtm.ref;
 
-package com.sun.org.apache.xml.internal.dtm.ref;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
-/** <p>CustomStringPool is an example of appliction provided data structure
- * for a DTM implementation to hold symbol references, e.g. elelment names.
- * It will follow the DTMDStringPool interface and use two simple methods
- * indexToString(int i) and stringToIndex(Sring s) to map between a set of
- * string values and a set of integer index values.  Therefore, an application
+/**
+ * CustomStringPool is an example of an application-provided data structure for a
+ * DTM implementation to hold symbol references, e.g. element names. It will
+ * follow the DTMStringPool interface and use two simple methods
+ * indexToString(int i) and stringToIndex(String s) to map between a set of
+ * string values and a set of integer index values. Therefore, an application
  * may improve DTM processing speed by substituting the DTM symbol resolution
- * tables with application specific quick symbol resolution tables.</p>
- *
+ * tables with application specific quick symbol resolution tables.
+ * <p>
  * %REVIEW% The only difference between this an DTMStringPool seems to be that
  * it uses a java.lang.Hashtable full of Integers rather than implementing its
  * own hashing. Joe deliberately avoided that approach when writing
@@ -39,52 +41,51 @@
  * -- especially in JDK 1.1.x, where Hashtable is synchronized. We need to
  * either justify this implementation or discard it.
  *
- * <p>Status: In progress, under discussion.</p>
- * */
+ * <p>
+ * Status: In progress, under discussion.
+ *
+ */
 public class CustomStringPool extends DTMStringPool {
-        //final Vector m_intToString;
-        //static final int HASHPRIME=101;
-        //int[] m_hashStart=new int[HASHPRIME];
-        final Hashtable m_stringToInt = new Hashtable();
-        public static final int NULL=-1;
+
+    final Map<String, Integer> m_stringToInt = new HashMap<>();
+    public static final int NULL = -1;
 
-        public CustomStringPool()
-        {
-                super();
-                /*m_intToString=new Vector();
-                System.out.println("In constructor m_intToString is " +
-                                                                                         ((null == m_intToString) ? "null" : "not null"));*/
-                //m_stringToInt=new Hashtable();
-                //removeAllElements();
-        }
+    public CustomStringPool() {
+        super();
+    }
 
-        public void removeAllElements()
-        {
-                m_intToString.removeAllElements();
-                if (m_stringToInt != null)
-                        m_stringToInt.clear();
+    public void removeAllElements() {
+        m_intToString.removeAllElements();
+        if (m_stringToInt != null) {
+            m_stringToInt.clear();
         }
+    }
 
-        /** @return string whose value is uniquely identified by this integer index.
-         * @throws java.lang.ArrayIndexOutOfBoundsException
-         *  if index doesn't map to a string.
-         * */
-        public String indexToString(int i)
-        throws java.lang.ArrayIndexOutOfBoundsException
-        {
-                return(String) m_intToString.elementAt(i);
-        }
+    /**
+     * @return string whose value is uniquely identified by this integer index.
+     * @throws java.lang.ArrayIndexOutOfBoundsException if index doesn't map to
+     * a string.
+     */
+    @Override
+    public String indexToString(int i)
+            throws java.lang.ArrayIndexOutOfBoundsException {
+        return (String) m_intToString.elementAt(i);
+    }
 
-        /** @return integer index uniquely identifying the value of this string. */
-        public int stringToIndex(String s)
-        {
-                if (s==null) return NULL;
-                Integer iobj=(Integer)m_stringToInt.get(s);
-                if (iobj==null) {
-                        m_intToString.addElement(s);
-                        iobj=new Integer(m_intToString.size());
-                        m_stringToInt.put(s,iobj);
-                }
-                return iobj.intValue();
+    /**
+     * @return integer index uniquely identifying the value of this string.
+     */
+    @Override
+    public int stringToIndex(String s) {
+        if (s == null) {
+            return NULL;
         }
+        Integer iobj = m_stringToInt.get(s);
+        if (iobj == null) {
+            m_intToString.addElement(s);
+            iobj = m_intToString.size();
+            m_stringToInt.put(s, iobj);
+        }
+        return iobj;
+    }
 }
--- a/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,26 +22,43 @@
  */
 package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm;
 
-import java.util.Hashtable;
-import java.util.Vector;
-import javax.xml.transform.Source;
-import javax.xml.transform.SourceLocator;
 
-import com.sun.org.apache.xml.internal.dtm.*;
-import com.sun.org.apache.xml.internal.dtm.ref.*;
-import com.sun.org.apache.xml.internal.utils.StringVector;
-import com.sun.org.apache.xml.internal.utils.IntVector;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.dtm.DTMManager;
+import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMStringPool;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMTreeWalker;
+import com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource;
+import com.sun.org.apache.xml.internal.dtm.ref.NodeLocator;
+import com.sun.org.apache.xml.internal.res.XMLErrorResources;
+import com.sun.org.apache.xml.internal.res.XMLMessages;
 import com.sun.org.apache.xml.internal.utils.FastStringBuffer;
 import com.sun.org.apache.xml.internal.utils.IntStack;
+import com.sun.org.apache.xml.internal.utils.IntVector;
+import com.sun.org.apache.xml.internal.utils.StringVector;
 import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
 import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException;
 import com.sun.org.apache.xml.internal.utils.XMLString;
 import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
-import com.sun.org.apache.xml.internal.res.XMLErrorResources;
-import com.sun.org.apache.xml.internal.res.XMLMessages;
-import org.xml.sax.*;
-import org.xml.sax.ext.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
 
 /**
  * This class implements a DTM that tends to be optimized more for speed than
@@ -145,7 +162,7 @@
    * This table holds the ID string to node associations, for
    * XML IDs.
    */
-  protected Hashtable m_idAttributes = new Hashtable();
+  protected Map<String, Integer> m_idAttributes = new HashMap<>();
 
   /**
    * fixed dom-style names.
@@ -1375,7 +1392,7 @@
 
     do
     {
-      intObj = (Integer) m_idAttributes.get(elementId);
+      intObj = m_idAttributes.get(elementId);
 
       if (null != intObj)
         return makeNodeHandle(intObj.intValue());
@@ -1513,7 +1530,7 @@
    */
   public void setIDAttribute(String id, int elem)
   {
-    m_idAttributes.put(id, new Integer(elem));
+    m_idAttributes.put(id, elem);
   }
 
   /**
--- a/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/res/XMLErrorResources_ko.java	Wed Sep 07 06:06:32 2016 +0100
@@ -254,7 +254,7 @@
        "\uAD6C\uBB38 \uBD84\uC11D\uAE30\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
 
     { ER_EXCEPTION_CREATING_POOL,
-       "\uD480\uC5D0 \uB300\uD55C \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD558\uB294 \uC911 \uC608\uC678 \uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
+       "\uD480\uC5D0 \uB300\uD55C \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD558\uB294 \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
 
     { ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
        "\uACBD\uB85C\uC5D0 \uBD80\uC801\uD569\uD55C \uC774\uC2A4\uCF00\uC774\uD504 \uC2DC\uD000\uC2A4\uAC00 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4."},
@@ -377,7 +377,7 @@
       "\uC774\uB984\uC740 \uCF5C\uB860\uC73C\uB85C \uC2DC\uC791\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
 
     { "BAD_CODE", "createMessage\uC5D0 \uB300\uD55C \uB9E4\uAC1C\uBCC0\uC218\uAC00 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4."},
-    { "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678 \uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
+    { "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
     { "line", "\uD589 \uBC88\uD638"},
     { "column","\uC5F4 \uBC88\uD638"},
 
--- a/src/com/sun/org/apache/xml/internal/resolver/Catalog.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/Catalog.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,18 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-// Catalog.java - Represents OASIS Open Catalog files.
-
 /*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,34 +17,31 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+// Catalog.java - Represents OASIS Open Catalog files.
 package com.sun.org.apache.xml.internal.resolver;
 
 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
+import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
+import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
+import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
+import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
+import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
+
+import java.io.DataInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
-import java.io.DataInputStream;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
+import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.MalformedURLException;
-
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
 import javax.xml.parsers.SAXParserFactory;
 
-import com.sun.org.apache.xml.internal.resolver.CatalogManager;
-import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
-import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
-
 /**
  * Represents OASIS Open Catalog files.
  *
@@ -347,7 +341,7 @@
    * vector. This allows the Catalog to quickly locate the reader
    * for a particular MIME type.</p>
    */
-  protected Hashtable readerMap = new Hashtable();
+  protected Map<String, Integer> readerMap = new HashMap<>();
 
   /**
    * A vector of CatalogReaders.
@@ -443,11 +437,11 @@
    */
   public void addReader(String mimeType, CatalogReader reader) {
     if (readerMap.containsKey(mimeType)) {
-      Integer pos = (Integer) readerMap.get(mimeType);
-      readerArr.set(pos.intValue(), reader);
+      Integer pos = readerMap.get(mimeType);
+      readerArr.set(pos, reader);
     } else {
       readerArr.add(reader);
-      Integer pos = new Integer(readerArr.size()-1);
+      Integer pos = readerArr.size()-1;
       readerMap.put(mimeType, pos);
     }
   }
@@ -470,19 +464,16 @@
       mapArr.add(null);
     }
 
-    Enumeration en = readerMap.keys();
-    while (en.hasMoreElements()) {
-      String mimeType = (String) en.nextElement();
-      Integer pos = (Integer) readerMap.get(mimeType);
-      mapArr.set(pos.intValue(), mimeType);
+    for (Map.Entry<String, Integer> entry : readerMap.entrySet()) {
+        mapArr.set(entry.getValue(), entry.getKey());
     }
 
     for (int count = 0; count < mapArr.size(); count++) {
       String mimeType = (String) mapArr.get(count);
-      Integer pos = (Integer) readerMap.get(mimeType);
+      Integer pos = readerMap.get(mimeType);
       newCatalog.addReader(mimeType,
                            (CatalogReader)
-                           readerArr.get(pos.intValue()));
+                           readerArr.get(pos));
     }
   }
 
@@ -822,9 +813,7 @@
       // tack on a basename because URLs point to files not dirs
       catalogCwd = FileURL.makeURL("basename");
     } catch (MalformedURLException e) {
-      String userdir = SecuritySupport.getSystemProperty("user.dir");
-      userdir.replace('\\', '/');
-      catalogManager.debug.message(1, "Malformed URL on cwd", userdir);
+      catalogManager.debug.message(1, "Malformed URL on cwd", "user.dir");
       catalogCwd = null;
     }
 
--- a/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,18 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-// CatalogEntry.java - Represents Catalog entries
-
 /*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,11 +17,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+// CatalogEntry.java - Represents Catalog entries
 package com.sun.org.apache.xml.internal.resolver;
 
-import java.util.Hashtable;
+import java.util.Map;
 import java.util.Vector;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Represents a Catalog entry.
@@ -53,14 +52,14 @@
  */
 public class CatalogEntry {
   /** The nextEntry is the ordinal number of the next entry type. */
-  protected static int nextEntry = 0;
+  protected static AtomicInteger nextEntry = new AtomicInteger(0);
 
   /**
    * The entryTypes vector maps catalog entry names
    * (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.).
    * Names are case sensitive.
    */
-  protected static Hashtable entryTypes = new Hashtable();
+  protected static final Map<String, Integer> entryTypes = new ConcurrentHashMap<>();
 
   /** The entryTypes vector maps catalog entry types to the
       number of arguments they're required to have. */
@@ -77,12 +76,12 @@
    * of arguments.
    * @return The type for the new entry.
    */
-  public static int addEntryType(String name, int numArgs) {
-    entryTypes.put(name, new Integer(nextEntry));
-    entryArgs.add(nextEntry, new Integer(numArgs));
-    nextEntry++;
+  static int addEntryType(String name, int numArgs) {
+    final int index = nextEntry.getAndIncrement();
+    entryTypes.put(name, index);
+    entryArgs.add(index, numArgs);
 
-    return nextEntry-1;
+    return index;
   }
 
   /**
@@ -99,13 +98,13 @@
       throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
     }
 
-    Integer iType = (Integer) entryTypes.get(name);
+    Integer iType = entryTypes.get(name);
 
     if (iType == null) {
       throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
     }
 
-    return iType.intValue();
+    return iType;
   }
 
   /**
@@ -161,13 +160,13 @@
    */
   public CatalogEntry(String name, Vector args)
     throws CatalogException {
-    Integer iType = (Integer) entryTypes.get(name);
+    Integer iType = entryTypes.get(name);
 
     if (iType == null) {
       throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
     }
 
-    int type = iType.intValue();
+    int type = iType;
 
     try {
       Integer iArgs = (Integer) entryArgs.get(type);
--- a/src/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,18 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-// BootstrapResolver.java - Resolve entities and URIs internally
-
 /*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,19 +17,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+// BootstrapResolver.java - Resolve entities and URIs internally
 
 package com.sun.org.apache.xml.internal.resolver.helpers;
 
-import java.util.Hashtable;
-import java.net.URL;
+import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.io.InputStream;
-
-import javax.xml.transform.URIResolver;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
 import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.TransformerException;
-
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 
@@ -66,13 +63,13 @@
   public static final String xmlCatalogSysId = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd";
 
   /** Private hash used for public identifiers. */
-  private Hashtable publicMap = new Hashtable();
+  private final Map<String, String> publicMap = new HashMap<>();
 
   /** Private hash used for system identifiers. */
-  private Hashtable systemMap = new Hashtable();
+  private final Map<String, String> systemMap = new HashMap<>();
 
   /** Private hash used for URIs. */
-  private Hashtable uriMap = new Hashtable();
+  private final Map<String, String> uriMap = new HashMap<>();
 
   /** Constructor. */
   public BootstrapResolver() {
@@ -98,9 +95,9 @@
     String resolved = null;
 
     if (systemId != null && systemMap.containsKey(systemId)) {
-      resolved = (String) systemMap.get(systemId);
+      resolved = systemMap.get(systemId);
     } else if (publicId != null && publicMap.containsKey(publicId)) {
-      resolved = (String) publicMap.get(publicId);
+      resolved = publicMap.get(publicId);
     }
 
     if (resolved != null) {
@@ -147,7 +144,7 @@
 
     String result = null;
     if (href != null && uriMap.containsKey(href)) {
-      result = (String) uriMap.get(href);
+      result = uriMap.get(href);
     }
 
     if (result == null) {
--- a/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,18 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-// DOMCatalogReader.java - Read XML Catalog files
-
 /*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,6 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+// DOMCatalogReader.java - Read XML Catalog files
 
 package com.sun.org.apache.xml.internal.resolver.readers;
 
@@ -31,11 +29,14 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
 import sun.reflect.misc.ReflectUtil;
 
@@ -77,7 +78,7 @@
    * or "{namespaceuri}elementname". The former is used if the
    * namespace URI is null.</p>
    */
-  protected Hashtable namespaceMap = new Hashtable();
+  protected Map<String, String> namespaceMap = new HashMap<>();
 
   /**
    * Add a new parser to the reader.
@@ -113,9 +114,9 @@
   public String getCatalogParser(String namespaceURI,
                                  String rootElement) {
     if (namespaceURI == null) {
-      return (String) namespaceMap.get(rootElement);
+      return namespaceMap.get(rootElement);
     } else {
-      return (String) namespaceMap.get("{"+namespaceURI+"}"+rootElement);
+      return namespaceMap.get("{"+namespaceURI+"}"+rootElement);
     }
   }
 
--- a/src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,18 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-// SAXCatalogReader.java - Read XML Catalog files
-
 /*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,6 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+// SAXCatalogReader.java - Read XML Catalog files
 
 package com.sun.org.apache.xml.internal.resolver.readers;
 
@@ -34,7 +32,8 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.UnknownHostException;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
@@ -90,7 +89,7 @@
      * or "{namespaceuri}elementname". The former is used if the
      * namespace URI is null.</p>
      */
-  protected Hashtable namespaceMap = new Hashtable();
+  protected Map<String, String> namespaceMap = new HashMap<>();
 
   /** The parser in use for the current catalog. */
   private SAXCatalogParser saxParser = null;
@@ -171,9 +170,9 @@
   public String getCatalogParser(String namespaceURI,
                                  String rootElement) {
     if (namespaceURI == null) {
-      return (String) namespaceMap.get(rootElement);
+      return namespaceMap.get(rootElement);
     } else {
-      return (String) namespaceMap.get("{"+namespaceURI+"}"+rootElement);
+      return namespaceMap.get("{"+namespaceURI+"}"+rootElement);
     }
   }
 
--- a/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -18,7 +18,6 @@
  * limitations under the License.
  */
 
-
 // Sep 14, 2000:
 //  Fixed comments to preserve whitespaces and add a line break
 //  when indenting. Reported by Gervase Markham <gerv@gerv.net>
@@ -46,23 +45,23 @@
 
 package com.sun.org.apache.xml.internal.serialize;
 
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Hashtable;
-import java.util.Vector;
-
 import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
 import com.sun.org.apache.xerces.internal.dom.DOMLocatorImpl;
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMErrorHandler;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.DocumentType;
-import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMErrorHandler;
 import org.w3c.dom.Element;
 import org.w3c.dom.Entity;
 import org.w3c.dom.NamedNodeMap;
@@ -186,7 +185,7 @@
      * Accumulated here prior to starting an element and placing this
      * list in the element state.
      */
-    protected Hashtable     _prefixes;
+    protected Map<String, String>  _prefixes;
 
 
     /**
@@ -821,7 +820,7 @@
         throws SAXException
     {
         if ( _prefixes == null )
-            _prefixes = new Hashtable();
+            _prefixes = new HashMap<>();
         _prefixes.put( uri, prefix == null ? "" : prefix );
     }
 
@@ -1909,7 +1908,7 @@
         String    prefix;
 
         if ( _prefixes != null ) {
-            prefix = (String) _prefixes.get( namespaceURI );
+            prefix = _prefixes.get( namespaceURI );
             if ( prefix != null )
                 return prefix;
         }
--- a/src/com/sun/org/apache/xml/internal/serialize/ElementState.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/ElementState.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -22,7 +22,7 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 
-import java.util.Hashtable;
+import java.util.Map;
 
 
 /**
@@ -102,7 +102,7 @@
     /**
      * Association between namespace URIs (keys) and prefixes (values).
      */
-    public Hashtable prefixes;
+    public Map<String, String> prefixes;
 
 
 }
--- a/src/com/sun/org/apache/xml/internal/serialize/Encodings.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/Encodings.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -22,11 +22,11 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 
+import com.sun.org.apache.xerces.internal.util.EncodingMap;
 import java.io.UnsupportedEncodingException;
-import java.util.Hashtable;
 import java.util.Locale;
-
-import com.sun.org.apache.xerces.internal.util.EncodingMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 
 /**
@@ -37,7 +37,7 @@
  *
  * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
  */
-public class Encodings
+class Encodings
 {
 
 
@@ -55,10 +55,10 @@
     // default (Java) encoding if none supplied:
     static final String DEFAULT_ENCODING = "UTF8";
 
-    // note that the size of this Hashtable
+    // note that the size of this Map
     // is bounded by the number of encodings recognized by EncodingMap;
     // therefore it poses no static mutability risk.
-    static Hashtable _encodings = new Hashtable();
+    private static final Map<String, EncodingInfo> _encodings = new ConcurrentHashMap();
 
     /**
      * @param encoding a MIME charset name, or null.
@@ -66,7 +66,7 @@
     static EncodingInfo getEncodingInfo(String encoding, boolean allowJavaNames) throws UnsupportedEncodingException {
         EncodingInfo eInfo = null;
         if (encoding == null) {
-            if((eInfo = (EncodingInfo)_encodings.get(DEFAULT_ENCODING)) != null)
+            if((eInfo = _encodings.get(DEFAULT_ENCODING)) != null)
                 return eInfo;
             eInfo = new EncodingInfo(EncodingMap.getJava2IANAMapping(DEFAULT_ENCODING), DEFAULT_ENCODING, LAST_PRINTABLE_UNICODE);
             _encodings.put(DEFAULT_ENCODING, eInfo);
@@ -79,7 +79,7 @@
             // see if the encoding passed in is a Java encoding name.
             if(allowJavaNames ) {
                 EncodingInfo.testJavaEncodingName(encoding);
-                if((eInfo = (EncodingInfo)_encodings.get(encoding)) != null)
+                if((eInfo = _encodings.get(encoding)) != null)
                     return eInfo;
                 // is it known to be unicode-compliant?
                 int i=0;
@@ -98,7 +98,7 @@
                 throw new UnsupportedEncodingException(encoding);
             }
         }
-        if ((eInfo = (EncodingInfo)_encodings.get(jName)) != null)
+        if ((eInfo = _encodings.get(jName)) != null)
             return eInfo;
         // have to create one...
         // is it known to be unicode-compliant?
--- a/src/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -37,13 +37,11 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
-import java.util.Enumeration;
 import java.util.Locale;
-
+import java.util.Map;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -320,13 +318,10 @@
                 preserveSpace = true;
 
             if ( addNSAttr ) {
-                Enumeration keys;
-
-                keys = _prefixes.keys();
-                while ( keys.hasMoreElements() ) {
+                for (Map.Entry<String, String> entry : _prefixes.entrySet()) {
                     _printer.printSpace();
-                    value = (String) keys.nextElement();
-                    name = (String) _prefixes.get( value );
+                    value = entry.getKey(); //The prefixes map uses the URI value as key.
+                    name = entry.getValue(); //and prefix name as value
                     if ( name.length() == 0 ) {
                         _printer.printText( "xmlns=\"" );
                         printEscaped( value );
--- a/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -18,7 +18,6 @@
  * limitations under the License.
  */
 
-
 // Aug 21, 2000:
 //   Fixed bug in isElement and made HTMLdtd public.
 //   Contributed by Eric SCHAEFFER" <eschaeffer@posterconseil.com>
@@ -27,12 +26,12 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
-
+import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.BufferedReader;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 
 /**
@@ -78,23 +77,23 @@
      * Table of reverse character reference mapping. Character codes are held
      * as single-character strings, mapped to their reference name.
      */
-    private static Hashtable        _byChar;
+    private static Map<Integer, String> _byChar;
 
 
     /**
      * Table of entity name to value mapping. Entities are held as strings,
      * character references as <TT>Character</TT> objects.
      */
-    private static Hashtable        _byName;
+    private static Map<String, Integer> _byName;
 
 
-    private static Hashtable        _boolAttrs;
+    private static final Map<String, String[]> _boolAttrs;
 
 
     /**
      * Holds element definitions.
      */
-    private static Hashtable        _elemDefs;
+    private static final Map<String, Integer> _elemDefs;
 
 
     /**
@@ -300,7 +299,7 @@
     {
         String[] attrNames;
 
-        attrNames = (String[]) _boolAttrs.get( tagName.toUpperCase(Locale.ENGLISH) );
+        attrNames = _boolAttrs.get( tagName.toUpperCase(Locale.ENGLISH) );
         if ( attrNames == null )
             return false;
         for ( int i = 0 ; i < attrNames.length ; ++i )
@@ -347,7 +346,7 @@
         String name;
 
         initialize();
-        name = (String) _byChar.get( new Integer( value ) );
+        name = _byChar.get(value);
         return name;
     }
 
@@ -372,8 +371,8 @@
         if ( _byName != null )
             return;
         try {
-            _byName = new Hashtable();
-            _byChar = new Hashtable();
+            _byName = new HashMap<>();
+            _byChar = new HashMap<>();
             is = HTMLdtd.class.getResourceAsStream( ENTITIES_RESOURCE );
             if ( is == null ) {
                 throw new RuntimeException(
@@ -442,7 +441,7 @@
 
     private static void defineElement( String name, int flags )
     {
-        _elemDefs.put( name, new Integer( flags ) );
+        _elemDefs.put(name, flags);
     }
 
 
@@ -462,7 +461,7 @@
     {
         Integer flags;
 
-        flags = (Integer) _elemDefs.get( name.toUpperCase(Locale.ENGLISH) );
+        flags = _elemDefs.get( name.toUpperCase(Locale.ENGLISH) );
         if ( flags == null )
             return false;
         else
@@ -472,7 +471,7 @@
 
     static
     {
-        _elemDefs = new Hashtable();
+        _elemDefs = new HashMap<>();
         defineElement( "ADDRESS", CLOSE_P );
         defineElement( "AREA", EMPTY );
         defineElement( "BASE",  EMPTY | ALLOWED_HEAD );
@@ -526,7 +525,7 @@
         defineElement( "TR", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
         defineElement( "UL", ELEM_CONTENT | CLOSE_P );
 
-        _boolAttrs = new Hashtable();
+        _boolAttrs = new HashMap<>();
         defineBoolean( "AREA", "href" );
         defineBoolean( "BUTTON", "disabled" );
         defineBoolean( "DIR", "compact" );
--- a/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -24,9 +24,11 @@
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-import java.io.UnsupportedEncodingException;
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.StringTokenizer;
 
 /**
@@ -43,7 +45,7 @@
     public static final String FactoriesProperty = "com.sun.org.apache.xml.internal.serialize.factories";
 
 
-    private static Hashtable  _factories = new Hashtable();
+    private static final Map<String, SerializerFactory>  _factories = Collections.synchronizedMap(new HashMap());
 
 
     static
@@ -89,9 +91,9 @@
         String method;
 
         synchronized ( _factories ) {
-            method = factory.getSupportedMethod();
-            _factories.put( method, factory );
-        }
+        method = factory.getSupportedMethod();
+        _factories.put( method, factory );
+    }
     }
 
 
@@ -101,7 +103,7 @@
      */
     public static SerializerFactory getSerializerFactory( String method )
     {
-        return (SerializerFactory) _factories.get( method );
+        return _factories.get( method );
     }
 
 
--- a/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -36,18 +36,16 @@
 
 package com.sun.org.apache.xml.internal.serialize;
 
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Enumeration;
-
 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Map;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMError;
 import org.w3c.dom.Element;
@@ -334,13 +332,10 @@
             }
 
             if (_prefixes != null) {
-                Enumeration keys;
-
-                keys = _prefixes.keys();
-                while (keys.hasMoreElements()) {
+                for (Map.Entry<String, String> entry : _prefixes.entrySet()) {
                     _printer.printSpace();
-                    value = (String) keys.nextElement();
-                    name = (String) _prefixes.get( value );
+                    value = entry.getKey(); //The prefixes map uses the URI value as key.
+                    name = entry.getValue(); //and prefix name as value
                     if (name.length() == 0) {
                         _printer.printText( "xmlns=\"" );
                         printEscaped( value );
--- a/src/com/sun/org/apache/xml/internal/serializer/AttributesImplSerializer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/AttributesImplSerializer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2003-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -23,14 +23,14 @@
 
 package com.sun.org.apache.xml.internal.serializer;
 
-import java.util.Hashtable;
-
+import java.util.HashMap;
+import java.util.Map;
 import org.xml.sax.Attributes;
 import org.xml.sax.helpers.AttributesImpl;
 
 /**
  * This class extends org.xml.sax.helpers.AttributesImpl which implements org.
- * xml.sax.Attributes. But for optimization this class adds a Hashtable for
+ * xml.sax.Attributes. But for optimization this class adds a Map for
  * faster lookup of an index by qName, which is commonly done in the stream
  * serializer.
  *
@@ -48,7 +48,7 @@
      * The keys to the hashtable to find the index are either
      * "prefix:localName"  or "{uri}localName".
      */
-    private final Hashtable m_indexFromQName = new Hashtable();
+    private final Map<String, Integer> m_indexFromQName = new HashMap<>();
 
     private final StringBuffer m_buff = new StringBuffer();
 
@@ -60,7 +60,7 @@
 
     /**
      * One less than the number of attributes before switching to
-     * the Hashtable.
+     * the Map.
      */
     private static final int MAXMinus1 = MAX - 1;
 
@@ -82,8 +82,8 @@
             return index;
         }
         // we have too many attributes and the super class is slow
-        // so find it quickly using our Hashtable.
-        Integer i = (Integer)m_indexFromQName.get(qname);
+        // so find it quickly using our Map.
+        Integer i = m_indexFromQName.get(qname);
         if (i == null)
             index = -1;
         else
@@ -126,7 +126,7 @@
         {
             /* add the key with the format of "prefix:localName" */
             /* we have just added the attibute, its index is the old length */
-            Integer i = new Integer(index);
+            Integer i = index;
             m_indexFromQName.put(qname, i);
 
             /* now add with key of the format "{uri}localName" */
@@ -135,14 +135,13 @@
             String key = m_buff.toString();
             m_indexFromQName.put(key, i);
         }
-        return;
     }
 
     /**
      * We are switching over to having a hash table for quick look
      * up of attributes, but up until now we haven't kept any
-     * information in the Hashtable, so we now update the Hashtable.
-     * Future additional attributes will update the Hashtable as
+     * information in the Map, so we now update the Map.
+     * Future additional attributes will update the Map as
      * they are added.
      * @param numAtts
      */
@@ -151,7 +150,7 @@
         for (int index = 0; index < numAtts; index++)
         {
             String qName = super.getQName(index);
-            Integer i = new Integer(index);
+            Integer i = index;
             m_indexFromQName.put(qName, i);
 
             // Add quick look-up to find with uri/local name pair
@@ -177,7 +176,7 @@
         if (MAX <= len)
         {
             // if we have had enough attributes and are
-            // using the Hashtable, then clear the Hashtable too.
+            // using the Map, then clear the Map too.
             m_indexFromQName.clear();
         }
 
@@ -224,16 +223,16 @@
             return index;
         }
         // we have too many attributes and the super class is slow
-        // so find it quickly using our Hashtable.
+        // so find it quickly using our Map.
         // Form the key of format "{uri}localName"
         m_buff.setLength(0);
         m_buff.append('{').append(uri).append('}').append(localName);
         String key = m_buff.toString();
-        Integer i = (Integer)m_indexFromQName.get(key);
+        Integer i = m_indexFromQName.get(key);
         if (i == null)
             index = -1;
         else
-            index = i.intValue();
+            index = i;
         return index;
     }
 }
--- a/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2003-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -25,13 +25,10 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
-import java.util.Hashtable;
 import java.util.Properties;
 import java.util.Vector;
-
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.Transformer;
-
 import org.w3c.dom.Node;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -39,6 +36,7 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+
 /**
  * This class is an adapter class. Its only purpose is to be extended and
  * for that extended class to over-ride all methods that are to be used.
@@ -75,11 +73,6 @@
         return; // don't do anything.
     }
 
-    protected void couldThrowException() throws Exception
-    {
-        return; // don't do anything.
-    }
-
     void aMethodIsCalled()
     {
 
@@ -568,13 +561,6 @@
         return null;
     }
     /**
-     * @see XSLOutputAttributes#setCdataSectionElements
-     */
-    public void setCdataSectionElements(Hashtable h) throws Exception
-    {
-        couldThrowException();
-    }
-    /**
      * @see XSLOutputAttributes#setDoctype(java.lang.String, java.lang.String)
      */
     public void setDoctype(String system, String pub)
--- a/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,14 +22,11 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
 import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
 import com.sun.org.apache.xml.internal.serializer.utils.Utils;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import java.util.Properties;
+import javax.xml.transform.OutputKeys;
 import org.xml.sax.ContentHandler;
 
 /**
@@ -70,10 +67,6 @@
   private SerializerFactory() {
 
   }
-  /**
-   * Associates output methods to default output formats.
-   */
-  private static Hashtable m_formats = new Hashtable();
 
   /**
    * Returns a serializer for the specified output method. The output method
--- a/src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -17,9 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: TreeWalker.java,v 1.1.4.1 2005/09/08 10:58:44 suresh_emailid Exp $
- */
+
 package com.sun.org.apache.xml.internal.serializer;
 
 import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
@@ -94,34 +92,17 @@
       m_contentHandler = contentHandler;
       if (m_contentHandler instanceof SerializationHandler) {
           m_Serializer = (SerializationHandler) m_contentHandler;
+      } else {
+          m_Serializer = null;
       }
-      else
-          m_Serializer = null;
 
       // Set the system ID, if it is given
       m_contentHandler.setDocumentLocator(m_locator);
-      if (systemId != null)
+      if (systemId != null) {
           m_locator.setSystemId(systemId);
-      else {
-          try {
-            // Bug see Bugzilla  26741
-            m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
-           }
-           catch (SecurityException se) {// user.dir not accessible from applet
-           }
       }
 
-      // Set the document locator
-                if (m_contentHandler != null)
-                        m_contentHandler.setDocumentLocator(m_locator);
-                try {
-                   // Bug see Bugzilla  26741
-                  m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
-                }
-                catch (SecurityException se){// user.dir not accessible from applet
-
-    }
-    m_dh = new DOM2Helper();
+      m_dh = new DOM2Helper();
   }
 
   /**
--- a/src/com/sun/org/apache/xml/internal/serializer/Utils.java	Fri Jul 29 04:24:19 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2003-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: Utils.java,v 1.2.4.1 2005/09/15 08:15:30 suresh_emailid Exp $
- */
-package com.sun.org.apache.xml.internal.serializer;
-
-import java.util.Hashtable;
-
-/**
- * This class contains utilities used by the serializer
- */
-class Utils
-{
-
-    /**
-     * This nested class acts as a way to lazy load the hashtable
-     * in a thread safe way.
-     */
-    static private class CacheHolder
-    {
-        static final Hashtable cache;
-        static {
-            cache = new Hashtable();
-        }
-    }
-    /**
-     * Load the class by name.
-     *
-     * This implementation, for performance reasons,
-     * caches all classes loaded by name and
-     * returns the cached Class object if it can previously
-     * loaded classes that were load by name.  If not previously loaded
-     * an attempt is made to load with Class.forName(classname)
-     * @param classname the name of the class to be loaded
-     * @return the loaded class, never null. If the class could not be
-     * loaded a ClassNotFound exception is thrown.
-     * @throws ClassNotFoundException if the class was not loaded
-     */
-    static Class ClassForName(String classname) throws ClassNotFoundException
-    {
-        Class c;
-        // the first time the next line runs will reference
-        // CacheHolder, causing the class to load and create the
-        // Hashtable.
-        Object o = CacheHolder.cache.get(classname);
-        if (o == null)
-        {
-            // class was not in the cache, so try to load it
-            c = Class.forName(classname);
-            // if the class is not found we will have thrown a
-            // ClassNotFoundException on the statement above
-
-            // if we get here c is not null
-            CacheHolder.cache.put(classname, c);
-        }
-        else
-        {
-            c = (Class)o;
-        }
-        return c;
-    }
-}
--- a/src/com/sun/org/apache/xml/internal/serializer/utils/Utils.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/serializer/utils/Utils.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2003-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,8 +22,6 @@
  */
 package com.sun.org.apache.xml.internal.serializer.utils;
 
-import java.util.Hashtable;
-
 /**
  * This class contains utilities used by the serializer.
  *
--- a/src/com/sun/org/apache/xml/internal/utils/DOMHelper.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/utils/DOMHelper.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,18 +22,16 @@
  */
 package com.sun.org.apache.xml.internal.utils;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
+import com.sun.org.apache.xml.internal.res.XMLErrorResources;
+import com.sun.org.apache.xml.internal.res.XMLMessages;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Vector;
-
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-
-import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
-import com.sun.org.apache.xml.internal.res.XMLErrorResources;
-import com.sun.org.apache.xml.internal.res.XMLMessages;
-
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -565,7 +563,7 @@
   /**
    * An experiment for the moment.
    */
-  Hashtable m_NSInfos = new Hashtable();
+  Map<Node, NSInfo> m_NSInfos = new HashMap<>();
 
   /** Object to put into the m_NSInfos table that tells that a node has not been
    *  processed, but has xmlns namespace decls.  */
@@ -623,9 +621,7 @@
 
     if (Node.ATTRIBUTE_NODE != ntype)
     {
-      Object nsObj = m_NSInfos.get(n);  // return value
-
-      nsInfo = (nsObj == null) ? null : (NSInfo) nsObj;
+      nsInfo = m_NSInfos.get(n);
       hasProcessedNS = (nsInfo == null) ? false : nsInfo.m_hasProcessedNS;
     }
     else
@@ -751,9 +747,7 @@
 
           if (null != parent)
           {
-            Object nsObj = m_NSInfos.get(parent);  // return value
-
-            nsInfo = (nsObj == null) ? null : (NSInfo) nsObj;
+            nsInfo = m_NSInfos.get(parent);
           }
         }
 
@@ -770,12 +764,12 @@
 
               if (candidateInfo == m_NSInfoUnProcWithoutXMLNS)
               {
-                m_NSInfos.put(m_candidateNoAncestorXMLNS.elementAt(i),
+                m_NSInfos.put((Node)m_candidateNoAncestorXMLNS.elementAt(i),
                               m_NSInfoUnProcNoAncestorXMLNS);
               }
               else if (candidateInfo == m_NSInfoNullWithoutXMLNS)
               {
-                m_NSInfos.put(m_candidateNoAncestorXMLNS.elementAt(i),
+                m_NSInfos.put((Node)m_candidateNoAncestorXMLNS.elementAt(i),
                               m_NSInfoNullNoAncestorXMLNS);
               }
             }
--- a/src/com/sun/org/apache/xml/internal/utils/ElemDesc.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/utils/ElemDesc.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
@@ -22,7 +22,9 @@
  */
 package com.sun.org.apache.xml.internal.utils;
 
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
+
 
 /**
  * This class is in support of SerializerToHTML, and acts as a sort
@@ -33,7 +35,7 @@
 {
 
   /** Table of attributes for the element */
-  Hashtable m_attrs = null;
+  Map<String, Integer> m_attrs = null;
 
   /** Element's flags, describing the role this element plays during
    * formatting of the document. This is used as a bitvector; more than one flag
@@ -157,9 +159,9 @@
   {
 
     if (null == m_attrs)
-      m_attrs = new Hashtable();
+      m_attrs = new HashMap<>();
 
-    m_attrs.put(name, new Integer(flags));
+    m_attrs.put(name, flags);
   }
 
   /**
@@ -178,11 +180,11 @@
 
     if (null != m_attrs)
     {
-      Integer _flags = (Integer) m_attrs.get(name);
+      Integer _flags = m_attrs.get(name);
 
       if (null != _flags)
       {
-        return (_flags.intValue() & flags) != 0;
+        return (_flags & flags) != 0;
       }
     }
 
--- a/src/com/sun/org/apache/xml/internal/utils/NamespaceSupport2.java	Fri Jul 29 04:24:19 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,751 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 1999-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: NamespaceSupport2.java,v 1.3 2005/09/28 13:49:20 pvedula Exp $
- */
-package com.sun.org.apache.xml.internal.utils;
-
-import java.util.EmptyStackException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * Encapsulate Namespace tracking logic for use by SAX drivers.
- *
- * <p>This class is an attempt to rewrite the SAX NamespaceSupport
- * "helper" class for improved efficiency. It can be used to track the
- * namespace declarations currently in scope, providing lookup
- * routines to map prefixes to URIs and vice versa.</p>
- *
- * <p>ISSUE: For testing purposes, I've extended NamespaceSupport even
- * though I'm completely reasserting all behaviors and fields.
- * Wasteful.... But SAX did not put an interface under that object and
- * we seem to have written that SAX class into our APIs... and I don't
- * want to argue with it right now. </p>
- *
- * @see org.xml.sax.helpers.NamespaceSupport
- * */
-public class NamespaceSupport2
-    extends org.xml.sax.helpers.NamespaceSupport
-{
-    ////////////////////////////////////////////////////////////////////
-    // Internal state.
-    ////////////////////////////////////////////////////////////////////
-
-    private Context2 currentContext; // Current point on the double-linked stack
-
-
-    ////////////////////////////////////////////////////////////////////
-    // Constants.
-    ////////////////////////////////////////////////////////////////////
-
-
-    /**
-     * The XML Namespace as a constant.
-     *
-     * <p>This is the Namespace URI that is automatically mapped
-     * to the "xml" prefix.</p>
-     */
-    public final static String XMLNS =
-        "http://www.w3.org/XML/1998/namespace";
-
-
-    ////////////////////////////////////////////////////////////////////
-    // Constructor.
-    ////////////////////////////////////////////////////////////////////
-
-
-    /**
-     * Create a new Namespace support object.
-     */
-    public NamespaceSupport2 ()
-    {
-        reset();
-    }
-
-
-    ////////////////////////////////////////////////////////////////////
-    // Context management.
-    ////////////////////////////////////////////////////////////////////
-
-
-    /**
-     * Reset this Namespace support object for reuse.
-     *
-     * <p>It is necessary to invoke this method before reusing the
-     * Namespace support object for a new session.</p>
-     */
-    public void reset ()
-    {
-        // Discarding the whole stack doesn't save us a lot versus
-        // creating a new NamespaceSupport. Do we care, or should we
-        // change this to just reset the root context?
-        currentContext = new Context2(null);
-        currentContext.declarePrefix("xml", XMLNS);
-    }
-
-
-    /**
-     * Start a new Namespace context.
-     *
-     * <p>Normally, you should push a new context at the beginning
-     * of each XML element: the new context will automatically inherit
-     * the declarations of its parent context, but it will also keep
-     * track of which declarations were made within this context.</p>
-     *
-     * <p>The Namespace support object always starts with a base context
-     * already in force: in this context, only the "xml" prefix is
-     * declared.</p>
-     *
-     * @see #popContext
-     */
-    public void pushContext ()
-    {
-        // JJK: Context has a parent pointer.
-        // That means we don't need a stack to pop.
-        // We may want to retain for reuse, but that can be done via
-        // a child pointer.
-
-        Context2 parentContext=currentContext;
-        currentContext = parentContext.getChild();
-        if (currentContext == null){
-                currentContext = new Context2(parentContext);
-            }
-        else{
-            // JJK: This will wipe out any leftover data
-            // if we're reusing a previously allocated Context.
-            currentContext.setParent(parentContext);
-        }
-    }
-
-
-    /**
-     * Revert to the previous Namespace context.
-     *
-     * <p>Normally, you should pop the context at the end of each
-     * XML element.  After popping the context, all Namespace prefix
-     * mappings that were previously in force are restored.</p>
-     *
-     * <p>You must not attempt to declare additional Namespace
-     * prefixes after popping a context, unless you push another
-     * context first.</p>
-     *
-     * @see #pushContext
-     */
-    public void popContext ()
-    {
-        Context2 parentContext=currentContext.getParent();
-        if(parentContext==null)
-            throw new EmptyStackException();
-        else
-            currentContext = parentContext;
-    }
-
-
-
-    ////////////////////////////////////////////////////////////////////
-    // Operations within a context.
-    ////////////////////////////////////////////////////////////////////
-
-
-    /**
-     * Declare a Namespace prefix.
-     *
-     * <p>This method declares a prefix in the current Namespace
-     * context; the prefix will remain in force until this context
-     * is popped, unless it is shadowed in a descendant context.</p>
-     *
-     * <p>To declare a default Namespace, use the empty string.  The
-     * prefix must not be "xml" or "xmlns".</p>
-     *
-     * <p>Note that you must <em>not</em> declare a prefix after
-     * you've pushed and popped another Namespace.</p>
-     *
-     * <p>Note that there is an asymmetry in this library: while {@link
-     * #getPrefix getPrefix} will not return the default "" prefix,
-     * even if you have declared one; to check for a default prefix,
-     * you have to look it up explicitly using {@link #getURI getURI}.
-     * This asymmetry exists to make it easier to look up prefixes
-     * for attribute names, where the default prefix is not allowed.</p>
-     *
-     * @param prefix The prefix to declare, or null for the empty
-     *        string.
-     * @param uri The Namespace URI to associate with the prefix.
-     * @return true if the prefix was legal, false otherwise
-     * @see #processName
-     * @see #getURI
-     * @see #getPrefix
-     */
-    public boolean declarePrefix (String prefix, String uri)
-    {
-        if (prefix.equals("xml") || prefix.equals("xmlns")) {
-            return false;
-        } else {
-            currentContext.declarePrefix(prefix, uri);
-            return true;
-        }
-    }
-
-
-    /**
-     * Process a raw XML 1.0 name.
-     *
-     * <p>This method processes a raw XML 1.0 name in the current
-     * context by removing the prefix and looking it up among the
-     * prefixes currently declared.  The return value will be the
-     * array supplied by the caller, filled in as follows:</p>
-     *
-     * <dl>
-     * <dt>parts[0]</dt>
-     * <dd>The Namespace URI, or an empty string if none is
-     *  in use.</dd>
-     * <dt>parts[1]</dt>
-     * <dd>The local name (without prefix).</dd>
-     * <dt>parts[2]</dt>
-     * <dd>The original raw name.</dd>
-     * </dl>
-     *
-     * <p>All of the strings in the array will be internalized.  If
-     * the raw name has a prefix that has not been declared, then
-     * the return value will be null.</p>
-     *
-     * <p>Note that attribute names are processed differently than
-     * element names: an unprefixed element name will received the
-     * default Namespace (if any), while an unprefixed element name
-     * will not.</p>
-     *
-     * @param qName The raw XML 1.0 name to be processed.
-     * @param parts A string array supplied by the caller, capable of
-     *        holding at least three members.
-     * @param isAttribute A flag indicating whether this is an
-     *        attribute name (true) or an element name (false).
-     * @return The supplied array holding three internalized strings
-     *        representing the Namespace URI (or empty string), the
-     *        local name, and the raw XML 1.0 name; or null if there
-     *        is an undeclared prefix.
-     * @see #declarePrefix
-     * @see java.lang.String#intern */
-    public String [] processName (String qName, String[] parts,
-                                  boolean isAttribute)
-    {
-        String[] name=currentContext.processName(qName, isAttribute);
-        if(name==null)
-            return null;
-
-        // JJK: This recopying is required because processName may return
-        // a cached result. I Don't Like It. *****
-        System.arraycopy(name,0,parts,0,3);
-        return parts;
-    }
-
-
-    /**
-     * Look up a prefix and get the currently-mapped Namespace URI.
-     *
-     * <p>This method looks up the prefix in the current context.
-     * Use the empty string ("") for the default Namespace.</p>
-     *
-     * @param prefix The prefix to look up.
-     * @return The associated Namespace URI, or null if the prefix
-     *         is undeclared in this context.
-     * @see #getPrefix
-     * @see #getPrefixes
-     */
-    public String getURI (String prefix)
-    {
-        return currentContext.getURI(prefix);
-    }
-
-
-    /**
-     * Return an enumeration of all prefixes currently declared.
-     *
-     * <p><strong>Note:</strong> if there is a default prefix, it will not be
-     * returned in this enumeration; check for the default prefix
-     * using the {@link #getURI getURI} with an argument of "".</p>
-     *
-     * @return An enumeration of all prefixes declared in the
-     *         current context except for the empty (default)
-     *         prefix.
-     * @see #getDeclaredPrefixes
-     * @see #getURI
-     */
-    public Enumeration getPrefixes ()
-    {
-        return currentContext.getPrefixes();
-    }
-
-
-    /**
-     * Return one of the prefixes mapped to a Namespace URI.
-     *
-     * <p>If more than one prefix is currently mapped to the same
-     * URI, this method will make an arbitrary selection; if you
-     * want all of the prefixes, use the {@link #getPrefixes}
-     * method instead.</p>
-     *
-     * <p><strong>Note:</strong> this will never return the empty
-     * (default) prefix; to check for a default prefix, use the {@link
-     * #getURI getURI} method with an argument of "".</p>
-     *
-     * @param uri The Namespace URI.
-     * @return One of the prefixes currently mapped to the URI supplied,
-     *         or null if none is mapped or if the URI is assigned to
-     *         the default Namespace.
-     * @see #getPrefixes(java.lang.String)
-     * @see #getURI */
-    public String getPrefix (String uri)
-    {
-        return currentContext.getPrefix(uri);
-    }
-
-
-    /**
-     * Return an enumeration of all prefixes currently declared for a URI.
-     *
-     * <p>This method returns prefixes mapped to a specific Namespace
-     * URI.  The xml: prefix will be included.  If you want only one
-     * prefix that's mapped to the Namespace URI, and you don't care
-     * which one you get, use the {@link #getPrefix getPrefix}
-     *  method instead.</p>
-     *
-     * <p><strong>Note:</strong> the empty (default) prefix is
-     * <em>never</em> included in this enumeration; to check for the
-     * presence of a default Namespace, use the {@link #getURI getURI}
-     * method with an argument of "".</p>
-     *
-     * @param uri The Namespace URI.
-     * @return An enumeration of all prefixes declared in the
-     *         current context.
-     * @see #getPrefix
-     * @see #getDeclaredPrefixes
-     * @see #getURI */
-    public Enumeration getPrefixes (String uri)
-    {
-        // JJK: The old code involved creating a vector, filling it
-        // with all the matching prefixes, and then getting its
-        // elements enumerator. Wastes storage, wastes cycles if we
-        // don't actually need them all. Better to either implement
-        // a specific enumerator for these prefixes... or a filter
-        // around the all-prefixes enumerator, which comes out to
-        // roughly the same thing.
-        //
-        // **** Currently a filter. That may not be most efficient
-        // when I'm done restructuring storage!
-        return new PrefixForUriEnumerator(this,uri,getPrefixes());
-    }
-
-
-    /**
-     * Return an enumeration of all prefixes declared in this context.
-     *
-     * <p>The empty (default) prefix will be included in this
-     * enumeration; note that this behaviour differs from that of
-     * {@link #getPrefix} and {@link #getPrefixes}.</p>
-     *
-     * @return An enumeration of all prefixes declared in this
-     *         context.
-     * @see #getPrefixes
-     * @see #getURI
-     */
-    public Enumeration getDeclaredPrefixes ()
-    {
-        return currentContext.getDeclaredPrefixes();
-    }
-
-
-
-}
-
-////////////////////////////////////////////////////////////////////
-// Local classes.
-// These were _internal_ classes... but in fact they don't have to be,
-// and may be more efficient if they aren't.
-////////////////////////////////////////////////////////////////////
-
-/**
- * Implementation of Enumeration filter, wrapped
- * aroung the get-all-prefixes version of the operation. This is NOT
- * necessarily the most efficient approach; finding the URI and then asking
- * what prefixes apply to it might make much more sense.
- */
-class PrefixForUriEnumerator implements Enumeration
-{
-    private Enumeration allPrefixes;
-    private String uri;
-    private String lookahead=null;
-    private NamespaceSupport2 nsup;
-
-    // Kluge: Since one can't do a constructor on an
-    // anonymous class (as far as I know)...
-    PrefixForUriEnumerator(NamespaceSupport2 nsup,String uri, Enumeration allPrefixes)
-    {
-        this.nsup=nsup;
-        this.uri=uri;
-        this.allPrefixes=allPrefixes;
-    }
-
-    public boolean hasMoreElements()
-    {
-        if(lookahead!=null)
-            return true;
-
-        while(allPrefixes.hasMoreElements())
-            {
-                String prefix=(String)allPrefixes.nextElement();
-                if(uri.equals(nsup.getURI(prefix)))
-                    {
-                        lookahead=prefix;
-                        return true;
-                    }
-            }
-        return false;
-    }
-
-    public Object nextElement()
-    {
-        if(hasMoreElements())
-            {
-                String tmp=lookahead;
-                lookahead=null;
-                return tmp;
-            }
-        else
-            throw new java.util.NoSuchElementException();
-    }
-}
-
-/**
- * Internal class for a single Namespace context.
- *
- * <p>This module caches and reuses Namespace contexts, so the number allocated
- * will be equal to the element depth of the document, not to the total
- * number of elements (i.e. 5-10 rather than tens of thousands).</p>
- */
-final class Context2 {
-
-    ////////////////////////////////////////////////////////////////
-    // Manefest Constants
-    ////////////////////////////////////////////////////////////////
-
-    /**
-     * An empty enumeration.
-     */
-    private final static Enumeration EMPTY_ENUMERATION =
-        new Vector().elements();
-
-    ////////////////////////////////////////////////////////////////
-    // Protected state.
-    ////////////////////////////////////////////////////////////////
-
-    Hashtable prefixTable;
-    Hashtable uriTable;
-    Hashtable elementNameTable;
-    Hashtable attributeNameTable;
-    String defaultNS = null;
-
-    ////////////////////////////////////////////////////////////////
-    // Internal state.
-    ////////////////////////////////////////////////////////////////
-
-    private Vector declarations = null;
-    private boolean tablesDirty = false;
-    private Context2 parent = null;
-    private Context2 child = null;
-
-    /**
-     * Create a new Namespace context.
-     */
-    Context2 (Context2 parent)
-    {
-        if(parent==null)
-            {
-                prefixTable = new Hashtable();
-                uriTable = new Hashtable();
-                elementNameTable=null;
-                attributeNameTable=null;
-            }
-        else
-            setParent(parent);
-    }
-
-
-    /**
-     * @returns The child Namespace context object, or null if this
-     * is the last currently on the chain.
-     */
-    Context2 getChild()
-    {
-        return child;
-    }
-
-    /**
-     * @returns The parent Namespace context object, or null if this
-     * is the root.
-     */
-    Context2 getParent()
-    {
-        return parent;
-    }
-
-    /**
-     * (Re)set the parent of this Namespace context.
-     * This is separate from the c'tor because it's re-applied
-     * when a Context2 is reused by push-after-pop.
-     *
-     * @param parent The parent Namespace context object.
-     */
-    void setParent (Context2 parent)
-    {
-        this.parent = parent;
-        parent.child = this;        // JJK: Doubly-linked
-        declarations = null;
-        prefixTable = parent.prefixTable;
-        uriTable = parent.uriTable;
-        elementNameTable = parent.elementNameTable;
-        attributeNameTable = parent.attributeNameTable;
-        defaultNS = parent.defaultNS;
-        tablesDirty = false;
-    }
-
-
-    /**
-     * Declare a Namespace prefix for this context.
-     *
-     * @param prefix The prefix to declare.
-     * @param uri The associated Namespace URI.
-     * @see org.xml.sax.helpers.NamespaceSupport2#declarePrefix
-     */
-    void declarePrefix (String prefix, String uri)
-    {
-                                // Lazy processing...
-        if (!tablesDirty) {
-            copyTables();
-        }
-        if (declarations == null) {
-            declarations = new Vector();
-        }
-
-        prefix = prefix.intern();
-        uri = uri.intern();
-        if ("".equals(prefix)) {
-            if ("".equals(uri)) {
-                defaultNS = null;
-            } else {
-                defaultNS = uri;
-            }
-        } else {
-            prefixTable.put(prefix, uri);
-            uriTable.put(uri, prefix); // may wipe out another prefix
-        }
-        declarations.addElement(prefix);
-    }
-
-
-    /**
-     * Process a raw XML 1.0 name in this context.
-     *
-     * @param qName The raw XML 1.0 name.
-     * @param isAttribute true if this is an attribute name.
-     * @return An array of three strings containing the
-     *         URI part (or empty string), the local part,
-     *         and the raw name, all internalized, or null
-     *         if there is an undeclared prefix.
-     * @see org.xml.sax.helpers.NamespaceSupport2#processName
-     */
-    String [] processName (String qName, boolean isAttribute)
-    {
-        String name[];
-        Hashtable table;
-
-                                // Select the appropriate table.
-        if (isAttribute) {
-            if(elementNameTable==null)
-                elementNameTable=new Hashtable();
-            table = elementNameTable;
-        } else {
-            if(attributeNameTable==null)
-                attributeNameTable=new Hashtable();
-            table = attributeNameTable;
-        }
-
-                                // Start by looking in the cache, and
-                                // return immediately if the name
-                                // is already known in this content
-        name = (String[])table.get(qName);
-        if (name != null) {
-            return name;
-        }
-
-                                // We haven't seen this name in this
-                                // context before.
-        name = new String[3];
-        int index = qName.indexOf(':');
-
-
-                                // No prefix.
-        if (index == -1) {
-            if (isAttribute || defaultNS == null) {
-                name[0] = "";
-            } else {
-                name[0] = defaultNS;
-            }
-            name[1] = qName.intern();
-            name[2] = name[1];
-        }
-
-                                // Prefix
-        else {
-            String prefix = qName.substring(0, index);
-            String local = qName.substring(index+1);
-            String uri;
-            if ("".equals(prefix)) {
-                uri = defaultNS;
-            } else {
-                uri = (String)prefixTable.get(prefix);
-            }
-            if (uri == null) {
-                return null;
-            }
-            name[0] = uri;
-            name[1] = local.intern();
-            name[2] = qName.intern();
-        }
-
-                                // Save in the cache for future use.
-        table.put(name[2], name);
-        tablesDirty = true;
-        return name;
-    }
-
-
-    /**
-     * Look up the URI associated with a prefix in this context.
-     *
-     * @param prefix The prefix to look up.
-     * @return The associated Namespace URI, or null if none is
-     *         declared.
-     * @see org.xml.sax.helpers.NamespaceSupport2#getURI
-     */
-    String getURI (String prefix)
-    {
-        if ("".equals(prefix)) {
-            return defaultNS;
-        } else if (prefixTable == null) {
-            return null;
-        } else {
-            return (String)prefixTable.get(prefix);
-        }
-    }
-
-
-    /**
-     * Look up one of the prefixes associated with a URI in this context.
-     *
-     * <p>Since many prefixes may be mapped to the same URI,
-     * the return value may be unreliable.</p>
-     *
-     * @param uri The URI to look up.
-     * @return The associated prefix, or null if none is declared.
-     * @see org.xml.sax.helpers.NamespaceSupport2#getPrefix
-     */
-    String getPrefix (String uri)
-    {
-        if (uriTable == null) {
-            return null;
-        } else {
-            return (String)uriTable.get(uri);
-        }
-    }
-
-
-    /**
-     * Return an enumeration of prefixes declared in this context.
-     *
-     * @return An enumeration of prefixes (possibly empty).
-     * @see org.xml.sax.helpers.NamespaceSupport2#getDeclaredPrefixes
-     */
-    Enumeration getDeclaredPrefixes ()
-    {
-        if (declarations == null) {
-            return EMPTY_ENUMERATION;
-        } else {
-            return declarations.elements();
-        }
-    }
-
-
-    /**
-     * Return an enumeration of all prefixes currently in force.
-     *
-     * <p>The default prefix, if in force, is <em>not</em>
-     * returned, and will have to be checked for separately.</p>
-     *
-     * @return An enumeration of prefixes (never empty).
-     * @see org.xml.sax.helpers.NamespaceSupport2#getPrefixes
-     */
-    Enumeration getPrefixes ()
-    {
-        if (prefixTable == null) {
-            return EMPTY_ENUMERATION;
-        } else {
-            return prefixTable.keys();
-        }
-    }
-
-    ////////////////////////////////////////////////////////////////
-    // Internal methods.
-    ////////////////////////////////////////////////////////////////
-
-    /**
-     * Copy on write for the internal tables in this context.
-     *
-     * <p>This class is optimized for the normal case where most
-     * elements do not contain Namespace declarations. In that case,
-     * the Context2 will share data structures with its parent.
-     * New tables are obtained only when new declarations are issued,
-     * so they can be popped off the stack.</p>
-     *
-     * <p> JJK: **** Alternative: each Context2 might declare
-     *  _only_ its local bindings, and delegate upward if not found.</p>
-     */
-    private void copyTables ()
-    {
-        // Start by copying our parent's bindings
-        prefixTable = (Hashtable)prefixTable.clone();
-        uriTable = (Hashtable)uriTable.clone();
-
-        // Replace the caches with empty ones, rather than
-        // trying to determine which bindings should be flushed.
-        // As far as I can tell, these caches are never actually
-        // used in Xalan... More efficient to remove the whole
-        // cache system? ****
-        if(elementNameTable!=null)
-            elementNameTable=new Hashtable();
-        if(attributeNameTable!=null)
-            attributeNameTable=new Hashtable();
-        tablesDirty = true;
-    }
-
-}
-
-
-// end of NamespaceSupport2.java
--- a/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -17,9 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: TreeWalker.java,v 1.2.4.1 2005/09/15 08:15:59 suresh_emailid Exp $
- */
+
 package com.sun.org.apache.xml.internal.utils;
 
 import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
@@ -81,7 +79,7 @@
 
         /**
    * Constructor.
-   * @param   contentHandler The implemention of the
+   * @param   contentHandler The implementation of the
    * @param   systemId System identifier for the document.
    * contentHandler operation (toXMLString, digest, ...)
    */
@@ -89,15 +87,8 @@
   {
     this.m_contentHandler = contentHandler;
     m_contentHandler.setDocumentLocator(m_locator);
-    if (systemId != null)
+    if (systemId != null) {
         m_locator.setSystemId(systemId);
-    else {
-        try {
-          // Bug see Bugzilla  26741
-          m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
-         }
-         catch (SecurityException se) {// user.dir not accessible from applet
-         }
     }
     m_dh = dh;
   }
@@ -111,31 +102,19 @@
   {
     this.m_contentHandler = contentHandler;
     m_contentHandler.setDocumentLocator(m_locator);
-    try {
-       // Bug see Bugzilla  26741
-      m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
-    }
-    catch (SecurityException se){// user.dir not accessible from applet
-    }
     m_dh = dh;
   }
 
   /**
    * Constructor.
-   * @param   contentHandler The implemention of the
+   * @param   contentHandler The implementation of the
    * contentHandler operation (toXMLString, digest, ...)
    */
   public TreeWalker(ContentHandler contentHandler)
   {
     this.m_contentHandler = contentHandler;
-                if (m_contentHandler != null)
-                        m_contentHandler.setDocumentLocator(m_locator);
-                try {
-                   // Bug see Bugzilla  26741
-                  m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
-                }
-                catch (SecurityException se){// user.dir not accessible from applet
-
+    if (m_contentHandler != null) {
+        m_contentHandler.setDocumentLocator(m_locator);
     }
     m_dh = new DOM2Helper();
   }
--- a/src/com/sun/org/apache/xpath/internal/compiler/Keywords.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xpath/internal/compiler/Keywords.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *      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,
@@ -22,267 +22,369 @@
  */
 package com.sun.org.apache.xpath.internal.compiler;
 
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Table of strings to operation code lookups.
+ *
  * @xsl.usage internal
  */
-public class Keywords
-{
+public class Keywords {
 
-  /** Table of keywords to opcode associations. */
-  private static Hashtable m_keywords = new Hashtable();
+    /**
+     * Table of keywords to opcode associations.
+     */
+    private static final Map<String, Integer> m_keywords;
 
-  /** Table of axes names to opcode associations. */
-  private static Hashtable m_axisnames = new Hashtable();
+    /**
+     * Table of axes names to opcode associations.
+     */
+    private static final Map<String, Integer> m_axisnames;
 
-  /** Table of function name to function ID associations. */
-  private static Hashtable m_nodetests = new Hashtable();
+    /**
+     * Table of function name to function ID associations.
+     */
+    private static final Map<String, Integer> m_nodetests;
 
-  /** Table of node type strings to opcode associations. */
-  private static Hashtable m_nodetypes = new Hashtable();
+    /**
+     * Table of node type strings to opcode associations.
+     */
+    private static final Map<String, Integer> m_nodetypes;
 
-  /** ancestor axes string. */
-  private static final String FROM_ANCESTORS_STRING = "ancestor";
+    /**
+     * ancestor axes string.
+     */
+    private static final String FROM_ANCESTORS_STRING = "ancestor";
 
-  /** ancestor-or-self axes string. */
-  private static final String FROM_ANCESTORS_OR_SELF_STRING =
-    "ancestor-or-self";
+    /**
+     * ancestor-or-self axes string.
+     */
+    private static final String FROM_ANCESTORS_OR_SELF_STRING
+            = "ancestor-or-self";
 
-  /** attribute axes string. */
-  private static final String FROM_ATTRIBUTES_STRING = "attribute";
+    /**
+     * attribute axes string.
+     */
+    private static final String FROM_ATTRIBUTES_STRING = "attribute";
 
-  /** child axes string. */
-  private static final String FROM_CHILDREN_STRING = "child";
+    /**
+     * child axes string.
+     */
+    private static final String FROM_CHILDREN_STRING = "child";
 
-  /** descendant-or-self axes string. */
-  private static final String FROM_DESCENDANTS_STRING = "descendant";
+    /**
+     * descendant-or-self axes string.
+     */
+    private static final String FROM_DESCENDANTS_STRING = "descendant";
 
-  /** ancestor axes string. */
-  private static final String FROM_DESCENDANTS_OR_SELF_STRING =
-    "descendant-or-self";
+    /**
+     * ancestor axes string.
+     */
+    private static final String FROM_DESCENDANTS_OR_SELF_STRING
+            = "descendant-or-self";
 
-  /** following axes string. */
-  private static final String FROM_FOLLOWING_STRING = "following";
+    /**
+     * following axes string.
+     */
+    private static final String FROM_FOLLOWING_STRING = "following";
 
-  /** following-sibling axes string. */
-  private static final String FROM_FOLLOWING_SIBLINGS_STRING =
-    "following-sibling";
+    /**
+     * following-sibling axes string.
+     */
+    private static final String FROM_FOLLOWING_SIBLINGS_STRING
+            = "following-sibling";
 
-  /** parent axes string. */
-  private static final String FROM_PARENT_STRING = "parent";
+    /**
+     * parent axes string.
+     */
+    private static final String FROM_PARENT_STRING = "parent";
 
-  /** preceding axes string. */
-  private static final String FROM_PRECEDING_STRING = "preceding";
+    /**
+     * preceding axes string.
+     */
+    private static final String FROM_PRECEDING_STRING = "preceding";
 
-  /** preceding-sibling axes string. */
-  private static final String FROM_PRECEDING_SIBLINGS_STRING =
-    "preceding-sibling";
+    /**
+     * preceding-sibling axes string.
+     */
+    private static final String FROM_PRECEDING_SIBLINGS_STRING
+            = "preceding-sibling";
 
-  /** self axes string. */
-  private static final String FROM_SELF_STRING = "self";
+    /**
+     * self axes string.
+     */
+    private static final String FROM_SELF_STRING = "self";
 
-  /** namespace axes string. */
-  private static final String FROM_NAMESPACE_STRING = "namespace";
+    /**
+     * namespace axes string.
+     */
+    private static final String FROM_NAMESPACE_STRING = "namespace";
 
-  /** self axes abreviated string. */
-  private static final String FROM_SELF_ABBREVIATED_STRING = ".";
+    /**
+     * self axes abreviated string.
+     */
+    private static final String FROM_SELF_ABBREVIATED_STRING = ".";
 
-  /** comment node test string. */
-  private static final String NODETYPE_COMMENT_STRING = "comment";
+    /**
+     * comment node test string.
+     */
+    private static final String NODETYPE_COMMENT_STRING = "comment";
 
-  /** text node test string. */
-  private static final String NODETYPE_TEXT_STRING = "text";
+    /**
+     * text node test string.
+     */
+    private static final String NODETYPE_TEXT_STRING = "text";
 
-  /** processing-instruction node test string. */
-  private static final String NODETYPE_PI_STRING = "processing-instruction";
+    /**
+     * processing-instruction node test string.
+     */
+    private static final String NODETYPE_PI_STRING = "processing-instruction";
 
-  /** Any node test string. */
-  private static final String NODETYPE_NODE_STRING = "node";
+    /**
+     * Any node test string.
+     */
+    private static final String NODETYPE_NODE_STRING = "node";
 
-  /** Wildcard element string. */
-  private static final String NODETYPE_ANYELEMENT_STRING = "*";
+    /**
+     * Wildcard element string.
+     */
+    private static final String NODETYPE_ANYELEMENT_STRING = "*";
 
-  /** current function string. */
-  public static final String FUNC_CURRENT_STRING = "current";
+    /**
+     * current function string.
+     */
+    public static final String FUNC_CURRENT_STRING = "current";
 
-  /** last function string. */
-  public static final String FUNC_LAST_STRING = "last";
+    /**
+     * last function string.
+     */
+    public static final String FUNC_LAST_STRING = "last";
 
-  /** position function string. */
-  public static final String FUNC_POSITION_STRING = "position";
+    /**
+     * position function string.
+     */
+    public static final String FUNC_POSITION_STRING = "position";
 
-  /** count function string. */
-  public static final String FUNC_COUNT_STRING = "count";
+    /**
+     * count function string.
+     */
+    public static final String FUNC_COUNT_STRING = "count";
 
-  /** id function string. */
-  static final String FUNC_ID_STRING = "id";
+    /**
+     * id function string.
+     */
+    static final String FUNC_ID_STRING = "id";
 
-  /** key function string (XSLT). */
-  public static final String FUNC_KEY_STRING = "key";
+    /**
+     * key function string (XSLT).
+     */
+    public static final String FUNC_KEY_STRING = "key";
 
-  /** local-name function string. */
-  public static final String FUNC_LOCAL_PART_STRING = "local-name";
+    /**
+     * local-name function string.
+     */
+    public static final String FUNC_LOCAL_PART_STRING = "local-name";
 
-  /** namespace-uri function string. */
-  public static final String FUNC_NAMESPACE_STRING = "namespace-uri";
+    /**
+     * namespace-uri function string.
+     */
+    public static final String FUNC_NAMESPACE_STRING = "namespace-uri";
 
-  /** name function string. */
-  public static final String FUNC_NAME_STRING = "name";
+    /**
+     * name function string.
+     */
+    public static final String FUNC_NAME_STRING = "name";
 
-  /** generate-id function string (XSLT). */
-  public static final String FUNC_GENERATE_ID_STRING = "generate-id";
+    /**
+     * generate-id function string (XSLT).
+     */
+    public static final String FUNC_GENERATE_ID_STRING = "generate-id";
 
-  /** not function string. */
-  public static final String FUNC_NOT_STRING = "not";
+    /**
+     * not function string.
+     */
+    public static final String FUNC_NOT_STRING = "not";
 
-  /** true function string. */
-  public static final String FUNC_TRUE_STRING = "true";
+    /**
+     * true function string.
+     */
+    public static final String FUNC_TRUE_STRING = "true";
 
-  /** false function string. */
-  public static final String FUNC_FALSE_STRING = "false";
-
-  /** boolean function string. */
-  public static final String FUNC_BOOLEAN_STRING = "boolean";
+    /**
+     * false function string.
+     */
+    public static final String FUNC_FALSE_STRING = "false";
 
-  /** lang function string. */
-  public static final String FUNC_LANG_STRING = "lang";
+    /**
+     * boolean function string.
+     */
+    public static final String FUNC_BOOLEAN_STRING = "boolean";
 
-  /** number function string. */
-  public static final String FUNC_NUMBER_STRING = "number";
+    /**
+     * lang function string.
+     */
+    public static final String FUNC_LANG_STRING = "lang";
 
-  /** floor function string. */
-  public static final String FUNC_FLOOR_STRING = "floor";
+    /**
+     * number function string.
+     */
+    public static final String FUNC_NUMBER_STRING = "number";
 
-  /** ceiling function string. */
-  public static final String FUNC_CEILING_STRING = "ceiling";
+    /**
+     * floor function string.
+     */
+    public static final String FUNC_FLOOR_STRING = "floor";
 
-  /** round function string. */
-  public static final String FUNC_ROUND_STRING = "round";
+    /**
+     * ceiling function string.
+     */
+    public static final String FUNC_CEILING_STRING = "ceiling";
 
-  /** sum function string. */
-  public static final String FUNC_SUM_STRING = "sum";
+    /**
+     * round function string.
+     */
+    public static final String FUNC_ROUND_STRING = "round";
 
-  /** string function string. */
-  public static final String FUNC_STRING_STRING = "string";
+    /**
+     * sum function string.
+     */
+    public static final String FUNC_SUM_STRING = "sum";
 
-  /** starts-with function string. */
-  public static final String FUNC_STARTS_WITH_STRING = "starts-with";
+    /**
+     * string function string.
+     */
+    public static final String FUNC_STRING_STRING = "string";
 
-  /** contains function string. */
-  public static final String FUNC_CONTAINS_STRING = "contains";
+    /**
+     * starts-with function string.
+     */
+    public static final String FUNC_STARTS_WITH_STRING = "starts-with";
 
-  /** substring-before function string. */
-  public static final String FUNC_SUBSTRING_BEFORE_STRING =
-    "substring-before";
+    /**
+     * contains function string.
+     */
+    public static final String FUNC_CONTAINS_STRING = "contains";
 
-  /** substring-after function string. */
-  public static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after";
+    /**
+     * substring-before function string.
+     */
+    public static final String FUNC_SUBSTRING_BEFORE_STRING
+            = "substring-before";
 
-  /** normalize-space function string. */
-  public static final String FUNC_NORMALIZE_SPACE_STRING = "normalize-space";
+    /**
+     * substring-after function string.
+     */
+    public static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after";
 
-  /** translate function string. */
-  public static final String FUNC_TRANSLATE_STRING = "translate";
+    /**
+     * normalize-space function string.
+     */
+    public static final String FUNC_NORMALIZE_SPACE_STRING = "normalize-space";
 
-  /** concat function string. */
-  public static final String FUNC_CONCAT_STRING = "concat";
+    /**
+     * translate function string.
+     */
+    public static final String FUNC_TRANSLATE_STRING = "translate";
+
+    /**
+     * concat function string.
+     */
+    public static final String FUNC_CONCAT_STRING = "concat";
 
-  /** system-property function string. */
-  public static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property";
+    /**
+     * system-property function string.
+     */
+    public static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property";
 
-  /** function-available function string (XSLT). */
-  public static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING =
-    "function-available";
+    /**
+     * function-available function string (XSLT).
+     */
+    public static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING
+            = "function-available";
 
-  /** element-available function string (XSLT). */
-  public static final String FUNC_EXT_ELEM_AVAILABLE_STRING =
-    "element-available";
+    /**
+     * element-available function string (XSLT).
+     */
+    public static final String FUNC_EXT_ELEM_AVAILABLE_STRING
+            = "element-available";
 
-  /** substring function string. */
-  public static final String FUNC_SUBSTRING_STRING = "substring";
+    /**
+     * substring function string.
+     */
+    public static final String FUNC_SUBSTRING_STRING = "substring";
 
-  /** string-length function string. */
-  public static final String FUNC_STRING_LENGTH_STRING = "string-length";
+    /**
+     * string-length function string.
+     */
+    public static final String FUNC_STRING_LENGTH_STRING = "string-length";
 
-  /** unparsed-entity-uri function string (XSLT). */
-  public static final String FUNC_UNPARSED_ENTITY_URI_STRING =
-    "unparsed-entity-uri";
+    /**
+     * unparsed-entity-uri function string (XSLT).
+     */
+    public static final String FUNC_UNPARSED_ENTITY_URI_STRING
+            = "unparsed-entity-uri";
 
   // Proprietary, built in functions
+    /**
+     * current function string (Proprietary).
+     */
+    public static final String FUNC_DOCLOCATION_STRING = "document-location";
 
-  /** current function string (Proprietary). */
-  public static final String FUNC_DOCLOCATION_STRING = "document-location";
+    static {
+        Map<String, Integer> keywords = new HashMap<>();
+        Map<String, Integer> axisnames = new HashMap<>();
+        Map<String, Integer> nodetests = new HashMap<>();
+        Map<String, Integer> nodetypes = new HashMap<>();
+
+        axisnames.put(FROM_ANCESTORS_STRING, OpCodes.FROM_ANCESTORS);
+        axisnames.put(FROM_ANCESTORS_OR_SELF_STRING, OpCodes.FROM_ANCESTORS_OR_SELF);
+        axisnames.put(FROM_ATTRIBUTES_STRING, OpCodes.FROM_ATTRIBUTES);
+        axisnames.put(FROM_CHILDREN_STRING, OpCodes.FROM_CHILDREN);
+        axisnames.put(FROM_DESCENDANTS_STRING, OpCodes.FROM_DESCENDANTS);
+        axisnames.put(FROM_DESCENDANTS_OR_SELF_STRING, OpCodes.FROM_DESCENDANTS_OR_SELF);
+        axisnames.put(FROM_FOLLOWING_STRING, OpCodes.FROM_FOLLOWING);
+        axisnames.put(FROM_FOLLOWING_SIBLINGS_STRING, OpCodes.FROM_FOLLOWING_SIBLINGS);
+        axisnames.put(FROM_PARENT_STRING, OpCodes.FROM_PARENT);
+        axisnames.put(FROM_PRECEDING_STRING, OpCodes.FROM_PRECEDING);
+        axisnames.put(FROM_PRECEDING_SIBLINGS_STRING, OpCodes.FROM_PRECEDING_SIBLINGS);
+        axisnames.put(FROM_SELF_STRING, OpCodes.FROM_SELF);
+        axisnames.put(FROM_NAMESPACE_STRING, OpCodes.FROM_NAMESPACE);
+        m_axisnames = Collections.unmodifiableMap(axisnames);
 
-  static
-  {
-    m_axisnames.put(FROM_ANCESTORS_STRING,
-                    new Integer(OpCodes.FROM_ANCESTORS));
-    m_axisnames.put(FROM_ANCESTORS_OR_SELF_STRING,
-                    new Integer(OpCodes.FROM_ANCESTORS_OR_SELF));
-    m_axisnames.put(FROM_ATTRIBUTES_STRING,
-                    new Integer(OpCodes.FROM_ATTRIBUTES));
-    m_axisnames.put(FROM_CHILDREN_STRING,
-                    new Integer(OpCodes.FROM_CHILDREN));
-    m_axisnames.put(FROM_DESCENDANTS_STRING,
-                    new Integer(OpCodes.FROM_DESCENDANTS));
-    m_axisnames.put(FROM_DESCENDANTS_OR_SELF_STRING,
-                    new Integer(OpCodes.FROM_DESCENDANTS_OR_SELF));
-    m_axisnames.put(FROM_FOLLOWING_STRING,
-                    new Integer(OpCodes.FROM_FOLLOWING));
-    m_axisnames.put(FROM_FOLLOWING_SIBLINGS_STRING,
-                    new Integer(OpCodes.FROM_FOLLOWING_SIBLINGS));
-    m_axisnames.put(FROM_PARENT_STRING,
-                    new Integer(OpCodes.FROM_PARENT));
-    m_axisnames.put(FROM_PRECEDING_STRING,
-                    new Integer(OpCodes.FROM_PRECEDING));
-    m_axisnames.put(FROM_PRECEDING_SIBLINGS_STRING,
-                    new Integer(OpCodes.FROM_PRECEDING_SIBLINGS));
-    m_axisnames.put(FROM_SELF_STRING,
-                    new Integer(OpCodes.FROM_SELF));
-    m_axisnames.put(FROM_NAMESPACE_STRING,
-                    new Integer(OpCodes.FROM_NAMESPACE));
-    m_nodetypes.put(NODETYPE_COMMENT_STRING,
-                    new Integer(OpCodes.NODETYPE_COMMENT));
-    m_nodetypes.put(NODETYPE_TEXT_STRING,
-                    new Integer(OpCodes.NODETYPE_TEXT));
-    m_nodetypes.put(NODETYPE_PI_STRING,
-                    new Integer(OpCodes.NODETYPE_PI));
-    m_nodetypes.put(NODETYPE_NODE_STRING,
-                    new Integer(OpCodes.NODETYPE_NODE));
-    m_nodetypes.put(NODETYPE_ANYELEMENT_STRING,
-                    new Integer(OpCodes.NODETYPE_ANYELEMENT));
-    m_keywords.put(FROM_SELF_ABBREVIATED_STRING,
-                   new Integer(OpCodes.FROM_SELF));
-    m_keywords.put(FUNC_ID_STRING,
-                   new Integer(FunctionTable.FUNC_ID));
-    m_keywords.put(FUNC_KEY_STRING,
-                   new Integer(FunctionTable.FUNC_KEY));
+        nodetypes.put(NODETYPE_COMMENT_STRING, OpCodes.NODETYPE_COMMENT);
+        nodetypes.put(NODETYPE_TEXT_STRING, OpCodes.NODETYPE_TEXT);
+        nodetypes.put(NODETYPE_PI_STRING, OpCodes.NODETYPE_PI);
+        nodetypes.put(NODETYPE_NODE_STRING, OpCodes.NODETYPE_NODE);
+        nodetypes.put(NODETYPE_ANYELEMENT_STRING, OpCodes.NODETYPE_ANYELEMENT);
+        m_nodetypes = Collections.unmodifiableMap(nodetypes);
+
+        keywords.put(FROM_SELF_ABBREVIATED_STRING, OpCodes.FROM_SELF);
+        keywords.put(FUNC_ID_STRING, FunctionTable.FUNC_ID);
+        keywords.put(FUNC_KEY_STRING, FunctionTable.FUNC_KEY);
+        m_keywords = Collections.unmodifiableMap(keywords);
 
-    m_nodetests.put(NODETYPE_COMMENT_STRING,
-                    new Integer(OpCodes.NODETYPE_COMMENT));
-    m_nodetests.put(NODETYPE_TEXT_STRING,
-                    new Integer(OpCodes.NODETYPE_TEXT));
-    m_nodetests.put(NODETYPE_PI_STRING,
-                    new Integer(OpCodes.NODETYPE_PI));
-    m_nodetests.put(NODETYPE_NODE_STRING,
-                    new Integer(OpCodes.NODETYPE_NODE));
-  }
+        nodetests.put(NODETYPE_COMMENT_STRING, OpCodes.NODETYPE_COMMENT);
+        nodetests.put(NODETYPE_TEXT_STRING, OpCodes.NODETYPE_TEXT);
+        nodetests.put(NODETYPE_PI_STRING, OpCodes.NODETYPE_PI);
+        nodetests.put(NODETYPE_NODE_STRING, OpCodes.NODETYPE_NODE);
+        m_nodetests = Collections.unmodifiableMap(nodetests);
+    }
+
+    static Integer getAxisName(String key) {
+        return m_axisnames.get(key);
+    }
 
-  static Object getAxisName(String key){
-          return m_axisnames.get(key);
-  }
-
-  static Object lookupNodeTest(String key){
-          return m_nodetests.get(key);
-  }
+    static Integer lookupNodeTest(String key) {
+        return m_nodetests.get(key);
+    }
 
-  static Object getKeyWord(String key){
-          return m_keywords.get(key);
-  }
+    static Integer getKeyWord(String key) {
+        return m_keywords.get(key);
+    }
 
-  static Object getNodeType(String key){
-          return m_nodetypes.get(key);
-  }
+    static Integer getNodeType(String key) {
+        return m_nodetypes.get(key);
+    }
 }
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java	Wed Sep 07 06:06:32 2016 +0100
@@ -486,7 +486,7 @@
      "Fehler aufgetreten."},
 
   { ER_ILLEGAL_VARIABLE_REFERENCE,
-      "VariableReference au\u00DFerhalb des Kontextes oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
+      "VariableReference au\u00DFerhalb des Kontexts oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
 
   { ER_AXES_NOT_ALLOWED,
       "Nur \"child::\"- und \"attribute::\"-Achsen sind in Vergleichsmustern zul\u00E4ssig. Betreffende Achsen = {0}"},
@@ -858,7 +858,7 @@
       "Option \"-E\" nicht unterst\u00FCtzt f\u00FCr DTM-Parser"},
 
   { WG_ILLEGAL_VARIABLE_REFERENCE,
-      "VariableReference au\u00DFerhalb des Kontextes oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
+      "VariableReference au\u00DFerhalb des Kontexts oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
 
   { WG_UNSUPPORTED_ENCODING,
      "Nicht unterst\u00FCtzte Codierung: {0}"},
--- a/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_ko.java	Wed Sep 07 06:06:32 2016 +0100
@@ -870,7 +870,7 @@
   { "help_language", "ko"},
   { "language", "ko"},
   { "BAD_CODE", "createMessage\uC5D0 \uB300\uD55C \uB9E4\uAC1C\uBCC0\uC218\uAC00 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4."},
-  { "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678 \uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
+  { "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
   { "version", ">>>>>>> Xalan \uBC84\uC804 "},
   { "version2", "<<<<<<<"},
   { "yes", "\uC608"},
--- a/src/com/sun/xml/internal/stream/Entity.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/xml/internal/stream/Entity.java	Wed Sep 07 06:06:32 2016 +0100
@@ -344,6 +344,9 @@
         // to know that prolog is read
         public boolean xmlDeclChunkRead = false;
 
+        // flag to indicate whether the Entity is a General Entity
+        public boolean isGE = false;
+
         /** returns the name of the current encoding
          *  @return current encoding name
          */
@@ -388,10 +391,11 @@
         //
 
         /** Constructs a scanned entity. */
-        public ScannedEntity(String name,
+        public ScannedEntity(boolean isGE, String name,
                 XMLResourceIdentifier entityLocation,
                 InputStream stream, Reader reader,
                 String encoding, boolean literal, boolean mayReadChunks, boolean isExternal) {
+            this.isGE = isGE;
             this.name = name ;
             this.entityLocation = entityLocation;
             this.stream = stream;
--- a/src/com/sun/xml/internal/stream/XMLEntityStorage.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/xml/internal/stream/XMLEntityStorage.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,19 +25,20 @@
 
 package com.sun.xml.internal.stream;
 
-import java.util.Hashtable;
-
+import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.impl.PropertyManager;
+import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
+import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.URI;
 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
-import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
-import com.sun.org.apache.xerces.internal.impl.PropertyManager;
-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  *
@@ -62,7 +63,7 @@
     protected boolean fWarnDuplicateEntityDef;
 
     /** Entities. */
-    protected Hashtable fEntities = new Hashtable();
+    protected Map<String, Entity> fEntities = new HashMap<>();
 
     protected Entity.ScannedEntity fCurrentEntity ;
 
@@ -138,7 +139,7 @@
      * @see SymbolTable
      */
     public Entity getEntity(String name) {
-        return (Entity)fEntities.get(name);
+        return fEntities.get(name);
     } // getEntity(String)
 
     public boolean hasEntities() {
@@ -150,7 +151,7 @@
     } // getEntity(String)
 
     public Enumeration getEntityKeys() {
-        return fEntities.keys();
+        return Collections.enumeration(fEntities.keySet());
     }
     /**
      * Adds an internal entity declaration.
@@ -263,7 +264,7 @@
      */
     public boolean isExternalEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -280,7 +281,7 @@
      */
     public boolean isEntityDeclInExternalSubset(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -333,7 +334,7 @@
      */
     public boolean isUnparsedEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         if (entity == null) {
             return false;
         }
@@ -348,7 +349,7 @@
      */
     public boolean isDeclaredEntity(String entityName) {
 
-        Entity entity = (Entity)fEntities.get(entityName);
+        Entity entity = fEntities.get(entityName);
         return entity != null;
     }
     /**
--- a/src/com/sun/xml/internal/stream/dtd/nonvalidating/DTDGrammar.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/com/sun/xml/internal/stream/dtd/nonvalidating/DTDGrammar.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,15 +1,15 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
  *
- * 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
+ *     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,
@@ -20,20 +20,20 @@
 
 package com.sun.xml.internal.stream.dtd.nonvalidating;
 
-import java.util.Hashtable;
-import java.util.ArrayList;
-import java.util.List;
-
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.QName;
-import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * A DTD grammar. This class implements the XNI handler interfaces
@@ -140,10 +140,10 @@
     private int fAttributeDeclNextAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
 
     /** Element index mapping table. */
-    private QNameHashtable fElementIndexMap = new QNameHashtable();
+    private final Map<String, Integer> fElementIndexMap = new HashMap<>();
 
     /** Temporary qualified name. */
-    private QName fQName = new QName();
+    private final QName fQName = new QName();
 
     /** Temporary Attribute decl. */
     protected XMLAttributeDecl fAttributeDecl = new XMLAttributeDecl();
@@ -156,7 +156,7 @@
 
 
     /** table of XMLElementDecl   */
-    Hashtable   fElementDeclTab     = new Hashtable();
+    Map<String, XMLElementDecl> fElementDeclTab = new HashMap<>();
 
     /** Default constructor. */
     public DTDGrammar(SymbolTable symbolTable) {
@@ -213,7 +213,7 @@
     public void elementDecl(String name, String contentModel, Augmentations augs)
     throws XNIException {
 
-        XMLElementDecl tmpElementDecl = (XMLElementDecl) fElementDeclTab.get(name) ;
+        XMLElementDecl tmpElementDecl = fElementDeclTab.get(name) ;
         if ( tmpElementDecl != null ) {
             if (tmpElementDecl.type == -1) {
                 fCurrentElementIndex = getElementDeclIndex(name);
@@ -299,7 +299,7 @@
             normalizeDefaultAttrValue(defaultValue);
         }
 
-        if ( this.fElementDeclTab.containsKey( (String) elementName) ) {
+        if ( this.fElementDeclTab.containsKey(elementName)) {
             //if ElementDecl has already being created in the Grammar then remove from table,
             //this.fElementDeclTab.remove( (String) elementName );
         }
@@ -431,7 +431,10 @@
      * @return index of the elementDeclName in scope
      */
     public int getElementDeclIndex(String elementDeclName) {
-        int mapping = fElementIndexMap.get(elementDeclName);
+        Integer mapping = fElementIndexMap.get(elementDeclName);
+        if (mapping == null) {
+            mapping = -1;
+        }
         //System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping);
         return mapping;
     } // getElementDeclIndex(String):int
@@ -824,127 +827,6 @@
         return newarray;
     }
 
-    //
-    // Classes
-    //
-
-
-    /**
-     * A simple Hashtable implementation that takes a tuple (String, String)
-     * as the key and a int as value.
-     *
-     * @author Eric Ye, IBM
-     * @author Andy Clark, IBM
-     */
-    protected static final class QNameHashtable {
-
-        //
-        // Constants
-        //
-        public static final boolean UNIQUE_STRINGS = true;
-
-        /** Initial bucket size (4). */
-        private static final int INITIAL_BUCKET_SIZE = 4;
-
-        // NOTE: Changed previous hashtable size from 512 to 101 so
-        //       that we get a better distribution for hashing. -Ac
-        /** Hashtable size (101). */
-        private static final int HASHTABLE_SIZE = 101;
-
-        //
-        // Data
-        //
-        private Object[][] fHashTable = new Object[HASHTABLE_SIZE][];
-
-        //
-        // Public methods
-        //
-        /** Associates the given value with the specified key tuple. */
-        public void put(String key, int value) {
-
-            // REVISIT: Why +2? -Ac
-            int hash = (hash(key)+2) % HASHTABLE_SIZE;
-            Object[] bucket = fHashTable[hash];
-
-            if (bucket == null) {
-                bucket = new Object[1 + 2*INITIAL_BUCKET_SIZE];
-                bucket[0] = new int[]{1};
-                bucket[1] = key;
-                bucket[2] = new int[]{value};
-                fHashTable[hash] = bucket;
-            } else {
-                int count = ((int[])bucket[0])[0];
-                int offset = 1 + 2*count;
-                if (offset == bucket.length) {
-                    int newSize = count + INITIAL_BUCKET_SIZE;
-                    Object[] newBucket = new Object[1 + 2*newSize];
-                    System.arraycopy(bucket, 0, newBucket, 0, offset);
-                    bucket = newBucket;
-                    fHashTable[hash] = bucket;
-                }
-                boolean found = false;
-                int j=1;
-                for (int i=0; i<count; i++){
-                    if ((String)bucket[j] == key) {
-                        ((int[])bucket[j+1])[0] = value;
-                        found = true;
-                        break;
-                    }
-                    j += 2;
-                }
-                if (! found) {
-                    bucket[offset++] = key;
-                    bucket[offset]= new int[]{value};
-                    ((int[])bucket[0])[0] = ++count;
-                }
-
-            }
-            //System.out.println("put("+key+" -> "+value+')');
-            //System.out.println("get("+key+") -> "+get(key));
-
-        } // put(int,String,String,int)
-
-        /** Returns the value associated with the specified key tuple. */
-        public int get(String key) {
-            int hash = (hash(key)+2) % HASHTABLE_SIZE;
-            Object[] bucket = fHashTable[hash];
-
-            if (bucket == null) {
-                return -1;
-            }
-            int count = ((int[])bucket[0])[0];
-
-            int j=1;
-            for (int i=0; i<count; i++){
-                if ((String)bucket[j] == key) {
-                    return ((int[])bucket[j+1])[0];
-                }
-                j += 2;
-            }
-            return -1;
-
-        } // get(int,String,String)
-
-        //
-        // Protected methods
-        //
-
-        /** Returns a hash value for the specified symbol. */
-        protected int hash(String symbol) {
-
-            if (symbol == null) {
-                return 0;
-            }
-            int code = 0;
-            int length = symbol.length();
-            for (int i = 0; i < length; i++) {
-                code = code * 37 + symbol.charAt(i);
-            }
-            return code & 0x7FFFFFF;
-
-        } // hash(String):int
-
-    }  // class QNameHashtable
     /**
      * Normalize the attribute value of a non CDATA default attribute
      * collapsing sequences of space characters (x20)
--- a/src/org/xml/sax/helpers/NamespaceSupport.java	Fri Jul 29 04:24:19 2016 +0100
+++ b/src/org/xml/sax/helpers/NamespaceSupport.java	Wed Sep 07 06:06:32 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -31,10 +31,13 @@
 
 package org.xml.sax.helpers;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.EmptyStackException;
 import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -138,7 +141,7 @@
      * An empty enumeration.
      */
     private final static Enumeration EMPTY_ENUMERATION =
-        new Vector().elements();
+            Collections.enumeration(new ArrayList<String>());
 
 
     ////////////////////////////////////////////////////////////////////
@@ -462,15 +465,15 @@
      */
     public Enumeration getPrefixes (String uri)
     {
-        Vector prefixes = new Vector();
+        List<String> prefixes = new ArrayList<>();
         Enumeration allPrefixes = getPrefixes();
         while (allPrefixes.hasMoreElements()) {
             String prefix = (String)allPrefixes.nextElement();
             if (uri.equals(getURI(prefix))) {
-                prefixes.addElement(prefix);
+                prefixes.add(prefix);
             }
         }
-        return prefixes.elements();
+        return Collections.enumeration(prefixes);
     }
 
 
@@ -618,7 +621,7 @@
                 copyTables();
             }
             if (declarations == null) {
-                declarations = new Vector();
+                declarations = new ArrayList<>();
             }
 
             prefix = prefix.intern();
@@ -633,7 +636,7 @@
                 prefixTable.put(prefix, uri);
                 uriTable.put(uri, prefix); // may wipe out another prefix
             }
-            declarations.addElement(prefix);
+            declarations.add(prefix);
         }
 
 
@@ -651,33 +654,33 @@
         String [] processName (String qName, boolean isAttribute)
         {
             String name[];
-            Hashtable table;
+            Map<String, String[]> table;
 
-                                // Select the appropriate table.
+            // Select the appropriate table.
             if (isAttribute) {
                 table = attributeNameTable;
             } else {
                 table = elementNameTable;
             }
 
-                                // Start by looking in the cache, and
-                                // return immediately if the name
-                                // is already known in this content
+            // Start by looking in the cache, and
+            // return immediately if the name
+            // is already known in this content
             name = (String[])table.get(qName);
             if (name != null) {
                 return name;
             }
 
-                                // We haven't seen this name in this
-                                // context before.  Maybe in the parent
-                                // context, but we can't assume prefix
-                                // bindings are the same.
+            // We haven't seen this name in this
+            // context before.  Maybe in the parent
+            // context, but we can't assume prefix
+            // bindings are the same.
             name = new String[3];
             name[2] = qName.intern();
             int index = qName.indexOf(':');
 
 
-                                // No prefix.
+            // No prefix.
             if (index == -1) {
                 if (isAttribute) {
                     if (qName == "xmlns" && namespaceDeclUris)
@@ -692,7 +695,7 @@
                 name[1] = name[2];
             }
 
-                                // Prefix
+            // Prefix
             else {
                 String prefix = qName.substring(0, index);
                 String local = qName.substring(index+1);
@@ -710,8 +713,8 @@
                 name[1] = local.intern();
             }
 
-                                // Save in the cache for future use.
-                                // (Could be shared with parent context...)
+            // Save in the cache for future use.
+            // (Could be shared with parent context...)
             table.put(name[2], name);
             return name;
         }
@@ -768,11 +771,10 @@
             if (declarations == null) {
                 return EMPTY_ENUMERATION;
             } else {
-                return declarations.elements();
+                return Collections.enumeration(declarations);
             }
         }
 
-
         /**
          * Return an enumeration of all prefixes currently in force.
          *
@@ -787,7 +789,7 @@
             if (prefixTable == null) {
                 return EMPTY_ENUMERATION;
             } else {
-                return prefixTable.keys();
+                return Collections.enumeration(prefixTable.keySet());
             }
         }
 
@@ -807,17 +809,17 @@
         private void copyTables ()
         {
             if (prefixTable != null) {
-                prefixTable = (Hashtable)prefixTable.clone();
+                prefixTable = new HashMap<>(prefixTable);
             } else {
-                prefixTable = new Hashtable();
+                prefixTable = new HashMap<>();
             }
             if (uriTable != null) {
-                uriTable = (Hashtable)uriTable.clone();
+                uriTable = new HashMap<>(uriTable);
             } else {
-                uriTable = new Hashtable();
+                uriTable = new HashMap<>();
             }
-            elementNameTable = new Hashtable();
-            attributeNameTable = new Hashtable();
+            elementNameTable = new HashMap<>();
+            attributeNameTable = new HashMap<>();
             declSeen = true;
         }
 
@@ -827,10 +829,10 @@
         // Protected state.
         ////////////////////////////////////////////////////////////////
 
-        Hashtable prefixTable;
-        Hashtable uriTable;
-        Hashtable elementNameTable;
-        Hashtable attributeNameTable;
+        Map<String, String> prefixTable;
+        Map<String, String> uriTable;
+        Map<String, String[]> elementNameTable;
+        Map<String, String[]> attributeNameTable;
         String defaultNS = null;
 
 
@@ -839,7 +841,7 @@
         // Internal state.
         ////////////////////////////////////////////////////////////////
 
-        private Vector declarations = null;
+        private List<String> declarations = null;
         private boolean declSeen = false;
         private Context parent = null;
     }