Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
6cc1c39b
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6cc1c39b
编写于
7月 08, 2008
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6715251: javap should be consistent with javac and return 2 if given no arguments
Reviewed-by: ksrini
上级
e6180220
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
106 addition
and
15 deletion
+106
-15
src/share/classes/com/sun/tools/javap/JavapTask.java
src/share/classes/com/sun/tools/javap/JavapTask.java
+30
-13
test/tools/javap/T4876942.java
test/tools/javap/T4876942.java
+2
-2
test/tools/javap/T6715251.java
test/tools/javap/T6715251.java
+74
-0
未找到文件。
src/share/classes/com/sun/tools/javap/JavapTask.java
浏览文件 @
6cc1c39b
...
...
@@ -306,14 +306,32 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
};
}
/** Result codes.
*/
static
final
int
EXIT_OK
=
0
,
// Compilation completed with no errors.
EXIT_ERROR
=
1
,
// Completed but reported errors.
EXIT_CMDERR
=
2
,
// Bad command-line arguments
EXIT_SYSERR
=
3
,
// System error or resource exhaustion.
EXIT_ABNORMAL
=
4
;
// Compiler terminated abnormally
int
run
(
String
[]
args
)
{
try
{
handleOptions
(
args
);
// the following gives consistent behavior with javac
if
(
classes
==
null
||
classes
.
size
()
==
0
)
{
if
(
options
.
help
||
options
.
version
||
options
.
fullVersion
)
return
EXIT_OK
;
else
return
EXIT_CMDERR
;
}
boolean
ok
=
run
();
return
ok
?
0
:
1
;
return
ok
?
EXIT_OK
:
EXIT_ERROR
;
}
catch
(
BadArgs
e
)
{
diagnosticListener
.
report
(
createDiagnostic
(
e
.
key
,
e
.
args
));
return
1
;
return
EXIT_CMDERR
;
}
catch
(
InternalError
e
)
{
Object
[]
e_args
;
if
(
e
.
getCause
()
==
null
)
...
...
@@ -324,7 +342,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
System
.
arraycopy
(
e
.
args
,
0
,
e_args
,
1
,
e
.
args
.
length
);
}
diagnosticListener
.
report
(
createDiagnostic
(
"err.internal.error"
,
e_args
));
return
1
;
return
EXIT_ABNORMAL
;
}
finally
{
log
.
flush
();
}
...
...
@@ -349,8 +367,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
fileManager
=
getDefaultFileManager
(
diagnosticListener
,
log
);
Iterator
<
String
>
iter
=
args
.
iterator
();
if
(!
iter
.
hasNext
())
options
.
help
=
true
;
boolean
noArgs
=
!
iter
.
hasNext
();
while
(
iter
.
hasNext
())
{
String
arg
=
iter
.
next
();
...
...
@@ -370,9 +387,15 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
((
JavapFileManager
)
fileManager
).
setIgnoreSymbolFile
(
true
);
if
((
classes
==
null
||
classes
.
size
()
==
0
)
&&
!(
options
.
help
||
options
.
version
||
options
.
fullVersion
))
{
!(
noArgs
||
options
.
help
||
options
.
version
||
options
.
fullVersion
))
{
throw
new
BadArgs
(
"err.no.classes.specified"
);
}
if
(
noArgs
||
options
.
help
)
showHelp
();
if
(
options
.
version
||
options
.
fullVersion
)
showVersion
(
options
.
fullVersion
);
}
private
void
handleOption
(
String
name
,
Iterator
<
String
>
rest
)
throws
BadArgs
{
...
...
@@ -405,14 +428,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
}
public
boolean
run
()
{
if
(
options
.
help
)
showHelp
();
if
(
options
.
version
||
options
.
fullVersion
)
showVersion
(
options
.
fullVersion
);
if
(
classes
==
null
||
classes
.
size
()
==
0
)
return
tru
e
;
return
fals
e
;
context
.
put
(
PrintWriter
.
class
,
log
);
ClassWriter
classWriter
=
ClassWriter
.
instance
(
context
);
...
...
test/tools/javap/T4876942.java
浏览文件 @
6cc1c39b
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 4876942
* @bug 4876942
6715251
* @summary javap invoked without args does not print help screen
*/
...
...
@@ -48,7 +48,7 @@ public class T4876942 {
PrintWriter
out
=
new
PrintWriter
(
sw
);
//sun.tools.javap.Main.entry(args);
int
rc
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
args
,
out
);
if
(
rc
!=
0
)
if
(
rc
!=
(
args
.
length
==
0
?
2
:
0
)
)
throw
new
Error
(
"javap failed. rc="
+
rc
);
out
.
close
();
return
sw
.
toString
();
...
...
test/tools/javap/T6715251.java
0 → 100644
浏览文件 @
6cc1c39b
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
java.io.*
;
import
java.util.*
;
/*
* @test
* @bug 6715251
* @summary javap should be consistent with javac and return 2 if given no arguments
*/
public
class
T6715251
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
T6715251
().
run
();
}
void
run
()
throws
Exception
{
String
testClasses
=
System
.
getProperty
(
"test.classes"
,
"."
);
test
(
2
);
test
(
0
,
"-help"
);
test
(
0
,
"-version"
);
test
(
0
,
"-fullversion"
);
test
(
0
,
"-classpath"
,
testClasses
,
"T6715251"
);
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors received"
);
}
void
test
(
int
expect
,
String
...
args
)
{
int
rc
=
javap
(
args
);
if
(
rc
!=
expect
)
error
(
"bad result: expected: "
+
expect
+
", found "
+
rc
+
"\n"
+
log
);
}
int
javap
(
String
...
args
)
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
int
rc
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
args
,
pw
);
log
=
sw
.
toString
();
return
rc
;
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
msg
);
errors
++;
}
String
log
;
int
errors
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录