Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
0c56bf05
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看板
提交
0c56bf05
编写于
6月 11, 2013
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8007907: javap, method com.sun.tools.javap.Main.run returns 0 even in case of class not found error
Reviewed-by: jjg
上级
03b756cc
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
117 addition
and
43 deletion
+117
-43
src/share/classes/com/sun/tools/javap/JavapTask.java
src/share/classes/com/sun/tools/javap/JavapTask.java
+27
-25
test/tools/javac/constDebug/ConstDebugTest.java
test/tools/javac/constDebug/ConstDebugTest.java
+10
-11
test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java
test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java
+1
-2
test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java
...ls/javap/8007907/JavapReturns0AfterClassNotFoundTest.java
+75
-0
test/tools/javap/T4777949.java
test/tools/javap/T4777949.java
+3
-3
test/tools/javap/T7190862.java
test/tools/javap/T7190862.java
+1
-2
未找到文件。
src/share/classes/com/sun/tools/javap/JavapTask.java
浏览文件 @
0c56bf05
...
@@ -452,8 +452,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -452,8 +452,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
}
}
try
{
try
{
boolean
ok
=
run
();
return
run
();
return
ok
?
EXIT_OK
:
EXIT_ERROR
;
}
finally
{
}
finally
{
if
(
defaultFileManager
!=
null
)
{
if
(
defaultFileManager
!=
null
)
{
try
{
try
{
...
@@ -569,12 +568,13 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -569,12 +568,13 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
}
}
public
Boolean
call
()
{
public
Boolean
call
()
{
return
run
();
return
run
()
==
0
;
}
}
public
boolean
run
()
{
public
int
run
()
{
if
(
classes
==
null
||
classes
.
size
()
==
0
)
if
(
classes
==
null
||
classes
.
isEmpty
())
{
return
false
;
return
EXIT_ERROR
;
}
context
.
put
(
PrintWriter
.
class
,
log
);
context
.
put
(
PrintWriter
.
class
,
log
);
ClassWriter
classWriter
=
ClassWriter
.
instance
(
context
);
ClassWriter
classWriter
=
ClassWriter
.
instance
(
context
);
...
@@ -583,55 +583,56 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -583,55 +583,56 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
attributeFactory
.
setCompat
(
options
.
compat
);
attributeFactory
.
setCompat
(
options
.
compat
);
boolean
ok
=
true
;
int
result
=
EXIT_OK
;
for
(
String
className:
classes
)
{
for
(
String
className:
classes
)
{
JavaFileObject
fo
;
try
{
try
{
writeClass
(
classWriter
,
className
);
result
=
writeClass
(
classWriter
,
className
);
}
catch
(
ConstantPoolException
e
)
{
}
catch
(
ConstantPoolException
e
)
{
reportError
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
());
reportError
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
());
ok
=
false
;
result
=
EXIT_ERROR
;
}
catch
(
EOFException
e
)
{
}
catch
(
EOFException
e
)
{
reportError
(
"err.end.of.file"
,
className
);
reportError
(
"err.end.of.file"
,
className
);
ok
=
false
;
result
=
EXIT_ERROR
;
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
reportError
(
"err.file.not.found"
,
e
.
getLocalizedMessage
());
reportError
(
"err.file.not.found"
,
e
.
getLocalizedMessage
());
ok
=
false
;
result
=
EXIT_ERROR
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
//e.printStackTrace();
//e.printStackTrace();
Object
msg
=
e
.
getLocalizedMessage
();
Object
msg
=
e
.
getLocalizedMessage
();
if
(
msg
==
null
)
if
(
msg
==
null
)
{
msg
=
e
;
msg
=
e
;
}
reportError
(
"err.ioerror"
,
className
,
msg
);
reportError
(
"err.ioerror"
,
className
,
msg
);
ok
=
false
;
result
=
EXIT_ERROR
;
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
StringWriter
sw
=
new
StringWriter
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
PrintWriter
pw
=
new
PrintWriter
(
sw
);
t
.
printStackTrace
(
pw
);
t
.
printStackTrace
(
pw
);
pw
.
close
();
pw
.
close
();
reportError
(
"err.crash"
,
t
.
toString
(),
sw
.
toString
());
reportError
(
"err.crash"
,
t
.
toString
(),
sw
.
toString
());
ok
=
false
;
result
=
EXIT_ABNORMAL
;
}
}
}
}
return
ok
;
return
result
;
}
}
protected
boolean
writeClass
(
ClassWriter
classWriter
,
String
className
)
protected
int
writeClass
(
ClassWriter
classWriter
,
String
className
)
throws
IOException
,
ConstantPoolException
{
throws
IOException
,
ConstantPoolException
{
JavaFileObject
fo
=
open
(
className
);
JavaFileObject
fo
=
open
(
className
);
if
(
fo
==
null
)
{
if
(
fo
==
null
)
{
reportError
(
"err.class.not.found"
,
className
);
reportError
(
"err.class.not.found"
,
className
);
return
false
;
return
EXIT_ERROR
;
}
}
ClassFileInfo
cfInfo
=
read
(
fo
);
ClassFileInfo
cfInfo
=
read
(
fo
);
if
(!
className
.
endsWith
(
".class"
))
{
if
(!
className
.
endsWith
(
".class"
))
{
String
cfName
=
cfInfo
.
cf
.
getName
();
String
cfName
=
cfInfo
.
cf
.
getName
();
if
(!
cfName
.
replaceAll
(
"[/$]"
,
"."
).
equals
(
className
.
replaceAll
(
"[/$]"
,
"."
)))
if
(!
cfName
.
replaceAll
(
"[/$]"
,
"."
).
equals
(
className
.
replaceAll
(
"[/$]"
,
"."
)))
{
reportWarning
(
"warn.unexpected.class"
,
className
,
cfName
.
replace
(
'/'
,
'.'
));
reportWarning
(
"warn.unexpected.class"
,
className
,
cfName
.
replace
(
'/'
,
'.'
));
}
}
}
write
(
cfInfo
);
write
(
cfInfo
);
if
(
options
.
showInnerClasses
)
{
if
(
options
.
showInnerClasses
)
{
...
@@ -640,7 +641,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -640,7 +641,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
if
(
a
instanceof
InnerClasses_attribute
)
{
if
(
a
instanceof
InnerClasses_attribute
)
{
InnerClasses_attribute
inners
=
(
InnerClasses_attribute
)
a
;
InnerClasses_attribute
inners
=
(
InnerClasses_attribute
)
a
;
try
{
try
{
boolean
ok
=
true
;
int
result
=
EXIT_OK
;
for
(
int
i
=
0
;
i
<
inners
.
classes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
inners
.
classes
.
length
;
i
++)
{
int
outerIndex
=
inners
.
classes
[
i
].
outer_class_info_index
;
int
outerIndex
=
inners
.
classes
[
i
].
outer_class_info_index
;
ConstantPool
.
CONSTANT_Class_info
outerClassInfo
=
cf
.
constant_pool
.
getClassInfo
(
outerIndex
);
ConstantPool
.
CONSTANT_Class_info
outerClassInfo
=
cf
.
constant_pool
.
getClassInfo
(
outerIndex
);
...
@@ -651,21 +652,22 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -651,21 +652,22 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
String
innerClassName
=
innerClassInfo
.
getName
();
String
innerClassName
=
innerClassInfo
.
getName
();
classWriter
.
println
(
"// inner class "
+
innerClassName
.
replaceAll
(
"[/$]"
,
"."
));
classWriter
.
println
(
"// inner class "
+
innerClassName
.
replaceAll
(
"[/$]"
,
"."
));
classWriter
.
println
();
classWriter
.
println
();
ok
=
ok
&
writeClass
(
classWriter
,
innerClassName
);
result
=
writeClass
(
classWriter
,
innerClassName
);
if
(
result
!=
EXIT_OK
)
return
result
;
}
}
}
}
return
ok
;
return
result
;
}
catch
(
ConstantPoolException
e
)
{
}
catch
(
ConstantPoolException
e
)
{
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
return
false
;
return
EXIT_ERROR
;
}
}
}
else
if
(
a
!=
null
)
{
}
else
if
(
a
!=
null
)
{
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
return
false
;
return
EXIT_ERROR
;
}
}
}
}
return
true
;
return
EXIT_OK
;
}
}
protected
JavaFileObject
open
(
String
className
)
throws
IOException
{
protected
JavaFileObject
open
(
String
className
)
throws
IOException
{
...
...
test/tools/javac/constDebug/ConstDebugTest.java
浏览文件 @
0c56bf05
...
@@ -25,27 +25,26 @@
...
@@ -25,27 +25,26 @@
* @test
* @test
* @bug 4645152 4785453
* @bug 4645152 4785453
* @summary javac compiler incorrectly inserts <clinit> when -g is specified
* @summary javac compiler incorrectly inserts <clinit> when -g is specified
* @library /tools/javac/lib
* @build ToolBox
* @run compile -g ConstDebugTest.java
* @run compile -g ConstDebugTest.java
* @run main ConstDebugTest
* @run main ConstDebugTest
*/
*/
import
java.nio.file.Paths
;
import
com.sun.tools.classfile.ClassFile
;
import
com.sun.tools.classfile.Method
;
//original test: test/tools/javac/constDebug/ConstDebug.sh
public
class
ConstDebugTest
{
public
class
ConstDebugTest
{
public
static
final
long
l
=
12
;
public
static
final
long
l
=
12
;
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
ClassFile
classFile
=
ClassFile
.
read
(
Paths
.
get
(
System
.
getProperty
(
"test.classes"
),
// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
ConstDebugTest
.
class
.
getSimpleName
()
+
".class"
));
ToolBox
.
JavaToolArgs
javapArgs
=
for
(
Method
method:
classFile
.
methods
)
{
new
ToolBox
.
JavaToolArgs
().
setAllArgs
(
"-v"
,
if
(
method
.
getName
(
classFile
.
constant_pool
).
equals
(
"<clinit>"
))
{
"-classpath"
,
System
.
getProperty
(
"test.classes"
),
"ConstDebugTest.class"
);
if
(
ToolBox
.
javap
(
javapArgs
).
contains
(
"clinit"
))
{
throw
new
AssertionError
(
throw
new
AssertionError
(
"javac should not create a <clinit> method for ConstDebugTest class"
);
"javac should not create a <clinit> method for ConstDebugTest class"
);
}
}
}
}
}
}
}
test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java
浏览文件 @
0c56bf05
...
@@ -66,8 +66,7 @@ public class JavapTaskCtorFailWithNPE {
...
@@ -66,8 +66,7 @@ public class JavapTaskCtorFailWithNPE {
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
null
,
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
null
,
Arrays
.
asList
(
classToCheck
.
getPath
()));
Arrays
.
asList
(
classToCheck
.
getPath
()));
boolean
ok
=
t
.
run
();
if
(
t
.
run
()
!=
0
)
if
(!
ok
)
throw
new
Error
(
"javap failed unexpectedly"
);
throw
new
Error
(
"javap failed unexpectedly"
);
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
...
...
test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java
0 → 100644
浏览文件 @
0c56bf05
/*
* Copyright (c) 2013, 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
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8007907
* @summary javap, method com.sun.tools.javap.Main.run returns 0 even in case
* of class not found error
*/
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
public
class
JavapReturns0AfterClassNotFoundTest
{
static
final
String
fileNotFoundErrorMsg
=
"Error: class not found: Unexisting.class"
;
static
final
String
exitCodeClassNotFoundAssertionMsg
=
"Javap's exit code for class not found should be 1"
;
static
final
String
classNotFoundMsgAssertionMsg
=
"Javap's error message for class not found is incorrect"
;
public
static
void
main
(
String
args
[])
throws
Exception
{
new
JavapReturns0AfterClassNotFoundTest
().
run
();
}
void
run
()
throws
IOException
{
check
(
exitCodeClassNotFoundAssertionMsg
,
classNotFoundMsgAssertionMsg
,
fileNotFoundErrorMsg
,
"-v"
,
"Unexisting.class"
);
}
void
check
(
String
exitCodeAssertionMsg
,
String
errMsgAssertionMsg
,
String
expectedErrMsg
,
String
...
params
)
{
int
result
;
StringWriter
s
;
String
out
;
try
(
PrintWriter
pw
=
new
PrintWriter
(
s
=
new
StringWriter
()))
{
result
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
params
,
pw
);
//no line separator, no problem
out
=
s
.
toString
().
trim
();
}
if
(
result
!=
1
)
{
System
.
out
.
println
(
"actual exit code "
+
result
);
throw
new
AssertionError
(
exitCodeAssertionMsg
);
}
if
(!
out
.
equals
(
expectedErrMsg
))
{
System
.
out
.
println
(
"actual "
+
out
);
System
.
out
.
println
(
"expected "
+
expectedErrMsg
);
throw
new
AssertionError
(
errMsgAssertionMsg
);
}
}
}
test/tools/javap/T4777949.java
浏览文件 @
0c56bf05
/*
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -87,11 +87,11 @@ public class T4777949 {
...
@@ -87,11 +87,11 @@ public class T4777949 {
PrintWriter
pw
=
new
PrintWriter
(
sw
);
PrintWriter
pw
=
new
PrintWriter
(
sw
);
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
args
,
classes
);
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
args
,
classes
);
boolean
ok
=
t
.
run
();
int
ok
=
t
.
run
();
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
if
(
!
ok
)
if
(
ok
!=
0
)
error
(
"javap failed unexpectedly"
);
error
(
"javap failed unexpectedly"
);
System
.
err
.
println
(
"args="
+
args
+
" classes="
+
classes
+
"\n"
System
.
err
.
println
(
"args="
+
args
+
" classes="
+
classes
+
"\n"
...
...
test/tools/javap/T7190862.java
浏览文件 @
0c56bf05
...
@@ -96,8 +96,7 @@ public class T7190862 {
...
@@ -96,8 +96,7 @@ public class T7190862 {
PrintWriter
pw
=
new
PrintWriter
(
sw
);
PrintWriter
pw
=
new
PrintWriter
(
sw
);
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavaFileManager
fm
=
JavapFileManager
.
create
(
dc
,
pw
);
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
args
,
classes
);
JavapTask
t
=
new
JavapTask
(
pw
,
fm
,
dc
,
args
,
classes
);
boolean
ok
=
t
.
run
();
if
(
t
.
run
()
!=
0
)
if
(!
ok
)
throw
new
Error
(
"javap failed unexpectedly"
);
throw
new
Error
(
"javap failed unexpectedly"
);
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
List
<
Diagnostic
<?
extends
JavaFileObject
>>
diags
=
dc
.
getDiagnostics
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录