Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
85345647
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看板
提交
85345647
编写于
1月 04, 2019
作者:
E
egahlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8215771: The jfr tool should pretty print reference chains
Reviewed-by: mgronlun
上级
3d1e902f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
5 deletion
+77
-5
src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java
src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java
+77
-5
未找到文件。
src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java
浏览文件 @
85345647
...
...
@@ -57,9 +57,11 @@ import jdk.jfr.internal.Utils;
* This class is also used by {@link RecordedObject#toString()}
*/
public
final
class
PrettyWriter
extends
EventPrintWriter
{
private
static
final
String
TYPE_OLD_OBJECT
=
Type
.
TYPES_PREFIX
+
"OldObject"
;
private
final
static
DateTimeFormatter
TIME_FORMAT
=
DateTimeFormatter
.
ofPattern
(
"HH:mm:ss.SSS"
);
private
final
static
Long
ZERO
=
0L
;
private
boolean
showIds
;
private
RecordedEvent
currentEvent
;
public
PrettyWriter
(
PrintWriter
destination
)
{
super
(
destination
);
...
...
@@ -198,6 +200,7 @@ public final class PrettyWriter extends EventPrintWriter {
}
public
void
print
(
RecordedEvent
event
)
{
currentEvent
=
event
;
print
(
event
.
getEventType
().
getName
(),
" "
);
println
(
"{"
);
indent
();
...
...
@@ -308,7 +311,11 @@ public final class PrettyWriter extends EventPrintWriter {
println
(
formatMethod
((
RecordedMethod
)
value
));
return
;
}
print
((
RecordedObject
)
value
,
postFix
);
if
(
field
.
getTypeName
().
equals
(
TYPE_OLD_OBJECT
))
{
printOldObject
((
RecordedObject
)
value
);
return
;
}
print
((
RecordedObject
)
value
,
postFix
);
return
;
}
if
(
value
.
getClass
().
isArray
())
{
...
...
@@ -358,6 +365,70 @@ public final class PrettyWriter extends EventPrintWriter {
println
(
text
);
}
private
void
printOldObject
(
RecordedObject
object
)
{
println
(
" ["
);
indent
();
printIndent
();
try
{
printReferenceChain
(
object
);
}
catch
(
IllegalArgumentException
iae
)
{
// Could not find a field
// Not possible to validate fields beforehand using RecordedObject#hasField
// since nested objects, for example object.referrer.array.index, requires
// an actual array object (which may be null).
}
retract
();
printIndent
();
println
(
"]"
);
}
private
void
printReferenceChain
(
RecordedObject
object
)
{
printObject
(
object
,
currentEvent
.
getLong
(
"arrayElements"
));
for
(
RecordedObject
ref
=
object
.
getValue
(
"referrer"
);
ref
!=
null
;
ref
=
object
.
getValue
(
"referrer"
))
{
long
skip
=
ref
.
getLong
(
"skip"
);
if
(
skip
>
0
)
{
printIndent
();
println
(
"..."
);
}
String
objectHolder
=
""
;
long
size
=
Long
.
MIN_VALUE
;
RecordedObject
array
=
ref
.
getValue
(
"array"
);
if
(
array
!=
null
)
{
long
index
=
array
.
getLong
(
"index"
);
size
=
array
.
getLong
(
"size"
);
objectHolder
=
"["
+
index
+
"]"
;
}
RecordedObject
field
=
ref
.
getValue
(
"field"
);
if
(
field
!=
null
)
{
objectHolder
=
field
.
getString
(
"name"
);
}
printIndent
();
print
(
objectHolder
);
print
(
" : "
);
object
=
ref
.
getValue
(
"object"
);
if
(
object
!=
null
)
{
printObject
(
object
,
size
);
}
}
}
void
printObject
(
RecordedObject
object
,
long
arraySize
)
{
RecordedClass
clazz
=
object
.
getClass
(
"type"
);
if
(
clazz
!=
null
)
{
String
className
=
clazz
.
getName
();
if
(
className
!=
null
&&
className
.
startsWith
(
"["
))
{
className
=
decodeDescriptors
(
className
,
arraySize
>
0
?
Long
.
toString
(
arraySize
)
:
""
).
get
(
0
);
}
print
(
className
);
String
description
=
object
.
getString
(
"description"
);
if
(
description
!=
null
)
{
print
(
" "
);
print
(
description
);
}
}
println
();
}
private
void
printClassLoader
(
RecordedClassLoader
cl
,
String
postFix
)
{
// Purposely not printing class loader name to avoid cluttered output
RecordedClass
clazz
=
cl
.
getType
();
...
...
@@ -388,7 +459,7 @@ public final class PrettyWriter extends EventPrintWriter {
StringJoiner
sj
=
new
StringJoiner
(
", "
);
String
md
=
m
.
getDescriptor
().
replace
(
"/"
,
"."
);
String
parameter
=
md
.
substring
(
1
,
md
.
lastIndexOf
(
")"
));
for
(
String
qualifiedName
:
decodeDescriptors
(
parameter
))
{
for
(
String
qualifiedName
:
decodeDescriptors
(
parameter
,
""
))
{
String
typeName
=
qualifiedName
.
substring
(
qualifiedName
.
lastIndexOf
(
'.'
)
+
1
);
sj
.
add
(
typeName
);
}
...
...
@@ -409,17 +480,18 @@ public final class PrettyWriter extends EventPrintWriter {
}
String
className
=
clazz
.
getName
();
if
(
className
.
startsWith
(
"["
))
{
className
=
decodeDescriptors
(
className
).
get
(
0
);
className
=
decodeDescriptors
(
className
,
""
).
get
(
0
);
}
println
(
className
+
" (classLoader = "
+
classLoaderName
+
")"
+
postFix
);
}
List
<
String
>
decodeDescriptors
(
String
descriptor
)
{
List
<
String
>
decodeDescriptors
(
String
descriptor
,
String
arraySize
)
{
List
<
String
>
descriptors
=
new
ArrayList
<>();
for
(
int
index
=
0
;
index
<
descriptor
.
length
();
index
++)
{
String
arrayBrackets
=
""
;
while
(
descriptor
.
charAt
(
index
)
==
'['
)
{
arrayBrackets
+=
"[]"
;
arrayBrackets
=
arrayBrackets
+
"["
+
arraySize
+
"]"
;
arraySize
=
""
;
index
++;
}
char
c
=
descriptor
.
charAt
(
index
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录