提交 351dc065 编写于 作者: N naoto

8182601: Improve usage messages

Reviewed-by: alanb, ahgross, ksrini, mchung, dfuchs
上级 7cb56d9b
/* /*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -485,7 +485,7 @@ public abstract class ResourceBundle { ...@@ -485,7 +485,7 @@ public abstract class ResourceBundle {
} }
/** /**
* A wrapper of ClassLoader.getSystemClassLoader(). * A wrapper of Extension Class Loader
*/ */
private static class RBClassLoader extends ClassLoader { private static class RBClassLoader extends ClassLoader {
private static final RBClassLoader INSTANCE = AccessController.doPrivileged( private static final RBClassLoader INSTANCE = AccessController.doPrivileged(
...@@ -494,7 +494,16 @@ public abstract class ResourceBundle { ...@@ -494,7 +494,16 @@ public abstract class ResourceBundle {
return new RBClassLoader(); return new RBClassLoader();
} }
}); });
private static final ClassLoader loader = ClassLoader.getSystemClassLoader(); private static final ClassLoader loader;
static {
// Find the extension class loader.
ClassLoader ld = ClassLoader.getSystemClassLoader();
ClassLoader parent;
while ((parent = ld.getParent()) != null) {
ld = parent;
}
loader = ld;
}
private RBClassLoader() { private RBClassLoader() {
} }
......
/* /*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -262,11 +262,17 @@ public class Level implements java.io.Serializable { ...@@ -262,11 +262,17 @@ public class Level implements java.io.Serializable {
} }
private String computeLocalizedLevelName(Locale newLocale) { private String computeLocalizedLevelName(Locale newLocale) {
ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale); // If this is a custom Level, load resource bundles on the
final String localizedName = rb.getString(name); // classpath and return.
if (!defaultBundle.equals(resourceBundleName)) {
return ResourceBundle.getBundle(resourceBundleName, newLocale,
ClassLoader.getSystemClassLoader()).getString(name);
}
final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName); // The default bundle "sun.util.logging.resources.logging" should only
if (!isDefaultBundle) return localizedName; // be loaded from the runtime; so use the extension class loader;
final ResourceBundle rb = ResourceBundle.getBundle(defaultBundle, newLocale);
final String localizedName = rb.getString(name);
// This is a trick to determine whether the name has been translated // This is a trick to determine whether the name has been translated
// or not. If it has not been translated, we need to use Locale.ROOT // or not. If it has not been translated, we need to use Locale.ROOT
......
/* /*
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1817,8 +1817,7 @@ public class Logger { ...@@ -1817,8 +1817,7 @@ public class Logger {
public ResourceBundle run() { public ResourceBundle run() {
try { try {
return ResourceBundle.getBundle(SYSTEM_LOGGER_RB_NAME, return ResourceBundle.getBundle(SYSTEM_LOGGER_RB_NAME,
locale, locale);
ClassLoader.getSystemClassLoader());
} catch (MissingResourceException e) { } catch (MissingResourceException e) {
throw new InternalError(e.toString()); throw new InternalError(e.toString());
} }
......
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -305,7 +305,8 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -305,7 +305,8 @@ public class UIDefaults extends Hashtable<Object,Object>
if (c != null) { if (c != null) {
b = ResourceBundle.getBundle(bundleName, l, c); b = ResourceBundle.getBundle(bundleName, l, c);
} else { } else {
b = ResourceBundle.getBundle(bundleName, l); b = ResourceBundle.getBundle(bundleName, l,
ClassLoader.getSystemClassLoader());
} }
Enumeration keys = b.getKeys(); Enumeration keys = b.getKeys();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册