Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
45f8d98b
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看板
提交
45f8d98b
编写于
4月 21, 2010
作者:
P
peytoia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6943963: NumericShaper with ARABIC doesn't shape digits correctly after calling another instance
Reviewed-by: okutsu
上级
d1a5532a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
67 deletion
+101
-67
src/share/classes/java/awt/font/NumericShaper.java
src/share/classes/java/awt/font/NumericShaper.java
+7
-1
test/java/awt/font/NumericShaper/MTTest.java
test/java/awt/font/NumericShaper/MTTest.java
+26
-25
test/java/awt/font/NumericShaper/ShapingTest.java
test/java/awt/font/NumericShaper/ShapingTest.java
+68
-41
未找到文件。
src/share/classes/java/awt/font/NumericShaper.java
浏览文件 @
45f8d98b
...
@@ -1163,8 +1163,14 @@ public final class NumericShaper implements java.io.Serializable {
...
@@ -1163,8 +1163,14 @@ public final class NumericShaper implements java.io.Serializable {
lastkey
=
newkey
;
lastkey
=
newkey
;
ctxKey
=
newkey
;
ctxKey
=
newkey
;
if
(((
mask
&
EASTERN_ARABIC
)
!=
0
)
&&
(
ctxKey
==
ARABIC_KEY
||
ctxKey
==
EASTERN_ARABIC_KEY
))
{
if
(((
mask
&
EASTERN_ARABIC
)
!=
0
)
&&
(
ctxKey
==
ARABIC_KEY
||
ctxKey
==
EASTERN_ARABIC_KEY
))
{
ctxKey
=
EASTERN_ARABIC_KEY
;
ctxKey
=
EASTERN_ARABIC_KEY
;
}
else
if
(((
mask
&
ARABIC
)
!=
0
)
&&
(
ctxKey
==
ARABIC_KEY
||
ctxKey
==
EASTERN_ARABIC_KEY
))
{
ctxKey
=
ARABIC_KEY
;
}
else
if
((
mask
&
(
1
<<
ctxKey
))
==
0
)
{
}
else
if
((
mask
&
(
1
<<
ctxKey
))
==
0
)
{
ctxKey
=
EUROPEAN_KEY
;
ctxKey
=
EUROPEAN_KEY
;
}
}
...
...
test/java/awt/font/NumericShaper/MTTest.java
浏览文件 @
45f8d98b
/*
/*
* Copyright (c) 20
09
Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 20
10
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* @test
* @test
* @bug 6843181
* @bug 6843181
6943963
* @summary Confirm that NumericShaper is thread-safe.
* @summary Confirm that NumericShaper is thread-safe.
* @run main/timeout=300/othervm MTTest
* @run main/timeout=300/othervm MTTest
*/
*/
...
@@ -37,33 +37,34 @@ public class MTTest {
...
@@ -37,33 +37,34 @@ public class MTTest {
static
volatile
boolean
runrun
=
true
;
static
volatile
boolean
runrun
=
true
;
static
volatile
boolean
err
=
false
;
static
volatile
boolean
err
=
false
;
final
static
String
text
=
"-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -789 (Thai) \u0e01\u0e33 01.23"
;
final
static
String
text
=
"-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -456 (Thai) \u0e01\u0e33 01.23"
;
static
char
[]
t1
,
t2
;
final
static
char
[]
expected1
=
"-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -\u06f4\u06f5\u06f6 (Thai) \u0e01\u0e33 \u0e50\u0e51.\u0e52\u0e53"
.
toCharArray
();
// for EASTERN_ARABIC
final
static
char
[]
expected2
=
"-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -\u0664\u0665\u0666 (Thai) \u0e01\u0e33 \u0e50\u0e51.\u0e52\u0e53"
.
toCharArray
();
// for ARABIC
static
NumericShaper
ns1
,
ns2
,
ns3
,
ns4
;
static
NumericShaper
ns1
,
ns2
,
ns3
,
ns4
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
" original: "
+
text
);
System
.
out
.
println
(
"original: "
+
text
);
ns1
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
ARABIC
),
Range
.
ARABIC
);
ns1
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
EASTERN_ARABIC
,
Range
.
THAI
),
t1
=
text
.
toCharArray
();
Range
.
EUROPEAN
);
ns1
.
shape
(
t1
,
0
,
t1
.
length
);
ns2
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
ARABIC
,
Range
.
THAI
),
System
.
out
.
println
(
"expected t1: "
+
String
.
valueOf
(
t1
));
Range
.
EUROPEAN
);
System
.
out
.
println
(
"expected for Eastern-Arabic & Thai: "
+
ns2
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
THAI
),
Range
.
THAI
);
String
.
valueOf
(
expected1
));
t2
=
text
.
toCharArray
();
System
.
out
.
println
(
"expected for Arabic & Thai: "
+
ns2
.
shape
(
t2
,
0
,
t2
.
length
);
String
.
valueOf
(
expected2
));
System
.
out
.
println
(
"expected t2: "
+
String
.
valueOf
(
t2
));
ns3
=
getContextualShaper
(
ARABIC
,
ARABIC
);
ns3
=
getContextualShaper
(
EASTERN_ARABIC
|
THAI
,
EUROPEAN
);
ns4
=
getContextualShaper
(
THAI
,
THAI
);
ns4
=
getContextualShaper
(
ARABIC
|
THAI
,
EUROPEAN
);
Thread
th1
=
new
Thread
(
new
Work
(
ns1
,
t
1
));
Thread
th1
=
new
Thread
(
new
Work
(
ns1
,
expected
1
));
Thread
th2
=
new
Thread
(
new
Work
(
ns2
,
t
2
));
Thread
th2
=
new
Thread
(
new
Work
(
ns2
,
expected
2
));
Thread
th3
=
new
Thread
(
new
Work
(
ns1
,
t
1
));
Thread
th3
=
new
Thread
(
new
Work
(
ns1
,
expected
1
));
Thread
th4
=
new
Thread
(
new
Work
(
ns2
,
t
2
));
Thread
th4
=
new
Thread
(
new
Work
(
ns2
,
expected
2
));
Thread
th5
=
new
Thread
(
new
Work
(
ns3
,
t
1
));
Thread
th5
=
new
Thread
(
new
Work
(
ns3
,
expected
1
));
Thread
th6
=
new
Thread
(
new
Work
(
ns4
,
t
2
));
Thread
th6
=
new
Thread
(
new
Work
(
ns4
,
expected
2
));
Thread
th7
=
new
Thread
(
new
Work
(
ns3
,
t
1
));
Thread
th7
=
new
Thread
(
new
Work
(
ns3
,
expected
1
));
Thread
th8
=
new
Thread
(
new
Work
(
ns4
,
t
2
));
Thread
th8
=
new
Thread
(
new
Work
(
ns4
,
expected
2
));
th1
.
start
();
th1
.
start
();
th2
.
start
();
th2
.
start
();
...
@@ -110,8 +111,8 @@ public class MTTest {
...
@@ -110,8 +111,8 @@ public class MTTest {
int
count
=
0
;
int
count
=
0
;
while
(
runrun
)
{
while
(
runrun
)
{
char
[]
t
=
text
.
toCharArray
();
char
[]
t
=
text
.
toCharArray
();
count
++;
try
{
try
{
count
++;
ns
.
shape
(
t
,
0
,
t
.
length
);
ns
.
shape
(
t
,
0
,
t
.
length
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Error: Unexpected exception: "
+
e
);
System
.
err
.
println
(
"Error: Unexpected exception: "
+
e
);
...
...
test/java/awt/font/NumericShaper/ShapingTest.java
浏览文件 @
45f8d98b
/*
/*
* Copyright (c) 20
09
Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 20
10
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* @test
* @test
* @bug 6842557
* @bug 6842557
6943963
* @summary confirm that shaping works as expected. (Mainly for new characters which were added in Unicode 5)
* @summary confirm that shaping works as expected. (Mainly for new characters which were added in Unicode 5)
* used where appropriate.
* used where appropriate.
*/
*/
...
@@ -33,15 +33,25 @@ import java.util.EnumSet;
...
@@ -33,15 +33,25 @@ import java.util.EnumSet;
import
static
java
.
awt
.
font
.
NumericShaper
.*;
import
static
java
.
awt
.
font
.
NumericShaper
.*;
public
class
ShapingTest
{
public
class
ShapingTest
{
private
static
boolean
err
=
false
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
test6842557
();
test6943963
();
if
(
err
)
{
throw
new
RuntimeException
(
"shape() returned unexpected value."
);
}
}
private
static
void
test6842557
()
{
NumericShaper
ns_old
=
getContextualShaper
(
ARABIC
|
TAMIL
|
ETHIOPIC
,
NumericShaper
ns_old
=
getContextualShaper
(
ARABIC
|
TAMIL
|
ETHIOPIC
,
EUROPEAN
);
EUROPEAN
);
NumericShaper
ns_new
=
getContextualShaper
(
EnumSet
.
of
(
NumericShaper
ns_new
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
ARABIC
,
Range
.
TAMIL
,
Range
.
ETHIOPIC
),
Range
.
ARABIC
,
Range
.
TAMIL
,
Range
.
ETHIOPIC
),
Range
.
EUROPEAN
);
Range
.
EUROPEAN
);
boolean
err
=
false
;
String
[][]
data
=
{
String
[][]
data
=
{
// Arabic "October 10"
// Arabic "October 10"
{
"\u0623\u0643\u062a\u0648\u0628\u0631 10"
,
{
"\u0623\u0643\u062a\u0648\u0628\u0631 10"
,
...
@@ -60,45 +70,62 @@ public class ShapingTest {
...
@@ -60,45 +70,62 @@ public class ShapingTest {
};
};
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
String
expected
=
data
[
i
][
1
];
checkResult
(
"ARABIC | TAMIL | ETHIOPIC"
,
ns_old
,
data
[
i
][
0
],
data
[
i
][
1
]);
char
[]
text
=
data
[
i
][
0
].
toCharArray
();
ns_old
.
shape
(
text
,
0
,
text
.
length
);
checkResult
(
"Range.ARABIC, Range.TAMIL, Range.ETHIOPIC"
,
String
got
=
new
String
(
text
);
ns_new
,
data
[
i
][
0
],
data
[
i
][
1
]);
if
(!
expected
.
equals
(
got
))
{
err
=
true
;
System
.
err
.
println
(
"Error with traditional range."
);
System
.
err
.
println
(
" text = "
+
data
[
i
][
0
]);
System
.
err
.
println
(
" got = "
+
got
);
System
.
err
.
println
(
" expected = "
+
expected
);
}
else
{
System
.
err
.
println
(
"OK with traditional range."
);
System
.
err
.
println
(
" text = "
+
data
[
i
][
0
]);
System
.
err
.
println
(
" got = "
+
got
);
System
.
err
.
println
(
" expected = "
+
expected
);
}
text
=
data
[
i
][
0
].
toCharArray
();
ns_new
.
shape
(
text
,
0
,
text
.
length
);
got
=
new
String
(
text
);
if
(!
expected
.
equals
(
got
))
{
err
=
true
;
System
.
err
.
println
(
"Error with new Enum range."
);
System
.
err
.
println
(
" text = "
+
data
[
i
][
0
]);
System
.
err
.
println
(
" got = "
+
got
);
System
.
err
.
println
(
" expected = "
+
expected
);
}
else
{
System
.
err
.
println
(
"OK with new Enum range."
);
System
.
err
.
println
(
" text = "
+
data
[
i
][
0
]);
System
.
err
.
println
(
" got = "
+
got
);
System
.
err
.
println
(
" expected = "
+
expected
);
}
}
}
}
if
(
err
)
{
private
static
void
test6943963
()
{
throw
new
RuntimeException
(
"shape() returned unexpected value."
);
// Needed to reproduce this bug.
NumericShaper
ns_dummy
=
getContextualShaper
(
ARABIC
|
TAMIL
|
ETHIOPIC
,
EUROPEAN
);
char
[]
c
=
"\u1200 1"
.
toCharArray
();
ns_dummy
.
shape
(
c
,
0
,
c
.
length
);
String
given
=
"\u0627\u0628 456"
;
String
expected_ARABIC
=
"\u0627\u0628 \u0664\u0665\u0666"
;
String
expected_EASTERN_ARABIC
=
"\u0627\u0628 \u06f4\u06f5\u06f6"
;
NumericShaper
ns
=
getContextualShaper
(
ARABIC
);
checkResult
(
"ARABIC"
,
ns
,
given
,
expected_ARABIC
);
ns
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
ARABIC
));
checkResult
(
"Range.ARABIC"
,
ns
,
given
,
expected_ARABIC
);
ns
=
getContextualShaper
(
EASTERN_ARABIC
);
checkResult
(
"EASTERN_ARABIC"
,
ns
,
given
,
expected_EASTERN_ARABIC
);
ns
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
EASTERN_ARABIC
));
checkResult
(
"Range.EASTERN_ARABIC"
,
ns
,
given
,
expected_EASTERN_ARABIC
);
ns
=
getContextualShaper
(
ARABIC
|
EASTERN_ARABIC
);
checkResult
(
"ARABIC | EASTERN_ARABIC"
,
ns
,
given
,
expected_EASTERN_ARABIC
);
ns
=
getContextualShaper
(
EnumSet
.
of
(
Range
.
ARABIC
,
Range
.
EASTERN_ARABIC
));
checkResult
(
"Range.ARABIC, Range.EASTERN_ARABIC"
,
ns
,
given
,
expected_EASTERN_ARABIC
);
}
private
static
void
checkResult
(
String
ranges
,
NumericShaper
ns
,
String
given
,
String
expected
)
{
char
[]
text
=
given
.
toCharArray
();
ns
.
shape
(
text
,
0
,
text
.
length
);
String
got
=
new
String
(
text
);
if
(!
expected
.
equals
(
got
))
{
err
=
true
;
System
.
err
.
println
(
"Error with range(s) <"
+
ranges
+
">."
);
System
.
err
.
println
(
" text = "
+
given
);
System
.
err
.
println
(
" got = "
+
got
);
System
.
err
.
println
(
" expected = "
+
expected
);
}
else
{
System
.
out
.
println
(
"OK with range(s) <"
+
ranges
+
">."
);
System
.
out
.
println
(
" text = "
+
given
);
System
.
out
.
println
(
" got = "
+
got
);
System
.
out
.
println
(
" expected = "
+
expected
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录