mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-03 04:30:06 +00:00
8170984: java.util.logging might force the initialization of ResourceBundle class too early
Reviewed-by: alanb
This commit is contained in:
parent
0807977548
commit
ee6b8571eb
@ -79,8 +79,13 @@ public class Level implements java.io.Serializable {
|
||||
private static final String defaultBundle =
|
||||
"sun.util.logging.resources.logging";
|
||||
|
||||
private static final JavaUtilResourceBundleAccess RB_ACCESS =
|
||||
SharedSecrets.getJavaUtilResourceBundleAccess();
|
||||
// Calling SharedSecrets.getJavaUtilResourceBundleAccess()
|
||||
// forces the initialization of ResourceBundle.class, which
|
||||
// can be too early if the VM has not finished booting yet.
|
||||
private static final class RbAccess {
|
||||
static final JavaUtilResourceBundleAccess RB_ACCESS =
|
||||
SharedSecrets.getJavaUtilResourceBundleAccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial The non-localized name of the level.
|
||||
@ -286,7 +291,7 @@ public class Level implements java.io.Serializable {
|
||||
// or its defining class loader, if it's unnamed module,
|
||||
// of this Level instance that can be a custom Level subclass;
|
||||
Module module = this.getClass().getModule();
|
||||
ResourceBundle rb = RB_ACCESS.getBundle(resourceBundleName,
|
||||
ResourceBundle rb = RbAccess.RB_ACCESS.getBundle(resourceBundleName,
|
||||
newLocale, module);
|
||||
|
||||
final String localizedName = rb.getString(name);
|
||||
|
||||
@ -259,8 +259,13 @@ public class Logger {
|
||||
private static final LoggerBundle NO_RESOURCE_BUNDLE =
|
||||
new LoggerBundle(null, null);
|
||||
|
||||
private static final JavaUtilResourceBundleAccess RB_ACCESS =
|
||||
// Calling SharedSecrets.getJavaUtilResourceBundleAccess()
|
||||
// forces the initialization of ResourceBundle.class, which
|
||||
// can be too early if the VM has not finished booting yet.
|
||||
private static final class RbAccess {
|
||||
static final JavaUtilResourceBundleAccess RB_ACCESS =
|
||||
SharedSecrets.getJavaUtilResourceBundleAccess();
|
||||
}
|
||||
|
||||
// A value class that holds the logger configuration data.
|
||||
// This configuration can be shared between an application logger
|
||||
@ -2183,7 +2188,7 @@ public class Logger {
|
||||
if (!useCallersModule || callerModule == null || !callerModule.isNamed()) {
|
||||
try {
|
||||
Module mod = cl.getUnnamedModule();
|
||||
catalog = RB_ACCESS.getBundle(name, currentLocale, mod);
|
||||
catalog = RbAccess.RB_ACCESS.getBundle(name, currentLocale, mod);
|
||||
catalogName = name;
|
||||
catalogLocale = currentLocale;
|
||||
return catalog;
|
||||
@ -2227,7 +2232,7 @@ public class Logger {
|
||||
// Try with the caller's module
|
||||
try {
|
||||
// Use the caller's module
|
||||
catalog = RB_ACCESS.getBundle(name, currentLocale, callerModule);
|
||||
catalog = RbAccess.RB_ACCESS.getBundle(name, currentLocale, callerModule);
|
||||
catalogName = name;
|
||||
catalogLocale = currentLocale;
|
||||
return catalog;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user