# HG changeset patch # User rkennke # Date 1565971241 -7200 # Fri Aug 16 18:00:41 2019 +0200 # Node ID 203301052e82e349a0f70d1c56d5051a5e01acd0 # Parent 3ef3348195ffeb3c268af4a43928f2f09c5fa83a 8213325: (props) Properties.loadFromXML does not fully comply with the spec Reviewed-by: alanb, rriggs, dfuchs, naoto diff --git a/src/share/classes/jdk/internal/org/xml/sax/DTDHandler.java b/src/share/classes/jdk/internal/org/xml/sax/DTDHandler.java --- a/src/share/classes/jdk/internal/org/xml/sax/DTDHandler.java +++ b/src/share/classes/jdk/internal/org/xml/sax/DTDHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, 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 @@ -73,7 +73,6 @@ */ public interface DTDHandler { - /** * Receive notification of a notation declaration event. * @@ -136,6 +135,39 @@ String notationName) throws SAXException; + // from SAX2 extension DeclHandler + /** + * Receive notification of the start of DTD declarations. + * + * The start/endDTD events appear within the start/endDocument events + * from ContentHandler. + * + * @param name The document type name. + * @param publicId The declared public identifier for the + * external DTD subset, or null if none was declared. + * @param systemId The declared system identifier for the + * external DTD subset, or null if none was declared. + * (Note that this is not resolved against the document + * base URI.) + * @throws SAXException the event receiver may throw an exception during processing + */ + default public void startDTD (String name, String publicId, String systemId) + throws SAXException + { + // no op + } + + // Custom API for the Properties + + /** + * Receive notification of the start of DTD internal subset. + * + * @throws SAXException the event receiver may throw an exception during processing + */ + default public void startInternalSub () throws SAXException + { + // no op + } } // end of DTDHandler.java diff --git a/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java b/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java --- a/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java +++ b/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -53,11 +53,11 @@ private static final String ATTR_KEY = "key"; // The required DTD URI for exported properties private static final String PROPS_DTD_DECL = - ""; + ""; private static final String PROPS_DTD_URI = - "http://java.sun.com/dtd/properties.dtd"; + "http://java.sun.com/dtd/properties.dtd"; private static final String PROPS_DTD = - "" + "" + "" + "" + "= 0;) { ch = getch(); @@ -2229,6 +2231,13 @@ throws SAXException; /** + * Reports the start of DTD internal subset. + * + * @throws SAXException if the receiver throws SAXException + */ + public abstract void startInternalSub () throws SAXException; + + /** * Reports a comment. * * @param text The comment text starting from first charcater. diff --git a/src/share/classes/jdk/internal/util/xml/impl/ParserSAX.java b/src/share/classes/jdk/internal/util/xml/impl/ParserSAX.java --- a/src/share/classes/jdk/internal/util/xml/impl/ParserSAX.java +++ b/src/share/classes/jdk/internal/util/xml/impl/ParserSAX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -551,7 +551,16 @@ * @param sysid The system identifier of the entity or null. */ protected void docType(String name, String pubid, String sysid) throws SAXException { - mHandDtd.notationDecl(name, pubid, sysid); + mHandDtd.startDTD(name, pubid, sysid); + } + + /** + * Reports the start of DTD internal subset. + * + * @throws SAXException if the receiver throws SAXException + */ + public void startInternalSub () throws SAXException { + mHandDtd.startInternalSub(); } /** diff --git a/src/share/classes/sun/util/xml/META-INF/services/sun.util.spi.XmlPropertiesProvider b/src/share/classes/sun/util/xml/META-INF/services/sun.util.spi.XmlPropertiesProvider --- a/src/share/classes/sun/util/xml/META-INF/services/sun.util.spi.XmlPropertiesProvider +++ b/src/share/classes/sun/util/xml/META-INF/services/sun.util.spi.XmlPropertiesProvider @@ -1,1 +1,1 @@ -sun.util.xml.PlatformXmlPropertiesProvider +jdk.internal.util.xml.BasicXmlPropertiesProvider diff --git a/test/java/util/Properties/Compatibility.xml b/test/java/util/Properties/Compatibility.xml deleted file mode 100644 --- a/test/java/util/Properties/Compatibility.xml +++ /dev/null @@ -1,10 +0,0 @@ - - ]> - - -Property With Other Encoding -value1 -]]> -&intEnt; - diff --git a/test/java/util/Properties/CompatibilityTest.java b/test/java/util/Properties/CompatibilityTest.java deleted file mode 100644 --- a/test/java/util/Properties/CompatibilityTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2012, 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. - * - * 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. - */ - -/* - * @test - * @bug 8005280 8004371 - * @summary Compatibility test - * @run main CompatibilityTest - * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider CompatibilityTest - */ - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * This is a behavior compatibility test. - * Although not defined by the properties.dtd, the constructs - * in Compatibility.xml are supported by the regular JDK XML - * Provider. - * - * @author: Joe Wang - */ -public class CompatibilityTest { - - public static void main(String[] args) { - testInternalDTD(); - } - - /* - * Not in the spec, but the constructs work with the current JDK - */ - static void testInternalDTD() { - String src = System.getProperty("test.src"); - if (src == null) { - src = "."; - } - loadPropertyFile(src + "/Compatibility.xml"); - } - - /* - * 'Store' the populated 'Property' with the specified 'Encoding Type' as an - * XML file. Retrieve the same XML file and 'load' onto a new 'Property' object. - */ - static void loadPropertyFile(String filename) { - try (InputStream in = new FileInputStream(filename)) { - Properties prop = new Properties(); - prop.loadFromXML(in); - verifyProperites(prop); - } catch (IOException ex) { - fail(ex.getMessage()); - } - } - - /* - * This method verifies the first key-value with the original string. - */ - static void verifyProperites(Properties prop) { - try { - for (String key : prop.stringPropertyNames()) { - String val = prop.getProperty(key); - if (key.equals("Key1")) { - if (!val.equals("value1")) { - fail("Key:" + key + "'s value: \nExpected: value1\nFound: " + val); - } - } else if (key.equals("Key2")) { - if (!val.equals("")) { - fail("Key:" + key + "'s value: \nExpected: \nFound: " + val); - } - } else if (key.equals("Key3")) { - if (!val.equals("value3")) { - fail("Key:" + key + "'s value: \nExpected: value3\nFound: " + val); - } - } - } - } catch (Exception e) { - fail(e.getMessage()); - } - - } - - static void fail(String err) { - throw new RuntimeException(err); - } - -} diff --git a/test/java/util/Properties/invalidxml/IllegalElement.xml b/test/java/util/Properties/invalidxml/IllegalElement.xml new file mode 100644 --- /dev/null +++ b/test/java/util/Properties/invalidxml/IllegalElement.xml @@ -0,0 +1,11 @@ + + + + + + +comment + + value of the first key + + diff --git a/test/java/util/Properties/invalidxml/invalidDTD.xml b/test/java/util/Properties/invalidxml/invalidDTD.xml new file mode 100644 --- /dev/null +++ b/test/java/util/Properties/invalidxml/invalidDTD.xml @@ -0,0 +1,10 @@ + + ]> + + +Property With Other Encoding +value1 +]]> +&intEnt; + diff --git a/test/java/util/ResourceBundle/Control/XmlRB.xml b/test/java/util/ResourceBundle/Control/XmlRB.xml --- a/test/java/util/ResourceBundle/Control/XmlRB.xml +++ b/test/java/util/ResourceBundle/Control/XmlRB.xml @@ -2,15 +2,7 @@ - - - - - - -]> - + Test data for XMLResourceBundleTest.java XML diff --git a/test/java/util/ResourceBundle/Control/XmlRB_ja.xml b/test/java/util/ResourceBundle/Control/XmlRB_ja.xml --- a/test/java/util/ResourceBundle/Control/XmlRB_ja.xml +++ b/test/java/util/ResourceBundle/Control/XmlRB_ja.xml @@ -2,15 +2,7 @@ - - - - - - -]> - + Test data for XMLResourceBundleTest.java XML diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml b/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml +++ b/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml @@ -25,15 +25,7 @@ --> - - - - - - -]> - + Test data for UserDefaultControlTest.java XML diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB_ja.xml b/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB_ja.xml --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB_ja.xml +++ b/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB_ja.xml @@ -25,15 +25,7 @@ --> - - - - - - -]> - + Test data for UserDefaultControlTest.java XML diff --git a/test/java/util/spi/ResourceBundleControlProvider/rbcontrolprovider.jar b/test/java/util/spi/ResourceBundleControlProvider/rbcontrolprovider.jar index b7e6a491d7910a79c5f14b8cba79029b252e64f3..f01d60c11b103039ef13d1f582942114ab50ecb1 GIT binary patch literal 5693 zc$}432UJsOw++2ZkxoRK^b!aiqL4rcB{XSLq=w!@5e4ZWAVI41E>(~sMPQKLr3-=} z0wPTjL8QZvGtPV9n(@8=%ereND`%g3zID(3&c0hy6$h6ZKuAakIF6#w0GwMy09*i4 zQAb`tSsgBP(gy(G05nwz2!H&A{WC=KU%}L8*Z+W#^6JWP#hW^UNcc8#pkGZ@KyZXi z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