提交 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -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 final RBClassLoader INSTANCE = AccessController.doPrivileged(
......@@ -494,7 +494,16 @@ public abstract class ResourceBundle {
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() {
}
......
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -262,11 +262,17 @@ public class Level implements java.io.Serializable {
}
private String computeLocalizedLevelName(Locale newLocale) {
ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale);
final String localizedName = rb.getString(name);
// If this is a custom Level, load resource bundles on the
// classpath and return.
if (!defaultBundle.equals(resourceBundleName)) {
return ResourceBundle.getBundle(resourceBundleName, newLocale,
ClassLoader.getSystemClassLoader()).getString(name);
}
final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName);
if (!isDefaultBundle) return localizedName;
// The default bundle "sun.util.logging.resources.logging" should only
// 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
// 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1817,8 +1817,7 @@ public class Logger {
public ResourceBundle run() {
try {
return ResourceBundle.getBundle(SYSTEM_LOGGER_RB_NAME,
locale,
ClassLoader.getSystemClassLoader());
locale);
} catch (MissingResourceException e) {
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -305,7 +305,8 @@ public class UIDefaults extends Hashtable<Object,Object>
if (c != null) {
b = ResourceBundle.getBundle(bundleName, l, c);
} else {
b = ResourceBundle.getBundle(bundleName, l);
b = ResourceBundle.getBundle(bundleName, l,
ClassLoader.getSystemClassLoader());
}
Enumeration keys = b.getKeys();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册