# HG changeset patch # User aefimov # Date 1430222663 -10800 # Node ID 5734d1775f7982f2735cb83451e3caec70776626 # Parent 5b5e5ea9c8dd9e4ad6e06fc8bd61df249ae57ffd 8068842: Better JAXP data handling Reviewed-by: joehw, dfuchs, lancea diff -r 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/ExsltSets.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/Extensions.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/Extensions.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/lib/Extensions.java Tue Apr 28 15:04:23 2015 +0300 @@ -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,27 +22,23 @@ */ 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.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 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; /** @@ -312,7 +308,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java Tue Apr 28 15:04:23 2015 +0300 @@ -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,17 +23,17 @@ package com.sun.org.apache.xalan.internal.xslt; 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; @@ -169,7 +169,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); @@ -212,13 +212,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 @@ -238,22 +238,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; } @@ -263,39 +263,28 @@ "#---- BEGIN writeEnvironmentReport($Revision: 1.7 $): 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( @@ -346,14 +335,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)) @@ -363,32 +352,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 + " -----"); @@ -406,10 +383,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)) { @@ -426,7 +403,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; } @@ -436,47 +413,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"); @@ -498,7 +463,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 @@ -506,7 +471,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)) @@ -514,37 +479,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; } @@ -558,15 +511,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 @@ -594,22 +547,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 @@ -650,20 +603,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()) @@ -683,37 +636,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); } } } @@ -744,8 +692,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))) { @@ -779,13 +727,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(); final Class noArgs[] = new Class[0]; Class clazz = null; @@ -829,13 +777,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 { @@ -918,13 +866,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 { @@ -982,13 +930,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 { @@ -1017,13 +965,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 @@ -1095,13 +1043,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 @@ -1184,17 +1132,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"); @@ -1283,6 +1231,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java Tue Apr 28 15:04:23 2015 +0300 @@ -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); @@ -202,10 +201,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java Tue Apr 28 15:04:23 2015 +0300 @@ -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; @@ -53,6 +46,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 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 @@ -132,31 +133,38 @@ 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){ this.type = type; this.distance = distance; } - public boolean equals(Object query){ - return 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); + } } } @@ -167,99 +175,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, Type>(); + 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) { @@ -290,7 +311,7 @@ public String getClassNameFromUri(String uri) { - String className = (String)_extensionNamespaceTable.get(uri); + String className = EXTENSIONNAMESPACE.get(uri); if (className != null) return className; @@ -370,7 +391,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); @@ -450,15 +471,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; @@ -583,9 +604,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 @@ -617,7 +638,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); } diff -r 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 * @@ -23,10 +23,7 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler; -import java.io.File; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.Enumeration; +import java.util.Iterator; import com.sun.org.apache.xml.internal.utils.SystemIDResolver; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; @@ -121,10 +118,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 * @@ -23,11 +23,7 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler; -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 com.sun.org.apache.xml.internal.utils.SystemIDResolver; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; @@ -121,10 +117,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java Tue Apr 28 15:04:23 2015 +0300 @@ -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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java Tue Apr 28 15:04:23 2015 +0300 @@ -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,13 @@ 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.List; +import java.util.Map; +import java.util.Set; /** * @author Jacek Ambroziak @@ -49,8 +49,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 +85,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) { @@ -107,12 +106,12 @@ // Check if we have any declared namesaces if (_accessedPrefixes == null) { - _accessedPrefixes = new Hashtable(); + _accessedPrefixes = new HashMap(); } 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 +168,7 @@ */ public void addAttribute(SyntaxTreeNode attribute) { if (_attributeElements == null) { - _attributeElements = new Vector(2); + _attributeElements = new ArrayList(2); } _attributeElements.add(attribute); } @@ -179,9 +178,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 +190,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 +203,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(); - if (mapping != null) { - Enumeration prefixes = mapping.keys(); - while (prefixes.hasMoreElements()) { - String prefix = (String)prefixes.nextElement(); + while (node != null) { + Map mapping = node.getPrefixMapping(); + if (mapping != null) { + for( String prefix : mapping.keySet()) { if (!all.containsKey(prefix)) { all.put(prefix, mapping.get(prefix)); } @@ -223,7 +217,7 @@ } node = node.getParent(); } - return(all.keys()); + return all.entrySet(); } /** @@ -288,9 +282,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 +350,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 +384,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 +435,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 +481,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 +520,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 5b5e5ea9c8dd -r 5734d1775f79 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java Fri Oct 23 16:41:06 2015 -0400 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java Tue Apr 28 15:04:23 2015 +0300 @@ -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). @@ -564,15 +565,13 @@ MethodGenerator methodGen, InstructionHandle next) { - Enumeration templates = _namedTemplates.keys(); - while (templates.hasMoreElements()) { - final Template template = (Template)templates.nextElement(); + Set