提交 ed10c2fb 编写于 作者: N naoto

7079486: Locale.getDisplayScript() (no args) does not honor default DISPLAY locale

Reviewed-by: okutsu
上级 7f080213
...@@ -1589,7 +1589,7 @@ public final class Locale implements Cloneable, Serializable { ...@@ -1589,7 +1589,7 @@ public final class Locale implements Cloneable, Serializable {
* @since 1.7 * @since 1.7
*/ */
public String getDisplayScript() { public String getDisplayScript() {
return getDisplayScript(getDefault()); return getDisplayScript(getDefault(Category.DISPLAY));
} }
/** /**
......
...@@ -56,6 +56,7 @@ public class LocaleCategory { ...@@ -56,6 +56,7 @@ public class LocaleCategory {
Locale.getDefault().getVariant())).build(); Locale.getDefault().getVariant())).build();
checkDefault(); checkDefault();
testGetSetDefault(); testGetSetDefault();
testBug7079486();
} finally { } finally {
// restore the reserved locale // restore the reserved locale
Locale.setDefault(reservedLocale); Locale.setDefault(reservedLocale);
...@@ -82,5 +83,24 @@ public class LocaleCategory { ...@@ -82,5 +83,24 @@ public class LocaleCategory {
throw new RuntimeException("setDefault() should set all default locales for all categories"); throw new RuntimeException("setDefault() should set all default locales for all categories");
} }
} }
static void testBug7079486() {
Locale zh_Hans_CN = Locale.forLanguageTag("zh-Hans-CN");
// make sure JRE has zh_Hans_CN localized string
if (zh_Hans_CN.getDisplayScript(Locale.US).equals(zh_Hans_CN.getDisplayScript(zh_Hans_CN))) {
return;
}
Locale.setDefault(Locale.US);
String en_script = zh_Hans_CN.getDisplayScript();
Locale.setDefault(Locale.Category.DISPLAY, zh_Hans_CN);
String zh_script = zh_Hans_CN.getDisplayScript();
if (en_script.equals(zh_script)) {
throw new RuntimeException("Locale.getDisplayScript() (no args) does not honor default DISPLAY locale");
}
}
} }
#!/bin/sh #!/bin/sh
# #
# @test # @test
# @bug 4700857 6997928 # @bug 4700857 6997928 7079486
# @summary tests for Locale.getDefault(Locale.Category) and # @summary tests for Locale.getDefault(Locale.Category) and
# Locale.setDefault(Locale.Category, Locale) # Locale.setDefault(Locale.Category, Locale)
# @build LocaleCategory # @build LocaleCategory
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册