# HG changeset patch # User naoto # Date 1482165412 28800 # Mon Dec 19 08:36:52 2016 -0800 # Node ID 03a4425b611c2cf094535f6c80d36e1d4bc7c38f # Parent 2a07637c565e2200e101ea92e79fbac3c83daca3 [mq]: 8171189 diff --git a/src/java.base/share/classes/java/util/ResourceBundle.java b/src/java.base/share/classes/java/util/ResourceBundle.java --- a/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/src/java.base/share/classes/java/util/ResourceBundle.java @@ -60,7 +60,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.jar.JarEntry; -import java.util.spi.ResourceBundleControlProvider; import java.util.spi.ResourceBundleProvider; import jdk.internal.loader.BootLoader; @@ -232,8 +231,6 @@ *
  • {@code ResourceBundle.Control} is not supported in named modules. * If the {@code getBundle} method with a {@code ResourceBundle.Control} is called * in a named module, the method will throw an {@code UnsupportedOperationException}. - * Any service providers of {@link ResourceBundleControlProvider} are ignored in - * named modules. *
  • * * @@ -264,17 +261,6 @@ * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle} * factory method for details. * - *

    For the {@code getBundle} factory - * methods that take no {@link Control} instance, their default behavior of resource bundle loading - * can be modified with installed {@link - * ResourceBundleControlProvider} implementations. Any installed providers are - * detected at the {@code ResourceBundle} class loading time. If any of the - * providers provides a {@link Control} for the given base name, that {@link - * Control} will be used instead of the default {@link Control}. If there is - * more than one service provider installed for supporting the same base name, - * the first one returned from {@link ServiceLoader} will be used. - * *

    Cache Management

    * * Resource bundle instances created by the getBundle factory @@ -469,21 +455,6 @@ */ private volatile Set keySet; - private static final List providers; - - static { - List list = null; - ServiceLoader serviceLoaders - = ServiceLoader.loadInstalled(ResourceBundleControlProvider.class); - for (ResourceBundleControlProvider provider : serviceLoaders) { - if (list == null) { - list = new ArrayList<>(); - } - list.add(provider); - } - providers = list; - } - /** * Sole constructor. (For invocation by subclass constructors, typically * implicit.) @@ -948,7 +919,7 @@ { Class caller = Reflection.getCallerClass(); return getBundleImpl(baseName, Locale.getDefault(), - caller, getDefaultControl(caller, baseName)); + caller, Control.INSTANCE); } /** @@ -1022,7 +993,7 @@ { Class caller = Reflection.getCallerClass(); return getBundleImpl(baseName, locale, - caller, getDefaultControl(caller, baseName)); + caller, Control.INSTANCE); } /** @@ -1163,10 +1134,7 @@ * *

    This method behaves the same as calling * {@link #getBundle(String, Locale, ClassLoader, Control)} passing a - * default instance of {@link Control} unless another {@link Control} is - * provided with the {@link ResourceBundleControlProvider} SPI. Refer to the - * description of modifying the default - * behavior. + * default instance of {@link Control}. * *

    The following describes the default * behavior. @@ -1364,7 +1332,7 @@ throw new NullPointerException(); } Class caller = Reflection.getCallerClass(); - return getBundleImpl(baseName, locale, caller, loader, getDefaultControl(caller, baseName)); + return getBundleImpl(baseName, locale, caller, loader, Control.INSTANCE); } /** @@ -1589,18 +1557,6 @@ return getBundleImpl(baseName, targetLocale, caller, loader, control); } - private static Control getDefaultControl(Class caller, String baseName) { - if (providers != null && !caller.getModule().isNamed()) { - for (ResourceBundleControlProvider provider : providers) { - Control control = provider.getControl(baseName); - if (control != null) { - return control; - } - } - } - return Control.INSTANCE; - } - private static void checkNamedModule(Class caller) { if (caller.getModule().isNamed()) { throw new UnsupportedOperationException( @@ -2573,8 +2529,7 @@ * @apiNote {@code ResourceBundle.Control} is not supported * in named modules. If the {@code ResourceBundle.getBundle} method with * a {@code ResourceBundle.Control} is called in a named module, the method - * will throw an {@link UnsupportedOperationException}. Any service providers - * of {@link ResourceBundleControlProvider} are ignored in named modules. + * will throw an {@link UnsupportedOperationException}. * * @since 1.6 * @see java.util.spi.ResourceBundleProvider diff --git a/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java b/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java --- a/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java +++ b/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java @@ -35,21 +35,19 @@ * no {@link java.util.ResourceBundle.Control} instance can be modified with {@code * ResourceBundleControlProvider} implementations. * - *

    Provider implementations must be packaged using the Java Extension - * Mechanism as installed extensions. Refer to {@link java.util.ServiceLoader} - * for the extension packaging. Any installed {@code - * ResourceBundleControlProvider} implementations are loaded using {@link - * java.util.ServiceLoader} at the {@code ResourceBundle} class loading time. - * - *

    All {@code ResourceBundleControlProvider}s are ignored in named modules. - * * @author Masayoshi Okutsu * @since 1.8 * @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control) * ResourceBundle.getBundle * @see java.util.ServiceLoader#loadInstalled(Class) + * @deprecated There is no longer any mechanism to install a custom + * {@code ResourceBundleControlProvider} implementation defined + * by the platform class loader or its ancestor. The recommended + * way to use a custom {@code Control} implementation to load resource bundle + * is to use {@link java.util.ResourceBundle#getBundle(String, Control)} + * or other factory methods that take custom {@link java.util.ResourceBundle.Control}. */ +@Deprecated(since="9", forRemoval=true) public interface ResourceBundleControlProvider { /** * Returns a {@code ResourceBundle.Control} instance that is used diff --git a/test/ProblemList.txt b/test/ProblemList.txt --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -288,8 +288,6 @@ # jdk_util -java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java 8062512 generic-all - java/util/BitSet/BitSetStreamTest.java 8079538 generic-all diff --git a/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java b/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java +++ /dev/null @@ -1,59 +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 6959653 - * @summary Test ResourceBundle.Control provided using SPI. - * @build UserDefaultControlTest - * @run shell UserDefaultControlTest.sh - */ - -import java.io.*; -import java.net.*; -import java.util.*; - -public class UserDefaultControlTest { - public static void main(String[] args) { - ResourceBundle rb = ResourceBundle.getBundle("com.foo.XmlRB", Locale.ROOT); - String type = rb.getString("type"); - if (!type.equals("XML")) { - throw new RuntimeException("Root Locale: type: got " + type - + ", expected XML (ASCII)"); - } - - rb = ResourceBundle.getBundle("com.foo.XmlRB", Locale.JAPAN); - type = rb.getString("type"); - // Expect fullwidth "XML" - if (!type.equals("\uff38\uff2d\uff2c")) { - throw new RuntimeException("Locale.JAPAN: type: got " + type - + ", expected \uff38\uff2d\uff2c (fullwidth XML)"); - } - - try { - rb = ResourceBundle.getBundle("com.bar.XmlRB", Locale.JAPAN); - throw new RuntimeException("com.bar.XmlRB test failed."); - } catch (MissingResourceException e) { - // OK - } - } -} diff --git a/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.sh b/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.sh deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.sh +++ /dev/null @@ -1,25 +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. -# - -${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.ext.dirs=${TESTSRC} -cp ${TESTCLASSES} UserDefaultControlTest - diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/Makefile b/test/java/util/spi/ResourceBundleControlProvider/providersrc/Makefile deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/Makefile +++ /dev/null @@ -1,63 +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. 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. -# - -# -# Makefile for building a ResourceBundleControlProvider jar file for testing. -# -# Usage: make JDK_HOME=... all install -# - -DESTDIR = .. -TMPDIR = tmp -SERVICESDIR = $(TMPDIR)/META-INF/services -TARGETJAR = rbcontrolprovider.jar -BINDIR = $(JDK_HOME)/bin - - -all: $(TARGETJAR) - -install: all - cp $(TARGETJAR) $(DESTDIR) - -SERVICES = java.util.spi.ResourceBundleControlProvider - -FILES_JAVA = UserControlProvider.java \ - UserXMLControl.java - -RESOURCE_FILES = XmlRB.xml \ - XmlRB_ja.xml - -$(TARGETJAR): $(SERVICES) $(FILES_JAVA) $(RESOURCE_FILES) - rm -rf $(TMPDIR) $@ - mkdir -p $(SERVICESDIR) - $(BINDIR)/javac -d $(TMPDIR) $(FILES_JAVA) - cp $(SERVICES) $(SERVICESDIR) - cp $(RESOURCE_FILES) $(TMPDIR)/com/foo - $(BINDIR)/jar cvf $@ -C $(TMPDIR) . - -clean: - rm -rf $(TMPDIR) $(TARGETJAR) - -.PHONY: all install clean diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserControlProvider.java b/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserControlProvider.java deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserControlProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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. - */ - -package com.foo; - -import java.util.ResourceBundle; -import java.util.spi.ResourceBundleControlProvider; - -public class UserControlProvider implements ResourceBundleControlProvider { - static final ResourceBundle.Control XMLCONTROL = new UserXMLControl(); - - public ResourceBundle.Control getControl(String baseName) { - System.out.println(getClass().getName()+".getControl called for " + baseName); - - // Throws a NPE if baseName is null. - if (baseName.startsWith("com.foo.Xml")) { - System.out.println("\treturns " + XMLCONTROL); - return XMLCONTROL; - } - System.out.println("\treturns null"); - return null; - } -} diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserXMLControl.java b/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserXMLControl.java deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserXMLControl.java +++ /dev/null @@ -1,95 +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. - */ - -package com.foo; - -import java.io.*; -import java.net.*; -import java.util.*; -import static java.util.ResourceBundle.Control.*; - -public class UserXMLControl extends ResourceBundle.Control { - @Override - public List getFormats(String baseName) { - if (baseName == null) { - throw new NullPointerException(); - } - return Arrays.asList("xml"); - } - - @Override - public ResourceBundle newBundle(String baseName, Locale locale, - String format, - ClassLoader loader, - boolean reload) - throws IllegalAccessException, - InstantiationException, IOException { - if (baseName == null || locale == null - || format == null || loader == null) { - throw new NullPointerException(); - } - ResourceBundle bundle = null; - if (format.equals("xml")) { - String bundleName = toBundleName(baseName, locale); - String resourceName = toResourceName(bundleName, format); - URL url = loader.getResource(resourceName); - if (url != null) { - URLConnection connection = url.openConnection(); - if (connection != null) { - if (reload) { - // disable caches if reloading - connection.setUseCaches(false); - } - try (InputStream stream = connection.getInputStream()) { - if (stream != null) { - BufferedInputStream bis = new BufferedInputStream(stream); - bundle = new XMLResourceBundle(bis); - } - } - } - } - } - return bundle; - } - - private static class XMLResourceBundle extends ResourceBundle { - private Properties props; - - XMLResourceBundle(InputStream stream) throws IOException { - props = new Properties(); - props.loadFromXML(stream); - } - - protected Object handleGetObject(String key) { - if (key == null) { - throw new NullPointerException(); - } - return props.get(key); - } - - public Enumeration getKeys() { - // Not implemented - return null; - } - } -} diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml b/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - -]> - - - 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 deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/XmlRB_ja.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - -]> - - - Test data for UserDefaultControlTest.java - XML - diff --git a/test/java/util/spi/ResourceBundleControlProvider/providersrc/java.util.spi.ResourceBundleControlProvider b/test/java/util/spi/ResourceBundleControlProvider/providersrc/java.util.spi.ResourceBundleControlProvider deleted file mode 100644 --- a/test/java/util/spi/ResourceBundleControlProvider/providersrc/java.util.spi.ResourceBundleControlProvider +++ /dev/null @@ -1,1 +0,0 @@ -com.foo.UserControlProvider diff --git a/test/java/util/spi/ResourceBundleControlProvider/rbcontrolprovider.jar b/test/java/util/spi/ResourceBundleControlProvider/rbcontrolprovider.jar deleted file mode 100644 index b7e6a491d7910a79c5f14b8cba79029b252e64f3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch literal 0 Hc$@