--- old/src/share/classes/java/util/Properties.java 2014-05-12 12:22:18.956650601 +0100
+++ new/src/share/classes/java/util/Properties.java 2014-05-12 12:22:18.816650601 +0100
@@ -37,7 +37,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.util.spi.XmlPropertiesProvider;
+import jdk.internal.util.xml.PropertiesDefaultHandler;
/**
* The {@code Properties} class represents a persistent set of
@@ -877,7 +877,9 @@
public synchronized void loadFromXML(InputStream in)
throws IOException, InvalidPropertiesFormatException
{
- XmlSupport.load(this, Objects.requireNonNull(in));
+ Objects.requireNonNull(in);
+ PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
+ handler.load(this, in);
in.close();
}
@@ -949,8 +951,10 @@
public void storeToXML(OutputStream os, String comment, String encoding)
throws IOException
{
- XmlSupport.save(this, Objects.requireNonNull(os), comment,
- Objects.requireNonNull(encoding));
+ Objects.requireNonNull(os);
+ Objects.requireNonNull(encoding);
+ PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
+ handler.store(this, os, comment, encoding);
}
/**
@@ -1128,83 +1132,4 @@
private static final char[] hexDigit = {
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
};
-
- /**
- * Supporting class for loading/storing properties in XML format.
- *
- *
The {@code load} and {@code store} methods defined here delegate to a
- * system-wide {@code XmlPropertiesProvider}. On first invocation of either
- * method then the system-wide provider is located as follows:
- *
- *
- * - If the system property {@code sun.util.spi.XmlPropertiesProvider}
- * is defined then it is taken to be the full-qualified name of a concrete
- * provider class. The class is loaded with the system class loader as the
- * initiating loader. If it cannot be loaded or instantiated using a zero
- * argument constructor then an unspecified error is thrown.
- *
- * - If the system property is not defined then the service-provider
- * loading facility defined by the {@link ServiceLoader} class is used to
- * locate a provider with the system class loader as the initiating
- * loader and {@code sun.util.spi.XmlPropertiesProvider} as the service
- * type. If this process fails then an unspecified error is thrown. If
- * there is more than one service provider installed then it is
- * not specified as to which provider will be used.
- *
- * - If the provider is not found by the above means then a system
- * default provider will be instantiated and used.
- *
- */
- private static class XmlSupport {
-
- private static XmlPropertiesProvider loadProviderFromProperty(ClassLoader cl) {
- String cn = System.getProperty("sun.util.spi.XmlPropertiesProvider");
- if (cn == null)
- return null;
- try {
- Class> c = Class.forName(cn, true, cl);
- return (XmlPropertiesProvider)c.newInstance();
- } catch (ClassNotFoundException |
- IllegalAccessException |
- InstantiationException x) {
- throw new ServiceConfigurationError(null, x);
- }
- }
-
- private static XmlPropertiesProvider loadProviderAsService(ClassLoader cl) {
- Iterator iterator =
- ServiceLoader.load(XmlPropertiesProvider.class, cl).iterator();
- return iterator.hasNext() ? iterator.next() : null;
- }
-
- private static XmlPropertiesProvider loadProvider() {
- return AccessController.doPrivileged(
- new PrivilegedAction() {
- public XmlPropertiesProvider run() {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- XmlPropertiesProvider provider = loadProviderFromProperty(cl);
- if (provider != null)
- return provider;
- provider = loadProviderAsService(cl);
- if (provider != null)
- return provider;
- return new jdk.internal.util.xml.BasicXmlPropertiesProvider();
- }});
- }
-
- private static final XmlPropertiesProvider PROVIDER = loadProvider();
-
- static void load(Properties props, InputStream in)
- throws IOException, InvalidPropertiesFormatException
- {
- PROVIDER.load(props, in);
- }
-
- static void save(Properties props, OutputStream os, String comment,
- String encoding)
- throws IOException
- {
- PROVIDER.store(props, os, comment, encoding);
- }
- }
}