< prev index next >

src/java.base/share/classes/java/util/ResourceBundle.java

Print this page
rev 16336 : [mq]: 8171189

@@ -58,11 +58,10 @@
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 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;
 import jdk.internal.misc.JavaUtilResourceBundleAccess;
 import jdk.internal.misc.SharedSecrets;

@@ -230,12 +229,10 @@
  * find resource bundles using the given {@code ClassLoader} in named modules.
  * The {@code getBundle} method with a {@code Module} can be used, instead.</li>
  * <li>{@code ResourceBundle.Control} is <em>not</em> 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.
  * </li>
  * </ul>
  *
  * <h3><a name="RBP_support">ResourceBundleProvider Service Providers</a></h3>
  *

@@ -262,21 +259,10 @@
  * non-standard resource bundle formats, change the search strategy, or
  * define caching parameters. Refer to the descriptions of the class and the
  * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
  * factory method for details.
  *
- * <p><a name="modify_default_behavior">For the {@code getBundle} factory</a>
- * methods that take no {@link Control} instance, their <a
- * href="#default_behavior"> default behavior</a> of resource bundle loading
- * can be modified with <em>installed</em> {@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.
- *
  * <h3>Cache Management</h3>
  *
  * Resource bundle instances created by the <code>getBundle</code> factory
  * methods are cached by default, and the factory methods return the same
  * resource bundle instance multiple times if it has been

@@ -467,25 +453,10 @@
     /**
      * A Set of the keys contained only in this ResourceBundle.
      */
     private volatile Set<String> keySet;
 
-    private static final List<ResourceBundleControlProvider> providers;
-
-    static {
-        List<ResourceBundleControlProvider> list = null;
-        ServiceLoader<ResourceBundleControlProvider> 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.)
      */
     public ResourceBundle() {

@@ -946,11 +917,11 @@
     @CallerSensitive
     public static final ResourceBundle getBundle(String baseName)
     {
         Class<?> caller = Reflection.getCallerClass();
         return getBundleImpl(baseName, Locale.getDefault(),
-                             caller, getDefaultControl(caller, baseName));
+                             caller, Control.INSTANCE);
     }
 
     /**
      * Returns a resource bundle using the specified base name, the
      * default locale and the specified control. Calling this method

@@ -1020,11 +991,11 @@
     public static final ResourceBundle getBundle(String baseName,
                                                  Locale locale)
     {
         Class<?> caller = Reflection.getCallerClass();
         return getBundleImpl(baseName, locale,
-                             caller, getDefaultControl(caller, baseName));
+                             caller, Control.INSTANCE);
     }
 
     /**
      * Gets a resource bundle using the specified base name and the default locale
      * on behalf of the specified module. This method is equivalent to calling

@@ -1161,14 +1132,11 @@
      * Gets a resource bundle using the specified base name, locale, and class
      * loader.
      *
      * <p>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 <a href="#modify_default_behavior">modifying the default
-     * behavior</a>.
+     * default instance of {@link Control}.
      *
      * <p><a name="default_behavior">The following describes the default
      * behavior</a>.
      *
      * <p>

@@ -1362,11 +1330,11 @@
     {
         if (loader == null) {
             throw new NullPointerException();
         }
         Class<?> caller = Reflection.getCallerClass();
-        return getBundleImpl(baseName, locale, caller, loader, getDefaultControl(caller, baseName));
+        return getBundleImpl(baseName, locale, caller, loader, Control.INSTANCE);
     }
 
     /**
      * Returns a resource bundle using the specified base name, target
      * locale, class loader and control. Unlike the {@linkplain

@@ -1587,22 +1555,10 @@
         Class<?> caller = Reflection.getCallerClass();
         checkNamedModule(caller);
         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(
                     "ResourceBundle.Control not supported in named modules");
         }

@@ -2571,12 +2527,11 @@
      * </pre>
      *
      * @apiNote <a name="note">{@code ResourceBundle.Control} is not supported
      * in named modules.</a> 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
      */
     public static class Control {
< prev index next >