Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ff61ddf5
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ff61ddf5
编写于
12月 21, 2010
作者:
N
naoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4940539: Constructor of java.util.Locale should handle ISO 639-2 Language Codes
Reviewed-by: okutsu
上级
ba3e05b6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
9 deletion
+26
-9
src/share/classes/java/util/Locale.java
src/share/classes/java/util/Locale.java
+7
-2
test/java/util/Locale/LocaleTest.java
test/java/util/Locale/LocaleTest.java
+19
-7
未找到文件。
src/share/classes/java/util/Locale.java
浏览文件 @
ff61ddf5
...
...
@@ -1449,10 +1449,15 @@ public final class Locale implements Cloneable, Serializable {
* three-letter language abbreviation is not available for this locale.
*/
public
String
getISO3Language
()
throws
MissingResourceException
{
String
language3
=
getISO3Code
(
_baseLocale
.
getLanguage
(),
LocaleISOData
.
isoLanguageTable
);
String
lang
=
_baseLocale
.
getLanguage
();
if
(
lang
.
length
()
==
3
)
{
return
lang
;
}
String
language3
=
getISO3Code
(
lang
,
LocaleISOData
.
isoLanguageTable
);
if
(
language3
==
null
)
{
throw
new
MissingResourceException
(
"Couldn't find 3-letter language code for "
+
_baseLocale
.
getLanguage
()
,
"FormatData_"
+
toString
(),
"ShortLanguage"
);
+
lang
,
"FormatData_"
+
toString
(),
"ShortLanguage"
);
}
return
language3
;
}
...
...
test/java/util/Locale/LocaleTest.java
浏览文件 @
ff61ddf5
...
...
@@ -24,7 +24,8 @@
* @test
* @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613
* 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951
* 4147315 4147317 4147552 4335196 4778440 5010672 6475525 6544471 6627549 6786276
* 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549
* 6786276
* @summary test Locales
*/
/*
...
...
@@ -895,17 +896,28 @@ test commented out pending API-change approval
}
/**
* @bug 4147317
* java.util.Locale.getISO3Language() works wrong for non ISO-3166 codes.
* Should throw an exception for unknown locales
* @bug 4147317 4940539
* java.util.Locale.getISO3Language() works wrong for non ISO-639 codes.
* Should throw an exception for unknown locales, except they have three
* letter language codes.
*/
public
void
Test4147317
()
{
// Try
with codes that are the wrong length but happen to match text
//
at a valid offset in the mapping table
// Try
a three letter language code, and check whether it is
//
returned as is.
Locale
locale
=
new
Locale
(
"aaa"
,
"CCC"
);
try
{
String
result
=
locale
.
getISO3Language
();
if
(!
result
.
equals
(
"aaa"
))
{
errln
(
"ERROR: getISO3Language() returns: "
+
result
+
" for locale '"
+
locale
+
"' rather than returning it as is"
);
}
// Try an invalid two letter language code, and check whether it
// throws a MissingResourceException.
locale
=
new
Locale
(
"zz"
,
"CCC"
);
try
{
result
=
locale
.
getISO3Language
();
errln
(
"ERROR: getISO3Language() returns: "
+
result
+
" for locale '"
+
locale
+
"' rather than exception"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录