Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
66a22022
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66a22022
编写于
10月 22, 2010
作者:
N
naoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6993339: Bug4168625Test.java fails
Reviewed-by: peytoia
上级
7c2fd26b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
82 deletion
+4
-82
test/java/util/ResourceBundle/Bug4168625Test.java
test/java/util/ResourceBundle/Bug4168625Test.java
+4
-82
未找到文件。
test/java/util/ResourceBundle/Bug4168625Test.java
浏览文件 @
66a22022
...
...
@@ -25,7 +25,7 @@
@summary test Resource Bundle for bug 4168625
@build Bug4168625Class Bug4168625Getter Bug4168625Resource Bug4168625Resource3 Bug4168625Resource3_en Bug4168625Resource3_en_CA Bug4168625Resource3_en_IE Bug4168625Resource3_en_US Bug4168625Resource2_en_US Bug4168625Resource2
@run main/timeout=600 Bug4168625Test
@bug 4168625
@bug 4168625
6993339
*/
/*
*
...
...
@@ -50,9 +50,8 @@ import java.util.*;
import
java.io.*
;
/**
* This test tries to correct three efficiency problems with the caching
* mechanism of ResourceBundle. All tests assume that none of the bundles
* have been previously loaded and cached. It also allows concurrent loads
* This test tries to correct two efficiency problems with the caching
* mechanism of ResourceBundle. It also allows concurrent loads
* of resource bundles to be performed if the bundles are unrelated (ex. a
* load of a local system resource by one thread while another thread is
* doing a slow load over a network).
...
...
@@ -230,83 +229,6 @@ public class Bug4168625Test extends RBTestFmwk {
}
}
/**
* Previous versions of ResourceBundle exhibited the following caching behavior.
* Assume the class Bug4168625Resource_en exists. Bug4168625Resource_en_US does
* not. Two threads, ThreadA and ThreadB both try to get the same bundle.
* <P>
* <pre>
* ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
* A-->try to load Bug4168625Resource_en_US
* ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
* B-->try to load Bug4168625Resource_en_US
* B-->load Bug4168625Resource_en (#1)
* A-->load Bug4168625Resource_en (#2)
* A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en
* A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en_US
* A-->return Bug4168625Resource_en (#2)
* B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en
* B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en_US
* B-->return Bug4168625Resource_en (#1)
* </pre>
* <P>
* Both threads try and fail to load Bug4168625Resource_en_US. Both
* threads load Bug4168625Resource_en. Both threads get their own copy
* of the Bug4168625Resource_en resource.
*
* The desired behavior is as follows:
* <P>
* <pre>
* ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
* A-->try to load Bug4168625Resource_en_US
* ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
* B-->try to load Bug4168625Resource_en_US
* B-->load Bug4168625Resource_en
* A-->load Bug4168625Resource_en (block in ResourceBundle.getBundle)
* B-->cache Bug4168625Resource_en as Bug4168625Resource_en
* B-->cache Bug4168625Resource_en as Bug4168625Resource_en_US
* A-->return Bug4168625Resource_en
* B-->return Bug4168625Resource_en
* </pre>
* <P>
* Note that both threads return the same bundle object.
*/
public
void
testConcurrentLoading1
()
throws
Exception
{
final
Loader
loader
=
new
Loader
(
new
String
[]
{
"Bug4168625Class"
},
new
String
[]
{
"Bug4168625Resource3_en_US"
,
"Bug4168625Resource3_en_CA"
});
final
Class
c
=
loader
.
loadClass
(
"Bug4168625Class"
);
final
Bug4168625Getter
test
=
(
Bug4168625Getter
)
c
.
newInstance
();
//both threads want the same resource
ConcurrentLoadingThread
thread1
=
new
ConcurrentLoadingThread
(
loader
,
test
,
new
Locale
(
"en"
,
"US"
));
ConcurrentLoadingThread
thread2
=
new
ConcurrentLoadingThread
(
loader
,
test
,
new
Locale
(
"en"
,
"US"
));
thread1
.
start
();
//start thread 1
loader
.
waitForNotify
(
1
);
//wait for thread1 to do getBundle & block in loader
thread2
.
start
();
//start second thread
loader
.
waitForNotify
(
2
,
1000
);
//wait until thread2 blocks somewhere in getBundle
thread1
.
ping
();
//continue both threads
thread2
.
ping
();
thread1
.
join
();
//wait unitl both threads complete
thread2
.
join
();
//Now, examine the class loads that were done.
loader
.
logClasses
(
"Classes loaded after completion of both threads:"
);
boolean
dups
=
false
;
for
(
int
i
=
loader
.
loadedClasses
.
size
()
-
1
;
i
>=
0
;
i
--)
{
final
Object
item
=
loader
.
loadedClasses
.
elementAt
(
i
);
loader
.
loadedClasses
.
removeElementAt
(
i
);
if
(
loader
.
loadedClasses
.
contains
(
item
))
{
logln
(
"Resource loaded more than once: "
+
item
);
dups
=
true
;
}
}
if
(
dups
)
{
errln
(
"ResourceBundle loaded some classes multiple times"
);
}
}
private
class
ConcurrentLoadingThread
extends
Thread
{
private
Loader
loader
;
public
Object
bundle
;
...
...
@@ -355,7 +277,7 @@ public class Bug4168625Test extends RBTestFmwk {
* This test ensures that multiple resources can be loading at the same
* time as long as they don't depend on each other in some way.
*/
public
void
testConcurrentLoading
2
()
throws
Exception
{
public
void
testConcurrentLoading
()
throws
Exception
{
final
Loader
loader
=
new
Loader
(
new
String
[]
{
"Bug4168625Class"
},
new
String
[]
{
"Bug4168625Resource3_en_US"
,
"Bug4168625Resource3_en_CA"
});
final
Class
c
=
loader
.
loadClass
(
"Bug4168625Class"
);
final
Bug4168625Getter
test
=
(
Bug4168625Getter
)
c
.
newInstance
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录