Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5ae2772b
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看板
提交
5ae2772b
编写于
4月 10, 2015
作者:
A
amurillo
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
8e74b5cd
f80c5cf5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
86 addition
and
12 deletion
+86
-12
test/java/lang/instrument/RedefineMethodInBacktrace.sh
test/java/lang/instrument/RedefineMethodInBacktrace.sh
+2
-2
test/java/lang/instrument/RedefineMethodInBacktraceApp.java
test/java/lang/instrument/RedefineMethodInBacktraceApp.java
+52
-6
test/java/lang/instrument/RedefineMethodInBacktraceTarget.java
...java/lang/instrument/RedefineMethodInBacktraceTarget.java
+10
-1
test/java/lang/instrument/RedefineMethodInBacktraceTargetB.java
...ava/lang/instrument/RedefineMethodInBacktraceTargetB.java
+13
-1
test/java/lang/instrument/RedefineMethodInBacktraceTargetB_2.java
...a/lang/instrument/RedefineMethodInBacktraceTargetB_2.java
+4
-1
test/java/lang/instrument/RedefineMethodInBacktraceTarget_2.java
...va/lang/instrument/RedefineMethodInBacktraceTarget_2.java
+5
-1
未找到文件。
test/java/lang/instrument/RedefineMethodInBacktrace.sh
浏览文件 @
5ae2772b
#
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
...
...
@@ -77,7 +77,7 @@ fi
cat
output.log
MESG
=
"
Exception
"
MESG
=
"
Test failed
"
grep
"
$MESG
"
output.log
result
=
$?
if
[
"
$result
"
=
0
]
;
then
...
...
test/java/lang/instrument/RedefineMethodInBacktraceApp.java
浏览文件 @
5ae2772b
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -46,12 +46,15 @@ import sun.management.ManagementFactoryHelper;
* could be freed, since class redefinition didn't know about the backtraces.
*/
public
class
RedefineMethodInBacktraceApp
{
static
boolean
failed
=
false
;
public
static
void
main
(
String
args
[])
throws
Exception
{
System
.
out
.
println
(
"Hello from RedefineMethodInBacktraceApp!"
);
new
RedefineMethodInBacktraceApp
().
doTest
();
System
.
exit
(
0
);
if
(
failed
)
{
throw
new
Exception
(
"ERROR: RedefineMethodInBacktraceApp failed."
);
}
}
public
static
CountDownLatch
stop
=
new
CountDownLatch
(
1
);
...
...
@@ -63,13 +66,18 @@ public class RedefineMethodInBacktraceApp {
}
private
void
doMethodInBacktraceTest
()
throws
Exception
{
Throwable
t
=
getThrowableFromMethodToRedefine
();
Throwable
t1
=
getThrowableFromMethodToRedefine
();
Throwable
t2
=
getThrowableFromMethodToDelete
();
doRedefine
(
RedefineMethodInBacktraceTarget
.
class
);
doClassUnloading
();
touchRedefinedMethodInBacktrace
(
t
);
System
.
out
.
println
(
"checking backtrace for throwable from methodToRedefine"
);
touchRedefinedMethodInBacktrace
(
t1
);
System
.
out
.
println
(
"checking backtrace for throwable from methodToDelete"
);
touchRedefinedMethodInBacktrace
(
t2
);
}
private
void
doMethodInBacktraceTestB
()
throws
Exception
{
...
...
@@ -115,6 +123,10 @@ public class RedefineMethodInBacktraceApp {
if
(!(
thrownFromMethodToRedefine
instanceof
RuntimeException
))
{
throw
e
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"\nTest failed: unexpected exception: "
+
e
.
toString
());
failed
=
true
;
}
method
=
null
;
c
=
null
;
...
...
@@ -122,15 +134,49 @@ public class RedefineMethodInBacktraceApp {
return
thrownFromMethodToRedefine
;
}
private
static
Throwable
getThrowableFromMethodToDelete
()
throws
Exception
{
Class
<
RedefineMethodInBacktraceTarget
>
c
=
RedefineMethodInBacktraceTarget
.
class
;
Method
method
=
c
.
getMethod
(
"callMethodToDelete"
);
Throwable
thrownFromMethodToDelete
=
null
;
try
{
method
.
invoke
(
null
);
}
catch
(
InvocationTargetException
e
)
{
thrownFromMethodToDelete
=
e
.
getCause
();
if
(!(
thrownFromMethodToDelete
instanceof
RuntimeException
))
{
throw
e
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"\nTest failed: unexpected exception: "
+
e
.
toString
());
failed
=
true
;
}
return
thrownFromMethodToDelete
;
}
private
static
void
doClassUnloading
()
{
// This will clean out old, unused redefined methods.
System
.
gc
();
}
private
static
void
touchRedefinedMethodInBacktrace
(
Throwable
throwable
)
{
throwable
.
printStackTrace
();
// Make sure that we can convert the backtrace, which is referring to
// the redefined method, to a StrackTraceElement[] without crashing.
throwable
.
getStackTrace
();
StackTraceElement
[]
stackTrace
=
throwable
.
getStackTrace
();
for
(
int
i
=
0
;
i
<
stackTrace
.
length
;
i
++)
{
StackTraceElement
frame
=
stackTrace
[
i
];
if
(
frame
.
getClassName
()
==
null
)
{
System
.
out
.
println
(
"\nTest failed: trace["
+
i
+
"].getClassName() returned null"
);
failed
=
true
;
}
if
(
frame
.
getMethodName
()
==
null
)
{
System
.
out
.
println
(
"\nTest failed: trace["
+
i
+
"].getMethodName() returned null"
);
failed
=
true
;
}
}
}
private
static
void
doRedefine
(
Class
<?>
clazz
)
throws
Exception
{
...
...
test/java/lang/instrument/RedefineMethodInBacktraceTarget.java
浏览文件 @
5ae2772b
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -29,4 +29,13 @@ public class RedefineMethodInBacktraceTarget {
public
static
void
methodToRedefine
()
{
throw
new
RuntimeException
(
"Test exception"
);
}
public
static
void
callMethodToDelete
()
{
methodToDelete
();
}
private
static
void
methodToDelete
()
{
throw
new
RuntimeException
(
"Test exception in methodToDelete"
);
}
}
test/java/lang/instrument/RedefineMethodInBacktraceTargetB.java
浏览文件 @
5ae2772b
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -37,4 +37,16 @@ public class RedefineMethodInBacktraceTargetB {
// ignore, test will fail
}
}
public
static
void
callMethodToDelete
()
{
try
{
// signal that we are here
RedefineMethodInBacktraceApp
.
called
.
countDown
();
// wait until test is done
RedefineMethodInBacktraceApp
.
stop
.
await
();
}
catch
(
InterruptedException
ex
)
{
// ignore, test will fail
}
}
}
test/java/lang/instrument/RedefineMethodInBacktraceTargetB_2.java
浏览文件 @
5ae2772b
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -28,4 +28,7 @@
public
class
RedefineMethodInBacktraceTargetB
{
public
static
void
methodToRedefine
()
{
}
public
static
void
callMethodToDelete
()
{
}
}
test/java/lang/instrument/RedefineMethodInBacktraceTarget_2.java
浏览文件 @
5ae2772b
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -29,4 +29,8 @@ public class RedefineMethodInBacktraceTarget {
public
static
void
methodToRedefine
()
{
throw
new
RuntimeException
(
"Test exception 2"
);
}
public
static
void
callMethodToDelete
()
{
throw
new
RuntimeException
(
"Test exception 2 in callMethodToDelete"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录