< prev index next >

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

Print this page
rev 16280 : [mq]: 8171189

*** 58,68 **** 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; --- 58,67 ----
*** 230,241 **** * 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> * --- 229,238 ----
*** 262,282 **** * 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 --- 259,268 ----
*** 467,491 **** /** * 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() { --- 453,462 ----
*** 946,956 **** @CallerSensitive public static final ResourceBundle getBundle(String baseName) { Class<?> caller = Reflection.getCallerClass(); return getBundleImpl(baseName, Locale.getDefault(), ! caller, getDefaultControl(caller, baseName)); } /** * Returns a resource bundle using the specified base name, the * default locale and the specified control. Calling this method --- 917,927 ---- @CallerSensitive public static final ResourceBundle getBundle(String baseName) { Class<?> caller = Reflection.getCallerClass(); return getBundleImpl(baseName, Locale.getDefault(), ! caller, Control.INSTANCE); } /** * Returns a resource bundle using the specified base name, the * default locale and the specified control. Calling this method
*** 1020,1030 **** public static final ResourceBundle getBundle(String baseName, Locale locale) { Class<?> caller = Reflection.getCallerClass(); return getBundleImpl(baseName, locale, ! caller, getDefaultControl(caller, baseName)); } /** * 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 --- 991,1001 ---- public static final ResourceBundle getBundle(String baseName, Locale locale) { Class<?> caller = Reflection.getCallerClass(); return getBundleImpl(baseName, locale, ! 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,1174 **** * 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>. * * <p><a name="default_behavior">The following describes the default * behavior</a>. * * <p> --- 1132,1142 ---- * 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}. * * <p><a name="default_behavior">The following describes the default * behavior</a>. * * <p>
*** 1362,1372 **** { if (loader == null) { throw new NullPointerException(); } Class<?> caller = Reflection.getCallerClass(); ! return getBundleImpl(baseName, locale, caller, loader, getDefaultControl(caller, baseName)); } /** * Returns a resource bundle using the specified base name, target * locale, class loader and control. Unlike the {@linkplain --- 1330,1340 ---- { if (loader == null) { throw new NullPointerException(); } Class<?> caller = Reflection.getCallerClass(); ! 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,1608 **** 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"); } --- 1555,1564 ----
*** 2571,2582 **** * </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. * * @since 1.6 * @see java.util.spi.ResourceBundleProvider */ public static class Control { --- 2527,2537 ---- * </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}. * * @since 1.6 * @see java.util.spi.ResourceBundleProvider */ public static class Control {
< prev index next >