Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c871fee9
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看板
提交
c871fee9
编写于
6月 11, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8016311: Update j.u.c. tests to avoid using Thread.stop(Throwable)
Reviewed-by: alanb Contributed-by: martinrb@google.com
上级
661b8ba3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
9 deletion
+27
-9
test/java/util/concurrent/Executors/PrivilegedCallables.java
test/java/util/concurrent/Executors/PrivilegedCallables.java
+8
-3
test/java/util/concurrent/FutureTask/Throw.java
test/java/util/concurrent/FutureTask/Throw.java
+5
-2
test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
...ava/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
+8
-2
test/java/util/concurrent/locks/Lock/FlakyMutex.java
test/java/util/concurrent/locks/Lock/FlakyMutex.java
+6
-2
未找到文件。
test/java/util/concurrent/Executors/PrivilegedCallables.java
浏览文件 @
c871fee9
...
...
@@ -43,7 +43,8 @@ public class PrivilegedCallables {
final
Random
rnd
=
new
Random
();
@SuppressWarnings
(
"serial"
)
Throwable
[]
throwables
=
{
@SuppressWarnings
(
"serial"
)
Throwable
[]
throwables
=
{
new
Exception
()
{},
new
RuntimeException
()
{},
new
Error
()
{}
...
...
@@ -51,6 +52,11 @@ public class PrivilegedCallables {
Throwable
randomThrowable
()
{
return
throwables
[
rnd
.
nextInt
(
throwables
.
length
)];
}
void
throwThrowable
(
Throwable
t
)
throws
Exception
{
if
(
t
instanceof
Error
)
throw
(
Error
)
t
;
if
(
t
instanceof
RuntimeException
)
throw
(
RuntimeException
)
t
;
throw
(
Exception
)
t
;
}
//----------------------------------------------------------------
// A Policy class designed to make permissions fiddling very easy.
...
...
@@ -119,9 +125,8 @@ public class PrivilegedCallables {
if
(
rnd
.
nextBoolean
())
{
final
Throwable
t
=
randomThrowable
();
real
=
new
Callable
<
Integer
>()
{
@SuppressWarnings
(
"deprecation"
)
public
Integer
call
()
throws
Exception
{
Thread
.
currentThread
().
stop
(
t
);
throwThrowable
(
t
);
return
null
;
}};
try
{
c
.
call
();
...
...
test/java/util/concurrent/FutureTask/Throw.java
浏览文件 @
c871fee9
...
...
@@ -31,10 +31,9 @@ import java.util.concurrent.*;
public
class
Throw
{
@SuppressWarnings
(
"deprecation"
)
static
void
THROW
(
final
Throwable
t
)
{
if
(
t
!=
null
)
Thr
ead
.
currentThread
().
stop
(
t
);
Thr
ow
.<
RuntimeException
>
uncheckedThrow
(
t
);
}
Callable
<
Void
>
thrower
(
final
Throwable
t
)
{
...
...
@@ -138,4 +137,8 @@ public class Throw {
catch
(
Throwable
t
)
{
if
(
k
.
isAssignableFrom
(
t
.
getClass
()))
pass
();
else
unexpected
(
t
);}}
@SuppressWarnings
(
"unchecked"
)
static
<
T
extends
Throwable
>
void
uncheckedThrow
(
Throwable
t
)
throws
T
{
throw
(
T
)
t
;
// rely on vacuous cast
}
}
test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
浏览文件 @
c871fee9
...
...
@@ -101,8 +101,10 @@ public class ThrowingTasks {
static
class
Thrower
implements
Runnable
{
Throwable
t
;
Thrower
(
Throwable
t
)
{
this
.
t
=
t
;
}
@SuppressWarnings
(
"deprecation"
)
public
void
run
()
{
if
(
t
!=
null
)
Thread
.
currentThread
().
stop
(
t
);
}
public
void
run
()
{
if
(
t
!=
null
)
ThrowingTasks
.<
RuntimeException
>
uncheckedThrow
(
t
);
}
}
static
final
Thrower
noThrower
=
new
Thrower
(
null
);
...
...
@@ -265,4 +267,8 @@ public class ThrowingTasks {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
@SuppressWarnings
(
"unchecked"
)
static
<
T
extends
Throwable
>
void
uncheckedThrow
(
Throwable
t
)
throws
T
{
throw
(
T
)
t
;
// rely on vacuous cast
}
}
test/java/util/concurrent/locks/Lock/FlakyMutex.java
浏览文件 @
c871fee9
...
...
@@ -37,7 +37,7 @@ import java.util.concurrent.locks.*;
* tryAcquire method that randomly throws various Throwable
* subclasses.
*/
@SuppressWarnings
(
{
"deprecation"
,
"serial"
}
)
@SuppressWarnings
(
"serial"
)
public
class
FlakyMutex
implements
Lock
{
static
class
MyError
extends
Error
{}
static
class
MyException
extends
Exception
{}
...
...
@@ -49,7 +49,7 @@ public class FlakyMutex implements Lock {
switch
(
rnd
.
nextInt
(
10
))
{
case
0
:
throw
new
MyError
();
case
1
:
throw
new
MyRuntimeException
();
case
2
:
Thread
.
currentThread
().
stop
(
new
MyException
());
break
;
case
2
:
FlakyMutex
.<
RuntimeException
>
uncheckedThrow
(
new
MyException
())
;
default
:
/* Do nothing */
break
;
}
}
...
...
@@ -146,4 +146,8 @@ public class FlakyMutex implements Lock {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
@SuppressWarnings
(
"unchecked"
)
static
<
T
extends
Throwable
>
void
uncheckedThrow
(
Throwable
t
)
throws
T
{
throw
(
T
)
t
;
// rely on vacuous cast
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录