提交 c842d279 编写于 作者: N naoto

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

Reviewed-by: okutsu
上级 c026ea0b
......@@ -1589,7 +1589,7 @@ public final class Locale implements Cloneable, Serializable {
* @since 1.7
*/
public String getDisplayScript() {
return getDisplayScript(getDefault());
return getDisplayScript(getDefault(Category.DISPLAY));
}
/**
......
......@@ -56,6 +56,7 @@ public class LocaleCategory {
Locale.getDefault().getVariant())).build();
checkDefault();
testGetSetDefault();
testBug7079486();
} finally {
// restore the reserved locale
Locale.setDefault(reservedLocale);
......@@ -82,5 +83,24 @@ public class LocaleCategory {
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
#
# @test
# @bug 4700857 6997928
# @bug 4700857 6997928 7079486
# @summary tests for Locale.getDefault(Locale.Category) and
# Locale.setDefault(Locale.Category, Locale)
# @build LocaleCategory
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部