Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
547ea756
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看板
提交
547ea756
编写于
7月 30, 2009
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4880672: javap does not output inner interfaces of an interface
Reviewed-by: mcimadamore
上级
34f3f8d9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
169 addition
and
35 deletion
+169
-35
src/share/classes/com/sun/tools/javap/JavapTask.java
src/share/classes/com/sun/tools/javap/JavapTask.java
+81
-35
src/share/classes/com/sun/tools/javap/Options.java
src/share/classes/com/sun/tools/javap/Options.java
+1
-0
src/share/classes/com/sun/tools/javap/resources/javap.properties
...re/classes/com/sun/tools/javap/resources/javap.properties
+1
-0
test/tools/javap/T4880672.java
test/tools/javap/T4880672.java
+86
-0
未找到文件。
src/share/classes/com/sun/tools/javap/JavapTask.java
浏览文件 @
547ea756
...
@@ -289,6 +289,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -289,6 +289,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
{
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
{
task
.
options
.
showConstants
=
true
;
task
.
options
.
showConstants
=
true
;
}
}
},
new
Option
(
false
,
"-XDinner"
)
{
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
{
task
.
options
.
showInnerClasses
=
true
;
}
}
}
};
};
...
@@ -529,46 +535,15 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -529,46 +535,15 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
SourceWriter
sourceWriter
=
SourceWriter
.
instance
(
context
);
SourceWriter
sourceWriter
=
SourceWriter
.
instance
(
context
);
sourceWriter
.
setFileManager
(
fileManager
);
sourceWriter
.
setFileManager
(
fileManager
);
attributeFactory
.
setCompat
(
options
.
compat
);
attributeFactory
.
setJSR277
(
options
.
jsr277
);
boolean
ok
=
true
;
boolean
ok
=
true
;
for
(
String
className:
classes
)
{
for
(
String
className:
classes
)
{
JavaFileObject
fo
;
JavaFileObject
fo
;
try
{
try
{
if
(
className
.
endsWith
(
".class"
))
{
writeClass
(
classWriter
,
className
);
if
(
fileManager
instanceof
StandardJavaFileManager
)
{
StandardJavaFileManager
sfm
=
(
StandardJavaFileManager
)
fileManager
;
fo
=
sfm
.
getJavaFileObjects
(
className
).
iterator
().
next
();
}
else
{
reportError
(
"err.not.standard.file.manager"
,
className
);
ok
=
false
;
continue
;
}
}
else
{
fo
=
getClassFileObject
(
className
);
if
(
fo
==
null
)
{
// see if it is an inner class, by replacing dots to $, starting from the right
String
cn
=
className
;
int
lastDot
;
while
(
fo
==
null
&&
(
lastDot
=
cn
.
lastIndexOf
(
"."
))
!=
-
1
)
{
cn
=
cn
.
substring
(
0
,
lastDot
)
+
"$"
+
cn
.
substring
(
lastDot
+
1
);
fo
=
getClassFileObject
(
cn
);
}
}
if
(
fo
==
null
)
{
reportError
(
"err.class.not.found"
,
className
);
ok
=
false
;
continue
;
}
}
attributeFactory
.
setCompat
(
options
.
compat
);
attributeFactory
.
setJSR277
(
options
.
jsr277
);
ClassFileInfo
cfInfo
=
read
(
fo
);
if
(!
className
.
endsWith
(
".class"
))
{
String
cfName
=
cfInfo
.
cf
.
getName
();
if
(!
cfName
.
replaceAll
(
"[/$]"
,
"."
).
equals
(
className
.
replaceAll
(
"[/$]"
,
"."
)))
reportWarning
(
"warn.unexpected.class"
,
className
,
cfName
.
replace
(
'/'
,
'.'
));
}
write
(
cfInfo
);
}
catch
(
ConstantPoolException
e
)
{
}
catch
(
ConstantPoolException
e
)
{
reportError
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
());
reportError
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
());
ok
=
false
;
ok
=
false
;
...
@@ -598,6 +573,76 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -598,6 +573,76 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
return
ok
;
return
ok
;
}
}
protected
boolean
writeClass
(
ClassWriter
classWriter
,
String
className
)
throws
IOException
,
ConstantPoolException
{
JavaFileObject
fo
;
if
(
className
.
endsWith
(
".class"
))
{
if
(
fileManager
instanceof
StandardJavaFileManager
)
{
StandardJavaFileManager
sfm
=
(
StandardJavaFileManager
)
fileManager
;
fo
=
sfm
.
getJavaFileObjects
(
className
).
iterator
().
next
();
}
else
{
reportError
(
"err.not.standard.file.manager"
,
className
);
return
false
;
}
}
else
{
fo
=
getClassFileObject
(
className
);
if
(
fo
==
null
)
{
// see if it is an inner class, by replacing dots to $, starting from the right
String
cn
=
className
;
int
lastDot
;
while
(
fo
==
null
&&
(
lastDot
=
cn
.
lastIndexOf
(
"."
))
!=
-
1
)
{
cn
=
cn
.
substring
(
0
,
lastDot
)
+
"$"
+
cn
.
substring
(
lastDot
+
1
);
fo
=
getClassFileObject
(
cn
);
}
}
if
(
fo
==
null
)
{
reportError
(
"err.class.not.found"
,
className
);
return
false
;
}
}
ClassFileInfo
cfInfo
=
read
(
fo
);
if
(!
className
.
endsWith
(
".class"
))
{
String
cfName
=
cfInfo
.
cf
.
getName
();
if
(!
cfName
.
replaceAll
(
"[/$]"
,
"."
).
equals
(
className
.
replaceAll
(
"[/$]"
,
"."
)))
reportWarning
(
"warn.unexpected.class"
,
className
,
cfName
.
replace
(
'/'
,
'.'
));
}
write
(
cfInfo
);
if
(
options
.
showInnerClasses
)
{
ClassFile
cf
=
cfInfo
.
cf
;
Attribute
a
=
cf
.
getAttribute
(
Attribute
.
InnerClasses
);
if
(
a
instanceof
InnerClasses_attribute
)
{
InnerClasses_attribute
inners
=
(
InnerClasses_attribute
)
a
;
try
{
boolean
ok
=
true
;
for
(
int
i
=
0
;
i
<
inners
.
classes
.
length
;
i
++)
{
int
outerIndex
=
inners
.
classes
[
i
].
outer_class_info_index
;
ConstantPool
.
CONSTANT_Class_info
outerClassInfo
=
cf
.
constant_pool
.
getClassInfo
(
outerIndex
);
String
outerClassName
=
outerClassInfo
.
getName
();
if
(
outerClassName
.
equals
(
cf
.
getName
()))
{
int
innerIndex
=
inners
.
classes
[
i
].
inner_class_info_index
;
ConstantPool
.
CONSTANT_Class_info
innerClassInfo
=
cf
.
constant_pool
.
getClassInfo
(
innerIndex
);
String
innerClassName
=
innerClassInfo
.
getName
();
classWriter
.
println
(
"// inner class "
+
innerClassName
.
replaceAll
(
"[/$]"
,
"."
));
classWriter
.
println
();
ok
=
ok
&
writeClass
(
classWriter
,
innerClassName
);
}
}
return
ok
;
}
catch
(
ConstantPoolException
e
)
{
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
return
false
;
}
}
else
if
(
a
!=
null
)
{
reportError
(
"err.bad.innerclasses.attribute"
,
className
);
return
false
;
}
}
return
true
;
}
public
static
class
ClassFileInfo
{
public
static
class
ClassFileInfo
{
ClassFileInfo
(
JavaFileObject
fo
,
ClassFile
cf
,
byte
[]
digest
,
int
size
)
{
ClassFileInfo
(
JavaFileObject
fo
,
ClassFile
cf
,
byte
[]
digest
,
int
size
)
{
this
.
fo
=
fo
;
this
.
fo
=
fo
;
...
@@ -801,6 +846,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
...
@@ -801,6 +846,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
return
JavapTask
.
this
.
getMessage
(
locale
,
key
,
args
);
return
JavapTask
.
this
.
getMessage
(
locale
,
key
,
args
);
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getClass
().
getName
()
+
"[key="
+
key
+
",args="
+
Arrays
.
asList
(
args
)
+
"]"
;
return
getClass
().
getName
()
+
"[key="
+
key
+
",args="
+
Arrays
.
asList
(
args
)
+
"]"
;
}
}
...
...
src/share/classes/com/sun/tools/javap/Options.java
浏览文件 @
547ea756
...
@@ -85,6 +85,7 @@ public class Options {
...
@@ -85,6 +85,7 @@ public class Options {
public
boolean
showAllAttrs
;
public
boolean
showAllAttrs
;
public
boolean
showConstants
;
public
boolean
showConstants
;
public
boolean
sysInfo
;
public
boolean
sysInfo
;
public
boolean
showInnerClasses
;
public
boolean
compat
;
// bug-for-bug compatibility mode with old javap
public
boolean
compat
;
// bug-for-bug compatibility mode with old javap
public
boolean
jsr277
;
public
boolean
jsr277
;
...
...
src/share/classes/com/sun/tools/javap/resources/javap.properties
浏览文件 @
547ea756
...
@@ -18,6 +18,7 @@ err.unknown.option=unknown option: {0}
...
@@ -18,6 +18,7 @@ err.unknown.option=unknown option: {0}
err.verify.not.supported
=
-verify not supported
err.verify.not.supported
=
-verify not supported
err.no.SourceFile.attribute
=
no SourceFile attribute
err.no.SourceFile.attribute
=
no SourceFile attribute
err.source.file.not.found
=
source file not found
err.source.file.not.found
=
source file not found
err.bad.innerclasses.attribute
=
bad InnerClasses attribute for {0}
warn.Xold.not.supported
=
-Xold is no longer available
warn.Xold.not.supported
=
-Xold is no longer available
main.usage.summary
=
\
main.usage.summary
=
\
...
...
test/tools/javap/T4880672.java
0 → 100644
浏览文件 @
547ea756
/*
* Copyright 2009 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.
*/
/*
* @test
* @bug 4880672
* @summary javap does not output inner interfaces of an interface
*/
import
java.io.*
;
import
java.util.*
;
public
class
T4880672
{
public
static
void
main
(
String
...
args
)
{
new
T4880672
().
run
();
}
void
run
()
{
verify
(
"java.util.Map"
,
"public interface java.util.Map$Entry"
);
verify
(
"T4880672"
,
"class T4880672$A$B extends java.lang.Object"
);
verify
(
"C"
,
""
);
// must not give error if no InnerClasses attribute
if
(
errors
>
0
)
throw
new
Error
(
errors
+
" found."
);
}
void
verify
(
String
className
,
String
...
expects
)
{
String
output
=
javap
(
className
);
for
(
String
expect:
expects
)
{
if
(
output
.
indexOf
(
expect
)<
0
)
error
(
expect
+
" not found"
);
}
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
msg
);
errors
++;
}
int
errors
;
String
javap
(
String
className
)
{
String
testClasses
=
System
.
getProperty
(
"test.classes"
,
"."
);
StringWriter
sw
=
new
StringWriter
();
PrintWriter
out
=
new
PrintWriter
(
sw
);
String
[]
args
=
{
"-XDinner"
,
"-classpath"
,
testClasses
,
className
};
int
rc
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
args
,
out
);
out
.
close
();
String
output
=
sw
.
toString
();
System
.
out
.
println
(
"class "
+
className
);
System
.
out
.
println
(
output
);
if
(
rc
!=
0
)
throw
new
Error
(
"javap failed. rc="
+
rc
);
if
(
output
.
indexOf
(
"Error:"
)
!=
-
1
)
throw
new
Error
(
"javap reported error."
);
return
output
;
}
class
A
{
class
B
{
}
}
}
class
C
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录