Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
a9a136bb
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看板
提交
a9a136bb
编写于
8月 04, 2008
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4884240: additional option required for javap
Reviewed-by: ksrini
上级
917a2dc9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
172 addition
and
3 deletion
+172
-3
src/share/classes/com/sun/tools/javap/ClassWriter.java
src/share/classes/com/sun/tools/javap/ClassWriter.java
+51
-0
src/share/classes/com/sun/tools/javap/JavapTask.java
src/share/classes/com/sun/tools/javap/JavapTask.java
+57
-1
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
+3
-2
test/tools/javap/T4884240.java
test/tools/javap/T4884240.java
+56
-0
test/tools/javap/T6622260.java
test/tools/javap/T6622260.java
+4
-0
未找到文件。
src/share/classes/com/sun/tools/javap/ClassWriter.java
浏览文件 @
a9a136bb
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
package
com.sun.tools.javap
;
package
com.sun.tools.javap
;
import
java.net.URI
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -46,6 +47,8 @@ import com.sun.tools.classfile.Signature_attribute;
...
@@ -46,6 +47,8 @@ import com.sun.tools.classfile.Signature_attribute;
import
com.sun.tools.classfile.SourceFile_attribute
;
import
com.sun.tools.classfile.SourceFile_attribute
;
import
com.sun.tools.classfile.Type
;
import
com.sun.tools.classfile.Type
;
import
java.text.DateFormat
;
import
java.util.Date
;
import
static
com
.
sun
.
tools
.
classfile
.
AccessFlags
.*;
import
static
com
.
sun
.
tools
.
classfile
.
AccessFlags
.*;
/*
/*
...
@@ -73,6 +76,23 @@ public class ClassWriter extends BasicWriter {
...
@@ -73,6 +76,23 @@ public class ClassWriter extends BasicWriter {
constantWriter
=
ConstantWriter
.
instance
(
context
);
constantWriter
=
ConstantWriter
.
instance
(
context
);
}
}
void
setDigest
(
String
name
,
byte
[]
digest
)
{
this
.
digestName
=
name
;
this
.
digest
=
digest
;
}
void
setFile
(
URI
uri
)
{
this
.
uri
=
uri
;
}
void
setFileSize
(
int
size
)
{
this
.
size
=
size
;
}
void
setLastModified
(
long
lastModified
)
{
this
.
lastModified
=
lastModified
;
}
ClassFile
getClassFile
()
{
ClassFile
getClassFile
()
{
return
classFile
;
return
classFile
;
}
}
...
@@ -85,6 +105,32 @@ public class ClassWriter extends BasicWriter {
...
@@ -85,6 +105,32 @@ public class ClassWriter extends BasicWriter {
classFile
=
cf
;
classFile
=
cf
;
constant_pool
=
classFile
.
constant_pool
;
constant_pool
=
classFile
.
constant_pool
;
if
((
options
.
sysInfo
||
options
.
verbose
)
&&
!
options
.
compat
)
{
if
(
uri
!=
null
)
{
if
(
uri
.
getScheme
().
equals
(
"file"
))
println
(
"Classfile "
+
uri
.
getPath
());
else
println
(
"Classfile "
+
uri
);
}
if
(
lastModified
!=
-
1
)
{
Date
lm
=
new
Date
(
lastModified
);
DateFormat
df
=
DateFormat
.
getDateInstance
();
if
(
size
>
0
)
{
println
(
"Last modified "
+
df
.
format
(
lm
)
+
"; size "
+
size
+
" bytes"
);
}
else
{
println
(
"Last modified "
+
df
.
format
(
lm
));
}
}
else
if
(
size
>
0
)
{
println
(
"Size "
+
size
+
" bytes"
);
}
if
(
digestName
!=
null
&&
digest
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
byte
b:
digest
)
sb
.
append
(
String
.
format
(
"%02x"
,
b
));
println
(
digestName
+
" checksum "
+
sb
);
}
}
Attribute
sfa
=
cf
.
getAttribute
(
Attribute
.
SourceFile
);
Attribute
sfa
=
cf
.
getAttribute
(
Attribute
.
SourceFile
);
if
(
sfa
instanceof
SourceFile_attribute
)
{
if
(
sfa
instanceof
SourceFile_attribute
)
{
println
(
"Compiled from \""
+
getSourceFile
((
SourceFile_attribute
)
sfa
)
+
"\""
);
println
(
"Compiled from \""
+
getSourceFile
((
SourceFile_attribute
)
sfa
)
+
"\""
);
...
@@ -570,6 +616,11 @@ public class ClassWriter extends BasicWriter {
...
@@ -570,6 +616,11 @@ public class ClassWriter extends BasicWriter {
private
CodeWriter
codeWriter
;
private
CodeWriter
codeWriter
;
private
ConstantWriter
constantWriter
;
private
ConstantWriter
constantWriter
;
private
ClassFile
classFile
;
private
ClassFile
classFile
;
private
URI
uri
;
private
long
lastModified
;
private
String
digestName
;
private
byte
[]
digest
;
private
int
size
;
private
ConstantPool
constant_pool
;
private
ConstantPool
constant_pool
;
private
Method
method
;
private
Method
method
;
private
static
final
String
NEWLINE
=
System
.
getProperty
(
"line.separator"
,
"\n"
);
private
static
final
String
NEWLINE
=
System
.
getProperty
(
"line.separator"
,
"\n"
);
...
...
src/share/classes/com/sun/tools/javap/JavapTask.java
浏览文件 @
a9a136bb
...
@@ -27,11 +27,15 @@ package com.sun.tools.javap;
...
@@ -27,11 +27,15 @@ package com.sun.tools.javap;
import
java.io.EOFException
;
import
java.io.EOFException
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FilterInputStream
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.io.Writer
;
import
java.security.DigestInputStream
;
import
java.security.MessageDigest
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -199,6 +203,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
...
@@ -199,6 +203,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
}
}
},
},
new
Option
(
false
,
"-sysinfo"
)
{
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
{
task
.
options
.
sysInfo
=
true
;
}
},
new
Option
(
false
,
"-Xold"
)
{
new
Option
(
false
,
"-Xold"
)
{
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
throws
BadArgs
{
void
process
(
JavapTask
task
,
String
opt
,
String
arg
)
throws
BadArgs
{
// -Xold is only supported as first arg when invoked from
// -Xold is only supported as first arg when invoked from
...
@@ -494,8 +504,27 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
...
@@ -494,8 +504,27 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
Attribute
.
Factory
attributeFactory
=
new
Attribute
.
Factory
();
Attribute
.
Factory
attributeFactory
=
new
Attribute
.
Factory
();
attributeFactory
.
setCompat
(
options
.
compat
);
attributeFactory
.
setCompat
(
options
.
compat
);
attributeFactory
.
setJSR277
(
options
.
jsr277
);
attributeFactory
.
setJSR277
(
options
.
jsr277
);
ClassFile
cf
=
ClassFile
.
read
(
fo
.
openInputStream
(),
attributeFactory
);
InputStream
in
=
fo
.
openInputStream
();
SizeInputStream
sizeIn
=
null
;
MessageDigest
md
=
null
;
if
(
options
.
sysInfo
||
options
.
verbose
)
{
md
=
MessageDigest
.
getInstance
(
"MD5"
);
in
=
new
DigestInputStream
(
in
,
md
);
in
=
sizeIn
=
new
SizeInputStream
(
in
);
}
ClassFile
cf
=
ClassFile
.
read
(
in
,
attributeFactory
);
if
(
options
.
sysInfo
||
options
.
verbose
)
{
classWriter
.
setFile
(
fo
.
toUri
());
classWriter
.
setLastModified
(
fo
.
getLastModified
());
classWriter
.
setDigest
(
"MD5"
,
md
.
digest
());
classWriter
.
setFileSize
(
sizeIn
.
size
());
}
classWriter
.
write
(
cf
);
classWriter
.
write
(
cf
);
}
catch
(
ConstantPoolException
e
)
{
}
catch
(
ConstantPoolException
e
)
{
diagnosticListener
.
report
(
createDiagnostic
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
()));
diagnosticListener
.
report
(
createDiagnostic
(
"err.bad.constant.pool"
,
className
,
e
.
getLocalizedMessage
()));
ok
=
false
;
ok
=
false
;
...
@@ -665,4 +694,31 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
...
@@ -665,4 +694,31 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
Map
<
Locale
,
ResourceBundle
>
bundles
;
Map
<
Locale
,
ResourceBundle
>
bundles
;
private
static
final
String
progname
=
"javap"
;
private
static
final
String
progname
=
"javap"
;
private
static
class
SizeInputStream
extends
FilterInputStream
{
SizeInputStream
(
InputStream
in
)
{
super
(
in
);
}
int
size
()
{
return
size
;
}
@Override
public
int
read
(
byte
[]
buf
,
int
offset
,
int
length
)
throws
IOException
{
int
n
=
super
.
read
(
buf
,
offset
,
length
);
if
(
n
>
0
)
size
+=
n
;
return
n
;
}
@Override
public
int
read
()
throws
IOException
{
int
b
=
super
.
read
();
size
+=
1
;
return
b
;
}
private
int
size
;
}
}
}
src/share/classes/com/sun/tools/javap/Options.java
浏览文件 @
a9a136bb
...
@@ -81,6 +81,7 @@ public class Options {
...
@@ -81,6 +81,7 @@ public class Options {
public
boolean
showInternalSignatures
;
public
boolean
showInternalSignatures
;
public
boolean
showAllAttrs
;
public
boolean
showAllAttrs
;
public
boolean
showConstants
;
public
boolean
showConstants
;
public
boolean
sysInfo
;
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
浏览文件 @
a9a136bb
...
@@ -67,5 +67,6 @@ main.opt.constants=\
...
@@ -67,5 +67,6 @@ main.opt.constants=\
\
-constants Show static final constants
\
-constants Show static final constants
main.opt.sysinfo
=
\
\
-sysinfo Show system info (path, size, date, MD5 hash)
\n\
\
of class being processed
test/tools/javap/T4884240.java
0 → 100644
浏览文件 @
a9a136bb
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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-15301 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 4884240
* @summary additional option required for javap
*/
import
java.io.*
;
public
class
T4884240
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
T4884240
().
run
();
}
public
void
run
()
throws
Exception
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
String
[]
args
=
{
"-sysinfo"
,
"java.lang.Object"
};
int
rc
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
args
,
pw
);
if
(
rc
!=
0
)
throw
new
Exception
(
"unexpected return code: "
+
rc
);
pw
.
close
();
String
[]
lines
=
sw
.
toString
().
split
(
"\n"
);
if
(
lines
.
length
<
3
||
!
lines
[
0
].
startsWith
(
"Classfile"
)
||
!
lines
[
1
].
startsWith
(
"Last modified"
)
||
!
lines
[
2
].
startsWith
(
"MD5"
))
{
System
.
out
.
println
(
sw
);
throw
new
Exception
(
"unexpected output"
);
}
}
}
test/tools/javap/T6622260.java
浏览文件 @
a9a136bb
...
@@ -189,6 +189,10 @@ public class T6622260 {
...
@@ -189,6 +189,10 @@ public class T6622260 {
void
verify
(
String
output
)
{
void
verify
(
String
output
)
{
System
.
out
.
println
(
output
);
System
.
out
.
println
(
output
);
if
(
output
.
startsWith
(
"Classfile"
))
{
// make sure to ignore filename
output
=
output
.
substring
(
output
.
indexOf
(
'\n'
));
}
if
(
output
.
indexOf
(
"-"
)
>=
0
)
if
(
output
.
indexOf
(
"-"
)
>=
0
)
throw
new
Error
(
"- found in output"
);
throw
new
Error
(
"- found in output"
);
if
(
output
.
indexOf
(
"FFFFFF"
)
>=
0
)
if
(
output
.
indexOf
(
"FFFFFF"
)
>=
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录