# HG changeset patch # User naoto # Date 1482170171 28800 # Node ID c6ee006baceb290296c530cb33f74d454331854f # Parent b3cc743446a26c933a457c0f60ee16d88b7516f9 8171189: Deprecate ResourceBundleControlProvider for removal Reviewed-by: mchung diff -r b3cc743446a2 -r c6ee006baceb jdk/src/java.base/share/classes/java/util/ResourceBundle.java --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Mon Dec 19 12:39:21 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Mon Dec 19 09:56:11 2016 -0800 @@ -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 @@ *
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. - * *
getBundle
factory
@@ -469,21 +455,6 @@
*/
private volatile SetThis 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 -r b3cc743446a2 -r c6ee006baceb jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java --- a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java Mon Dec 19 12:39:21 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java Mon Dec 19 09:56:11 2016 -0800 @@ -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 -r b3cc743446a2 -r c6ee006baceb jdk/test/ProblemList.txt
--- a/jdk/test/ProblemList.txt Mon Dec 19 12:39:21 2016 -0500
+++ b/jdk/test/ProblemList.txt Mon Dec 19 09:56:11 2016 -0800
@@ -292,8 +292,6 @@
# jdk_util
-java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java 8062512 generic-all
-
java/util/BitSet/BitSetStreamTest.java 8079538 generic-all
diff -r b3cc743446a2 -r c6ee006baceb jdk/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java Mon Dec 19 12:39:21 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r b3cc743446a2 -r c6ee006baceb jdk/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.sh
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.sh Mon Dec 19 12:39:21 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r b3cc743446a2 -r c6ee006baceb jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/Makefile
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/Makefile Mon Dec 19 12:39:21 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r b3cc743446a2 -r c6ee006baceb jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserControlProvider.java
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserControlProvider.java Mon Dec 19 12:39:21 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r b3cc743446a2 -r c6ee006baceb jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserXMLControl.java
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/providersrc/UserXMLControl.java Mon Dec 19 12:39:21 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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