Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d121e5cd
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看板
提交
d121e5cd
编写于
11月 14, 2013
作者:
S
sla
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
Reviewed-by: alanb, allwin, sspitsyn, mgronlun
上级
18a6d032
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
126 addition
and
106 deletion
+126
-106
src/share/classes/sun/tools/jinfo/JInfo.java
src/share/classes/sun/tools/jinfo/JInfo.java
+43
-32
src/share/classes/sun/tools/jmap/JMap.java
src/share/classes/sun/tools/jmap/JMap.java
+53
-49
src/share/classes/sun/tools/jps/Jps.java
src/share/classes/sun/tools/jps/Jps.java
+3
-2
src/share/classes/sun/tools/jstack/JStack.java
src/share/classes/sun/tools/jstack/JStack.java
+27
-23
未找到文件。
src/share/classes/sun/tools/jinfo/JInfo.java
浏览文件 @
d121e5cd
...
...
@@ -26,7 +26,6 @@
package
sun.tools.jinfo
;
import
java.lang.reflect.Method
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -44,7 +43,7 @@ public class JInfo {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
usage
();
// no arguments
usage
(
1
);
// no arguments
}
boolean
useSA
=
true
;
...
...
@@ -56,14 +55,20 @@ public class JInfo {
// (<executable> and <code file>). So, total
// argument count including option has to 2 or 3.
if
(
args
.
length
!=
2
&&
args
.
length
!=
3
)
{
usage
();
usage
(
1
);
}
}
else
if
(
arg1
.
equals
(
"-flag"
))
{
// do not use SA, use attach-on-demand
useSA
=
false
;
}
else
{
// unknown option or -h or -help, print help
usage
();
int
exit
;
if
(
arg1
.
equals
(
"-help"
)
||
arg1
.
equals
(
"-h"
))
{
exit
=
0
;
}
else
{
exit
=
1
;
}
usage
(
exit
);
}
}
...
...
@@ -75,7 +80,13 @@ public class JInfo {
String
option
=
args
[
1
];
flag
(
pid
,
option
);
}
else
{
usage
();
int
exit
;
if
(
arg1
.
equals
(
"-help"
)
||
arg1
.
equals
(
"-h"
))
{
exit
=
0
;
}
else
{
exit
=
1
;
}
usage
(
exit
);
}
}
}
...
...
@@ -86,7 +97,7 @@ public class JInfo {
// Tool not available on this platform.
Class
<?>
c
=
loadClass
(
tool
);
if
(
c
==
null
)
{
usage
();
usage
(
1
);
}
// invoke the main method with the arguments
...
...
@@ -176,39 +187,39 @@ public class JInfo {
// print usage message
private
static
void
usage
()
{
private
static
void
usage
(
int
exit
)
{
Class
<?>
c
=
loadClass
(
"sun.jvm.hotspot.tools.JInfo"
);
boolean
usageSA
=
(
c
!=
null
);
System
.
out
.
println
(
"Usage:"
);
System
.
err
.
println
(
"Usage:"
);
if
(
usageSA
)
{
System
.
out
.
println
(
" jinfo [option] <pid>"
);
System
.
out
.
println
(
" (to connect to running process)"
);
System
.
out
.
println
(
" jinfo [option] <executable <core>"
);
System
.
out
.
println
(
" (to connect to a core file)"
);
System
.
out
.
println
(
" jinfo [option] [server_id@]<remote server IP or hostname>"
);
System
.
out
.
println
(
" (to connect to remote debug server)"
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"where <option> is one of:"
);
System
.
out
.
println
(
" -flag <name> to print the value of the named VM flag"
);
System
.
out
.
println
(
" -flag [+|-]<name> to enable or disable the named VM flag"
);
System
.
out
.
println
(
" -flag <name>=<value> to set the named VM flag to the given value"
);
System
.
out
.
println
(
" -flags to print VM flags"
);
System
.
out
.
println
(
" -sysprops to print Java system properties"
);
System
.
out
.
println
(
" <no option> to print both of the above"
);
System
.
out
.
println
(
" -h | -help to print this help message"
);
System
.
err
.
println
(
" jinfo [option] <pid>"
);
System
.
err
.
println
(
" (to connect to running process)"
);
System
.
err
.
println
(
" jinfo [option] <executable <core>"
);
System
.
err
.
println
(
" (to connect to a core file)"
);
System
.
err
.
println
(
" jinfo [option] [server_id@]<remote server IP or hostname>"
);
System
.
err
.
println
(
" (to connect to remote debug server)"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
"where <option> is one of:"
);
System
.
err
.
println
(
" -flag <name> to print the value of the named VM flag"
);
System
.
err
.
println
(
" -flag [+|-]<name> to enable or disable the named VM flag"
);
System
.
err
.
println
(
" -flag <name>=<value> to set the named VM flag to the given value"
);
System
.
err
.
println
(
" -flags to print VM flags"
);
System
.
err
.
println
(
" -sysprops to print Java system properties"
);
System
.
err
.
println
(
" <no option> to print both of the above"
);
System
.
err
.
println
(
" -h | -help to print this help message"
);
}
else
{
System
.
out
.
println
(
" jinfo <option> <pid>"
);
System
.
out
.
println
(
" (to connect to a running process)"
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"where <option> is one of:"
);
System
.
out
.
println
(
" -flag <name> to print the value of the named VM flag"
);
System
.
out
.
println
(
" -flag [+|-]<name> to enable or disable the named VM flag"
);
System
.
out
.
println
(
" -flag <name>=<value> to set the named VM flag to the given value"
);
System
.
out
.
println
(
" -h | -help to print this help message"
);
System
.
err
.
println
(
" jinfo <option> <pid>"
);
System
.
err
.
println
(
" (to connect to a running process)"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
"where <option> is one of:"
);
System
.
err
.
println
(
" -flag <name> to print the value of the named VM flag"
);
System
.
err
.
println
(
" -flag [+|-]<name> to enable or disable the named VM flag"
);
System
.
err
.
println
(
" -flag <name>=<value> to set the named VM flag to the given value"
);
System
.
err
.
println
(
" -h | -help to print this help message"
);
}
System
.
exit
(
1
);
System
.
exit
(
exit
);
}
}
src/share/classes/sun/tools/jmap/JMap.java
浏览文件 @
d121e5cd
...
...
@@ -60,7 +60,7 @@ public class JMap {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
usage
();
// no arguments
usage
(
1
);
// no arguments
}
// used to indicate if we should use SA
...
...
@@ -77,11 +77,13 @@ public class JMap {
if
(!
arg
.
startsWith
(
"-"
))
{
break
;
}
if
(
arg
.
equals
(
FORCE_SA_OPTION
))
{
if
(
arg
.
equals
(
"-help"
)
||
arg
.
equals
(
"-h"
))
{
usage
(
0
);
}
else
if
(
arg
.
equals
(
FORCE_SA_OPTION
))
{
useSA
=
true
;
}
else
{
if
(
option
!=
null
)
{
usage
();
// option already specified
usage
(
1
);
// option already specified
}
option
=
arg
;
}
...
...
@@ -101,7 +103,7 @@ public class JMap {
// only one parameter (the process-id)
int
paramCount
=
args
.
length
-
optionCount
;
if
(
paramCount
==
0
||
paramCount
>
2
)
{
usage
();
usage
(
1
);
}
if
(
optionCount
==
0
||
paramCount
!=
1
)
{
...
...
@@ -139,7 +141,7 @@ public class JMap {
}
else
if
(
option
.
startsWith
(
DUMP_OPTION_PREFIX
))
{
dump
(
pid
,
option
);
}
else
{
usage
();
usage
(
1
);
}
}
}
...
...
@@ -161,7 +163,9 @@ public class JMap {
if
(
option
.
startsWith
(
DUMP_OPTION_PREFIX
))
{
// first check that the option can be parsed
String
fn
=
parseDumpOptions
(
option
);
if
(
fn
==
null
)
usage
();
if
(
fn
==
null
)
{
usage
(
1
);
}
// tool for heap dumping
tool
=
"sun.jvm.hotspot.tools.HeapDumper"
;
...
...
@@ -180,13 +184,13 @@ public class JMap {
}
}
if
(
tool
==
null
)
{
usage
();
// no mapping to tool
usage
(
1
);
// no mapping to tool
}
// Tool not available on this platform.
Class
<?>
c
=
loadClass
(
tool
);
if
(
c
==
null
)
{
usage
();
usage
(
1
);
}
// invoke the main method with the arguments
...
...
@@ -225,7 +229,7 @@ public class JMap {
// parse the options to get the dump filename
String
filename
=
parseDumpOptions
(
options
);
if
(
filename
==
null
)
{
usage
();
// invalid options or no filename
usage
(
1
);
// invalid options or no filename
}
// get the canonical path - important to avoid just passing
...
...
@@ -341,49 +345,49 @@ public class JMap {
}
// print usage message
private
static
void
usage
()
{
System
.
out
.
println
(
"Usage:"
);
private
static
void
usage
(
int
exit
)
{
System
.
err
.
println
(
"Usage:"
);
if
(
haveSA
())
{
System
.
out
.
println
(
" jmap [option] <pid>"
);
System
.
out
.
println
(
" (to connect to running process)"
);
System
.
out
.
println
(
" jmap [option] <executable <core>"
);
System
.
out
.
println
(
" (to connect to a core file)"
);
System
.
out
.
println
(
" jmap [option] [server_id@]<remote server IP or hostname>"
);
System
.
out
.
println
(
" (to connect to remote debug server)"
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"where <option> is one of:"
);
System
.
out
.
println
(
" <none> to print same info as Solaris pmap"
);
System
.
out
.
println
(
" -heap to print java heap summary"
);
System
.
out
.
println
(
" -histo[:live] to print histogram of java object heap; if the \"live\""
);
System
.
out
.
println
(
" suboption is specified, only count live objects"
);
System
.
out
.
println
(
" -clstats to print class loader statistics"
);
System
.
out
.
println
(
" -finalizerinfo to print information on objects awaiting finalization"
);
System
.
out
.
println
(
" -dump:<dump-options> to dump java heap in hprof binary format"
);
System
.
out
.
println
(
" dump-options:"
);
System
.
out
.
println
(
" live dump only live objects; if not specified,"
);
System
.
out
.
println
(
" all objects in the heap are dumped."
);
System
.
out
.
println
(
" format=b binary format"
);
System
.
out
.
println
(
" file=<file> dump heap to <file>"
);
System
.
out
.
println
(
" Example: jmap -dump:live,format=b,file=heap.bin <pid>"
);
System
.
out
.
println
(
" -F force. Use with -dump:<dump-options> <pid> or -histo"
);
System
.
out
.
println
(
" to force a heap dump or histogram when <pid> does not"
);
System
.
out
.
println
(
" respond. The \"live\" suboption is not supported"
);
System
.
out
.
println
(
" in this mode."
);
System
.
out
.
println
(
" -h | -help to print this help message"
);
System
.
out
.
println
(
" -J<flag> to pass <flag> directly to the runtime system"
);
System
.
err
.
println
(
" jmap [option] <pid>"
);
System
.
err
.
println
(
" (to connect to running process)"
);
System
.
err
.
println
(
" jmap [option] <executable <core>"
);
System
.
err
.
println
(
" (to connect to a core file)"
);
System
.
err
.
println
(
" jmap [option] [server_id@]<remote server IP or hostname>"
);
System
.
err
.
println
(
" (to connect to remote debug server)"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
"where <option> is one of:"
);
System
.
err
.
println
(
" <none> to print same info as Solaris pmap"
);
System
.
err
.
println
(
" -heap to print java heap summary"
);
System
.
err
.
println
(
" -histo[:live] to print histogram of java object heap; if the \"live\""
);
System
.
err
.
println
(
" suboption is specified, only count live objects"
);
System
.
err
.
println
(
" -clstats to print class loader statistics"
);
System
.
err
.
println
(
" -finalizerinfo to print information on objects awaiting finalization"
);
System
.
err
.
println
(
" -dump:<dump-options> to dump java heap in hprof binary format"
);
System
.
err
.
println
(
" dump-options:"
);
System
.
err
.
println
(
" live dump only live objects; if not specified,"
);
System
.
err
.
println
(
" all objects in the heap are dumped."
);
System
.
err
.
println
(
" format=b binary format"
);
System
.
err
.
println
(
" file=<file> dump heap to <file>"
);
System
.
err
.
println
(
" Example: jmap -dump:live,format=b,file=heap.bin <pid>"
);
System
.
err
.
println
(
" -F force. Use with -dump:<dump-options> <pid> or -histo"
);
System
.
err
.
println
(
" to force a heap dump or histogram when <pid> does not"
);
System
.
err
.
println
(
" respond. The \"live\" suboption is not supported"
);
System
.
err
.
println
(
" in this mode."
);
System
.
err
.
println
(
" -h | -help to print this help message"
);
System
.
err
.
println
(
" -J<flag> to pass <flag> directly to the runtime system"
);
}
else
{
System
.
out
.
println
(
" jmap -histo <pid>"
);
System
.
out
.
println
(
" (to connect to running process and print histogram of java object heap"
);
System
.
out
.
println
(
" jmap -dump:<dump-options> <pid>"
);
System
.
out
.
println
(
" (to connect to running process and dump java heap)"
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
" dump-options:"
);
System
.
out
.
println
(
" format=b binary default"
);
System
.
out
.
println
(
" file=<file> dump heap to <file>"
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
" Example: jmap -dump:format=b,file=heap.bin <pid>"
);
System
.
err
.
println
(
" jmap -histo <pid>"
);
System
.
err
.
println
(
" (to connect to running process and print histogram of java object heap"
);
System
.
err
.
println
(
" jmap -dump:<dump-options> <pid>"
);
System
.
err
.
println
(
" (to connect to running process and dump java heap)"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
" dump-options:"
);
System
.
err
.
println
(
" format=b binary default"
);
System
.
err
.
println
(
" file=<file> dump heap to <file>"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
" Example: jmap -dump:format=b,file=heap.bin <pid>"
);
}
System
.
exit
(
1
);
System
.
exit
(
exit
);
}
}
src/share/classes/sun/tools/jps/Jps.java
浏览文件 @
d121e5cd
...
...
@@ -45,11 +45,11 @@ public class Jps {
}
catch
(
IllegalArgumentException
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
Arguments
.
printUsage
(
System
.
err
);
return
;
System
.
exit
(
1
)
;
}
if
(
arguments
.
isHelp
())
{
Arguments
.
printUsage
(
System
.
out
);
Arguments
.
printUsage
(
System
.
err
);
System
.
exit
(
0
);
}
...
...
@@ -165,6 +165,7 @@ public class Jps {
e
.
printStackTrace
();
}
}
System
.
exit
(
1
);
}
}
}
src/share/classes/sun/tools/jstack/JStack.java
浏览文件 @
d121e5cd
...
...
@@ -42,7 +42,7 @@ import sun.tools.attach.HotSpotVirtualMachine;
public
class
JStack
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
usage
();
// no arguments
usage
(
1
);
// no arguments
}
boolean
useSA
=
false
;
...
...
@@ -56,16 +56,20 @@ public class JStack {
if
(!
arg
.
startsWith
(
"-"
))
{
break
;
}
if
(
arg
.
equals
(
"-F"
))
{
if
(
arg
.
equals
(
"-help"
)
||
arg
.
equals
(
"-h"
))
{
usage
(
0
);
}
else
if
(
arg
.
equals
(
"-F"
))
{
useSA
=
true
;
}
else
{
}
else
{
if
(
arg
.
equals
(
"-m"
))
{
mixed
=
true
;
}
else
{
if
(
arg
.
equals
(
"-l"
))
{
locks
=
true
;
}
else
{
usage
();
usage
(
1
);
}
}
}
...
...
@@ -81,7 +85,7 @@ public class JStack {
// we assume core file and executable so we use SA.
int
paramCount
=
args
.
length
-
optionCount
;
if
(
paramCount
==
0
||
paramCount
>
2
)
{
usage
();
usage
(
1
);
}
if
(
paramCount
==
2
)
{
useSA
=
true
;
...
...
@@ -118,7 +122,7 @@ public class JStack {
private
static
void
runJStackTool
(
boolean
mixed
,
boolean
locks
,
String
args
[])
throws
Exception
{
Class
<?>
cl
=
loadSAClass
();
if
(
cl
==
null
)
{
usage
();
// SA not available
usage
(
1
);
// SA not available
}
// JStack tool also takes -m and -l arguments
...
...
@@ -199,31 +203,31 @@ public class JStack {
}
// print usage message
private
static
void
usage
()
{
System
.
out
.
println
(
"Usage:"
);
System
.
out
.
println
(
" jstack [-l] <pid>"
);
System
.
out
.
println
(
" (to connect to running process)"
);
private
static
void
usage
(
int
exit
)
{
System
.
err
.
println
(
"Usage:"
);
System
.
err
.
println
(
" jstack [-l] <pid>"
);
System
.
err
.
println
(
" (to connect to running process)"
);
if
(
loadSAClass
()
!=
null
)
{
System
.
out
.
println
(
" jstack -F [-m] [-l] <pid>"
);
System
.
out
.
println
(
" (to connect to a hung process)"
);
System
.
out
.
println
(
" jstack [-m] [-l] <executable> <core>"
);
System
.
out
.
println
(
" (to connect to a core file)"
);
System
.
out
.
println
(
" jstack [-m] [-l] [server_id@]<remote server IP or hostname>"
);
System
.
out
.
println
(
" (to connect to a remote debug server)"
);
System
.
err
.
println
(
" jstack -F [-m] [-l] <pid>"
);
System
.
err
.
println
(
" (to connect to a hung process)"
);
System
.
err
.
println
(
" jstack [-m] [-l] <executable> <core>"
);
System
.
err
.
println
(
" (to connect to a core file)"
);
System
.
err
.
println
(
" jstack [-m] [-l] [server_id@]<remote server IP or hostname>"
);
System
.
err
.
println
(
" (to connect to a remote debug server)"
);
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"Options:"
);
System
.
err
.
println
(
""
);
System
.
err
.
println
(
"Options:"
);
if
(
loadSAClass
()
!=
null
)
{
System
.
out
.
println
(
" -F to force a thread dump. Use when jstack <pid> does not respond"
+
System
.
err
.
println
(
" -F to force a thread dump. Use when jstack <pid> does not respond"
+
" (process is hung)"
);
System
.
out
.
println
(
" -m to print both java and native frames (mixed mode)"
);
System
.
err
.
println
(
" -m to print both java and native frames (mixed mode)"
);
}
System
.
out
.
println
(
" -l long listing. Prints additional information about locks"
);
System
.
out
.
println
(
" -h or -help to print this help message"
);
System
.
exit
(
1
);
System
.
err
.
println
(
" -l long listing. Prints additional information about locks"
);
System
.
err
.
println
(
" -h or -help to print this help message"
);
System
.
exit
(
exit
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录