# HG changeset patch # User andrew # Date 1473224792 -3600 # Node ID 80897e67a1b382d9d9ef523f7b994bcd0d309ccb # Parent 887a572ef17a585ac72aa6b17a48285f0f155ff0# Parent b198ece212c1f7ff382d9282624411a260b52a55 Merge jdk7u111-b01 diff -r 887a572ef17a -r 80897e67a1b3 .hgtags --- 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 diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/XalanConstants.java --- 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 */ diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java --- 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 stringTable = new HashMap<>(); for (int i = 0; i < nl.getLength(); i++) { diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/lib/Extensions.java --- 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 h = envChecker.getEnvironmentHash(); resultNode = factoryDocument.createElement("checkEnvironmentExtension"); envChecker.appendEnvironmentReport(resultNode, factoryDocument, h); envChecker = null; diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java --- 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.)]"}, diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java --- 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, diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java --- 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"}, diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java --- 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"}, diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java --- 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 = ""; /** diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java --- 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 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.

* - * @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 getEnvironmentHash() { // Setup a hash to store various environment information in - Hashtable hash = new Hashtable(); + Map 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. * *

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.

* - * @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 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 entry : h.entrySet()) { + String keyStr = entry.getKey(); + try { + // Special processing for classes found.. + if (keyStr.startsWith(FOUNDCLASSES)) { + List v = (ArrayList)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 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 v1 : v) { + for (Map.Entry 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 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 entry : h.entrySet()) { + String keyStr = entry.getKey(); + try { + // Special processing for classes found.. + if (keyStr.startsWith(FOUNDCLASSES)) { + List v = (List)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 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 v1 : v) { + for (Map.Entry 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 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 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 checkPathForJars(String cp, String[] jars) { if ((null == cp) || (null == jars) || (0 == cp.length()) || (0 == jars.length)) return null; - Vector v = new Vector(); + List 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 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 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 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 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 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 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 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 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 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 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 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. */ diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/DOM.java --- 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 getElementsWithIDs(); } diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java --- 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 children = elements(); + while (children.hasNext()) { + final SyntaxTreeNode child = children.next(); if (child instanceof Sort) { sortObjects.addElement(child); } diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java --- 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 // elements. Other elements cause an error. - final Vector contents = getContents(); + final List contents = getContents(); final int count = contents.size(); for (int i=0; i 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 attributes = elements(); + while (attributes.hasNext()) { final XslAttribute attribute = - (XslAttribute)attributes.nextElement(); + (XslAttribute)attributes.next(); buf.append(attribute); } return(buf.toString()); diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java --- 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 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 elements = elements(); + while (elements.hasNext()) { + final Expression exp = (Expression)elements.next(); exp.translate(classGen, methodGen); il.append(append); } diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java --- 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 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; diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java --- 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 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); diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java --- 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 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); diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java --- 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 _internal2Java = new MultiHashtable<>(); // Legal conversions between Java and internal types. - private static final Hashtable _java2Internal = new Hashtable(); + private static final Map, Type> JAVA2INTERNAL; // The mappings between EXSLT extension namespaces and implementation classes - private static final Hashtable _extensionNamespaceTable = new Hashtable(); + private static final Map EXTENSIONNAMESPACE; // Extension functions that are implemented in BasisLibrary - private static final Hashtable _extensionFunctionTable = new Hashtable(); + private static final Map 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, Type> java2Internal = new HashMap<>(); + Map extensionNamespaceTable = new HashMap<>(); + Map 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 { diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java --- 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 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); diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java --- 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 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); diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java --- 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, diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java --- 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 _attributeElements = null; + private Map _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> getNamespaceScope(SyntaxTreeNode node) { + Map all = new HashMap<>(); while (node != null) { - Hashtable mapping = node.getPrefixMapping(); + Map 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> include = getNamespaceScope(this); + for (Map.Entry 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 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 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 @@ * 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 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 chooseContents = child.getContents(); + for (SyntaxTreeNode chooseChild : chooseContents) { if (chooseChild instanceof When || chooseChild instanceof Otherwise) { if (canProduceAttributeNodes(chooseChild, false)) return true; diff -r 887a572ef17a -r 80897e67a1b3 src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java --- 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 _neededTemplates = new HashMap<>(); /** * A mapping between named templates and Mode objects. */ - private Hashtable _namedTemplates = new Hashtable(); + private Map _namedTemplates = new HashMap<>(); /** * A mapping between templates and instruction handles. */ - private Hashtable _templateIHs = new Hashtable(); + private Map _templateIHs = new HashMap<>(); /** * A mapping between templates and instruction lists. */ - private Hashtable _templateILs = new Hashtable(); + private Map _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 _importLevels = null; /** * A mapping between key names and keys. */ - private Hashtable _keys = null; + private Map _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 keys) { _keys = keys; /* @@ -300,7 +301,7 @@ */ private void flattenAlternative(Pattern pattern, Template template, - Hashtable keys) { + Map 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