--- old/make/java/java/FILES_java.gmk Tue Sep 13 13:52:39 2011 +++ new/make/java/java/FILES_java.gmk Tue Sep 13 13:52:39 2011 @@ -208,7 +208,6 @@ java/util/Observable.java \ java/util/Observer.java \ java/util/Properties.java \ - java/util/XMLUtils.java \ java/util/InvalidPropertiesFormatException.java \ java/util/PropertyPermission.java \ java/util/PropertyResourceBundle.java \ --- old/make/sun/Makefile Tue Sep 13 13:52:41 2011 +++ new/make/sun/Makefile Tue Sep 13 13:52:41 2011 @@ -68,7 +68,7 @@ endif # nio need to be compiled before awt to have all charsets ready -SUBDIRS = jar security javazic misc net nio text launcher +SUBDIRS = jar security javazic misc net nio text util launcher ifdef BUILD_HEADLESS_ONLY DISPLAY_LIBS = awt $(HEADLESS_SUBDIR) --- old/src/share/classes/java/util/Properties.java Tue Sep 13 13:52:43 2011 +++ new/src/share/classes/java/util/Properties.java Tue Sep 13 13:52:42 2011 @@ -34,6 +34,7 @@ import java.io.Writer; import java.io.OutputStreamWriter; import java.io.BufferedWriter; +import java.lang.reflect.*; /** * The Properties class represents a persistent set of @@ -1111,4 +1112,61 @@ private static final char[] hexDigit = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; + + + static class XMLUtils { + private static Method load = null; + private static Method save = null; + static { + try { + // reference sun.util.xml.Utils reflectively + // to allow the Properties class be compiled in + // the absence of XML + Class c = Class.forName("sun.util.xml.XMLUtils", true, null); + load = c.getMethod("load", Properties.class, InputStream.class); + save = c.getMethod("save", Properties.class, OutputStream.class, + String.class, String.class); + } catch (ClassNotFoundException cnf) { + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + } + + static void invoke(Method m, Object... args) throws IOException { + try { + m.invoke(null, args); + } catch (IllegalAccessException e) { + throw new AssertionError(e); + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof RuntimeException) + throw (RuntimeException)t; + + if (t instanceof IOException) { + throw (IOException)t; + } else { + throw new AssertionError(t); + } + } + } + + static void load(Properties props, InputStream in) + throws IOException, InvalidPropertiesFormatException + { + if (load == null) + throw new InternalError("sun.util.xml.XMLUtils not found"); + + invoke(load, props, in); + } + + static void save(Properties props, OutputStream os, String comment, + String encoding) + throws IOException + { + if (save == null) + throw new InternalError("sun.util.xml.XMLUtils not found"); + + invoke(save, props, os, comment, encoding); + } + } } --- /dev/null Tue Sep 13 13:52:45 2011 +++ new/make/sun/util/Makefile Tue Sep 13 13:52:44 2011 @@ -0,0 +1,40 @@ +# +# Copyright (c) 2011, 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 +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +BUILDDIR = ../.. +PACKAGE = sun.util +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +# +# Files +# +AUTO_FILES_JAVA_DIRS = sun/util/xml + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk + --- old/src/share/classes/java/util/XMLUtils.java Tue Sep 13 13:52:47 2011 +++ /dev/null Tue Sep 13 13:52:47 2011 @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2003, 2010, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.util; - -import java.io.*; -import org.xml.sax.*; -import org.xml.sax.helpers.*; -import org.w3c.dom.*; -import javax.xml.parsers.*; -import javax.xml.transform.*; -import javax.xml.transform.dom.*; -import javax.xml.transform.stream.*; - -/** - * A class used to aid in Properties load and save in XML. Keeping this - * code outside of Properties helps reduce the number of classes loaded - * when Properties is loaded. - * - * @author Michael McCloskey - * @since 1.3 - */ -class XMLUtils { - - // XML loading and saving methods for Properties - - // The required DTD URI for exported properties - private static final String PROPS_DTD_URI = - "http://java.sun.com/dtd/properties.dtd"; - - private static final String PROPS_DTD = - "" + - "" + - ""+ - "" + - "" + - "" + - ""; - - /** - * Version number for the format of exported properties files. - */ - private static final String EXTERNAL_XML_VERSION = "1.0"; - - static void load(Properties props, InputStream in) - throws IOException, InvalidPropertiesFormatException - { - Document doc = null; - try { - doc = getLoadingDoc(in); - } catch (SAXException saxe) { - throw new InvalidPropertiesFormatException(saxe); - } - Element propertiesElement = (Element)doc.getChildNodes().item(1); - String xmlVersion = propertiesElement.getAttribute("version"); - if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) - throw new InvalidPropertiesFormatException( - "Exported Properties file format version " + xmlVersion + - " is not supported. This java installation can read" + - " versions " + EXTERNAL_XML_VERSION + " or older. You" + - " may need to install a newer version of JDK."); - importProperties(props, propertiesElement); - } - - static Document getLoadingDoc(InputStream in) - throws SAXException, IOException - { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setIgnoringElementContentWhitespace(true); - dbf.setValidating(true); - dbf.setCoalescing(true); - dbf.setIgnoringComments(true); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - db.setEntityResolver(new Resolver()); - db.setErrorHandler(new EH()); - InputSource is = new InputSource(in); - return db.parse(is); - } catch (ParserConfigurationException x) { - throw new Error(x); - } - } - - static void importProperties(Properties props, Element propertiesElement) { - NodeList entries = propertiesElement.getChildNodes(); - int numEntries = entries.getLength(); - int start = numEntries > 0 && - entries.item(0).getNodeName().equals("comment") ? 1 : 0; - for (int i=start; i" + + "" + + ""+ + "" + + "" + + "" + + ""; + + /** + * Version number for the format of exported properties files. + */ + private static final String EXTERNAL_XML_VERSION = "1.0"; + + public static void load(Properties props, InputStream in) + throws IOException, InvalidPropertiesFormatException + { + Document doc = null; + try { + doc = getLoadingDoc(in); + } catch (SAXException saxe) { + throw new InvalidPropertiesFormatException(saxe); + } + Element propertiesElement = (Element)doc.getChildNodes().item(1); + String xmlVersion = propertiesElement.getAttribute("version"); + if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) + throw new InvalidPropertiesFormatException( + "Exported Properties file format version " + xmlVersion + + " is not supported. This java installation can read" + + " versions " + EXTERNAL_XML_VERSION + " or older. You" + + " may need to install a newer version of JDK."); + importProperties(props, propertiesElement); + } + + static Document getLoadingDoc(InputStream in) + throws SAXException, IOException + { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setIgnoringElementContentWhitespace(true); + dbf.setValidating(true); + dbf.setCoalescing(true); + dbf.setIgnoringComments(true); + try { + DocumentBuilder db = dbf.newDocumentBuilder(); + db.setEntityResolver(new Resolver()); + db.setErrorHandler(new EH()); + InputSource is = new InputSource(in); + return db.parse(is); + } catch (ParserConfigurationException x) { + throw new Error(x); + } + } + + static void importProperties(Properties props, Element propertiesElement) { + NodeList entries = propertiesElement.getChildNodes(); + int numEntries = entries.getLength(); + int start = numEntries > 0 && + entries.item(0).getNodeName().equals("comment") ? 1 : 0; + for (int i=start; i