Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e87b4d05
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看板
提交
e87b4d05
编写于
4月 21, 2014
作者:
N
naoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8036936: Use local locales
Summary: Made sure cache key is cleared on GC invocation Reviewed-by: okutsu
上级
9d4d4689
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
40 deletion
+52
-40
src/share/classes/sun/util/locale/BaseLocale.java
src/share/classes/sun/util/locale/BaseLocale.java
+49
-39
src/share/classes/sun/util/locale/LocaleObjectCache.java
src/share/classes/sun/util/locale/LocaleObjectCache.java
+3
-1
未找到文件。
src/share/classes/sun/util/locale/BaseLocale.java
浏览文件 @
e87b4d05
...
...
@@ -31,6 +31,7 @@
*/
package
sun.util.locale
;
import
java.lang.ref.SoftReference
;
public
final
class
BaseLocale
{
...
...
@@ -163,11 +164,11 @@ public final class BaseLocale {
return
h
;
}
private
static
final
class
Key
implements
Comparable
<
Key
>
{
private
final
S
tring
lang
;
private
final
S
tring
scrt
;
private
final
S
tring
regn
;
private
final
S
tring
vart
;
private
static
final
class
Key
{
private
final
S
oftReference
<
String
>
lang
;
private
final
S
oftReference
<
String
>
scrt
;
private
final
S
oftReference
<
String
>
regn
;
private
final
S
oftReference
<
String
>
vart
;
private
final
boolean
normalized
;
private
final
int
hash
;
...
...
@@ -179,10 +180,10 @@ public final class BaseLocale {
assert
language
.
intern
()
==
language
&&
region
.
intern
()
==
region
;
lang
=
language
;
scrt
=
""
;
regn
=
region
;
vart
=
""
;
lang
=
new
SoftReference
(
language
)
;
scrt
=
new
SoftReference
(
""
)
;
regn
=
new
SoftReference
(
region
)
;
vart
=
new
SoftReference
(
""
)
;
this
.
normalized
=
true
;
int
h
=
language
.
hashCode
();
...
...
@@ -203,40 +204,40 @@ public final class BaseLocale {
String
variant
,
boolean
normalized
)
{
int
h
=
0
;
if
(
language
!=
null
)
{
lang
=
language
;
lang
=
new
SoftReference
(
language
)
;
int
len
=
language
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
language
.
charAt
(
i
));
}
}
else
{
lang
=
""
;
lang
=
new
SoftReference
(
""
)
;
}
if
(
script
!=
null
)
{
scrt
=
script
;
scrt
=
new
SoftReference
(
script
)
;
int
len
=
script
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
script
.
charAt
(
i
));
}
}
else
{
scrt
=
""
;
scrt
=
new
SoftReference
(
""
)
;
}
if
(
region
!=
null
)
{
regn
=
region
;
regn
=
new
SoftReference
(
region
)
;
int
len
=
region
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
region
.
charAt
(
i
));
}
}
else
{
regn
=
""
;
regn
=
new
SoftReference
(
""
)
;
}
if
(
variant
!=
null
)
{
vart
=
variant
;
vart
=
new
SoftReference
(
variant
)
;
int
len
=
variant
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
variant
.
charAt
(
i
);
}
}
else
{
vart
=
""
;
vart
=
new
SoftReference
(
""
)
;
}
hash
=
h
;
this
.
normalized
=
normalized
;
...
...
@@ -244,28 +245,31 @@ public final class BaseLocale {
@Override
public
boolean
equals
(
Object
obj
)
{
return
(
this
==
obj
)
||
(
obj
instanceof
Key
)
&&
this
.
hash
==
((
Key
)
obj
).
hash
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
lang
,
this
.
lang
)
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
scrt
,
this
.
scrt
)
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
regn
,
this
.
regn
)
&&
((
Key
)
obj
).
vart
.
equals
(
vart
);
// variant is case sensitive in JDK!
if
(
this
==
obj
)
{
return
true
;
}
@Override
public
int
compareTo
(
Key
other
)
{
int
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
lang
,
other
.
lang
);
if
(
res
==
0
)
{
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
scrt
,
other
.
scrt
);
if
(
res
==
0
)
{
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
regn
,
other
.
regn
);
if
(
res
==
0
)
{
res
=
this
.
vart
.
compareTo
(
other
.
vart
);
if
(
obj
instanceof
Key
&&
this
.
hash
==
((
Key
)
obj
).
hash
)
{
String
tl
=
this
.
lang
.
get
();
String
ol
=
((
Key
)
obj
).
lang
.
get
();
if
(
tl
!=
null
&&
ol
!=
null
&&
LocaleUtils
.
caseIgnoreMatch
(
ol
,
tl
))
{
String
ts
=
this
.
scrt
.
get
();
String
os
=
((
Key
)
obj
).
scrt
.
get
();
if
(
ts
!=
null
&&
os
!=
null
&&
LocaleUtils
.
caseIgnoreMatch
(
os
,
ts
))
{
String
tr
=
this
.
regn
.
get
();
String
or
=
((
Key
)
obj
).
regn
.
get
();
if
(
tr
!=
null
&&
or
!=
null
&&
LocaleUtils
.
caseIgnoreMatch
(
or
,
tr
))
{
String
tv
=
this
.
vart
.
get
();
String
ov
=
((
Key
)
obj
).
vart
.
get
();
return
(
ov
!=
null
&&
ov
.
equals
(
tv
));
}
}
}
return
res
;
}
return
false
;
}
@Override
...
...
@@ -278,10 +282,10 @@ public final class BaseLocale {
return
key
;
}
String
lang
=
LocaleUtils
.
toLowerString
(
key
.
lang
).
intern
();
String
scrt
=
LocaleUtils
.
toTitleString
(
key
.
scrt
).
intern
();
String
regn
=
LocaleUtils
.
toUpperString
(
key
.
regn
).
intern
();
String
vart
=
key
.
vart
.
intern
();
// preserve upper/lower cases
String
lang
=
LocaleUtils
.
toLowerString
(
key
.
lang
.
get
()
).
intern
();
String
scrt
=
LocaleUtils
.
toTitleString
(
key
.
scrt
.
get
()
).
intern
();
String
regn
=
LocaleUtils
.
toUpperString
(
key
.
regn
.
get
()
).
intern
();
String
vart
=
key
.
vart
.
get
().
intern
();
// preserve upper/lower cases
return
new
Key
(
lang
,
scrt
,
regn
,
vart
,
true
);
}
...
...
@@ -294,12 +298,18 @@ public final class BaseLocale {
@Override
protected
Key
normalizeKey
(
Key
key
)
{
assert
key
.
lang
.
get
()
!=
null
&&
key
.
scrt
.
get
()
!=
null
&&
key
.
regn
.
get
()
!=
null
&&
key
.
vart
.
get
()
!=
null
;
return
Key
.
normalize
(
key
);
}
@Override
protected
BaseLocale
createObject
(
Key
key
)
{
return
new
BaseLocale
(
key
.
lang
,
key
.
scrt
,
key
.
regn
,
key
.
vart
);
return
new
BaseLocale
(
key
.
lang
.
get
(),
key
.
scrt
.
get
(),
key
.
regn
.
get
(),
key
.
vart
.
get
());
}
}
}
src/share/classes/sun/util/locale/LocaleObjectCache.java
浏览文件 @
e87b4d05
...
...
@@ -57,8 +57,10 @@ public abstract class LocaleObjectCache<K, V> {
value
=
entry
.
get
();
}
if
(
value
==
null
)
{
key
=
normalizeKey
(
key
);
V
newVal
=
createObject
(
key
);
// make sure key is normalized *after* the object creation
// so that newVal is assured to be created from a valid key.
key
=
normalizeKey
(
key
);
if
(
key
==
null
||
newVal
==
null
)
{
// subclass must return non-null key/value object
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录