Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5e476a0e
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看板
提交
5e476a0e
编写于
10月 14, 2010
作者:
K
ksrini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6746111: Improve pack200 error message
Reviewed-by: jrose
上级
d6986e1a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
7 deletion
+68
-7
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
+2
-2
src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
...share/classes/com/sun/java/util/jar/pack/ClassReader.java
+6
-1
test/tools/pack200/AttributeTests.java
test/tools/pack200/AttributeTests.java
+60
-4
test/tools/pack200/badattr.jar
test/tools/pack200/badattr.jar
+0
-0
未找到文件。
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
浏览文件 @
5e476a0e
...
...
@@ -654,8 +654,8 @@ class Attribute implements Comparable, Constants {
String
layout
;
public
FormatException
(
String
message
,
int
ctype
,
String
name
,
String
layout
)
{
super
(
ATTR_CONTEXT_NAME
[
ctype
]+
"."
+
name
+(
message
==
null
?
""
:
(
": "
+
message
)));
super
(
ATTR_CONTEXT_NAME
[
ctype
]+
" attribute \""
+
name
+
"\""
+
(
message
==
null
?
""
:
(
": "
+
message
)));
this
.
ctype
=
ctype
;
this
.
name
=
name
;
this
.
layout
=
layout
;
...
...
src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
浏览文件 @
5e476a0e
...
...
@@ -30,6 +30,7 @@ import java.util.*;
import
com.sun.java.util.jar.pack.Package.Class
;
import
com.sun.java.util.jar.pack.Package.InnerClass
;
import
com.sun.java.util.jar.pack.ConstantPool.*
;
import
com.sun.tools.classfile.AttributeException
;
/**
* Reader for a class file that is being incorporated into a package.
...
...
@@ -405,7 +406,7 @@ class ClassReader implements Constants {
skip
(
length
,
"unknown "
+
name
+
" attribute in "
+
h
);
continue
;
}
else
{
String
message
=
"
unknown in "
+
h
;
String
message
=
"
is unknown attribute in class "
+
h
;
throw
new
Attribute
.
FormatException
(
message
,
ctype
,
name
,
unknownAttrCommand
);
}
...
...
@@ -434,6 +435,10 @@ class ClassReader implements Constants {
in
.
readFully
(
bytes
);
a
=
a
.
addContent
(
bytes
);
}
if
(
a
.
size
()
==
0
&&
!
a
.
layout
().
isEmpty
())
{
throw
new
ClassFormatException
(
name
+
": attribute length cannot be zero, in "
+
h
);
}
h
.
addAttribute
(
a
);
if
(
verbose
>
2
)
Utils
.
log
.
fine
(
"read "
+
a
);
...
...
test/tools/pack200/AttributeTests.java
浏览文件 @
5e476a0e
...
...
@@ -20,12 +20,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/*
* @test
* @bug 6982312
...
...
@@ -34,12 +33,11 @@ import java.util.List;
* @run main AttributeTests
* @author ksrini
*/
public
class
AttributeTests
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
test6982312
();
test6746111
();
}
/*
* This is an interim test, which ensures pack200 handles JSR-292 related
...
...
@@ -72,4 +70,62 @@ public class AttributeTests {
testJar
.
delete
();
dynJar
.
delete
();
}
/*
* this test checks to see if we get the expected strings for output
*/
static
void
test6746111
()
throws
Exception
{
String
pack200Cmd
=
Utils
.
getPack200Cmd
();
File
badAttrJar
=
new
File
(
"."
,
"badattr.jar"
);
Utils
.
copyFile
(
new
File
(
Utils
.
TEST_SRC_DIR
,
"badattr.jar"
),
badAttrJar
);
File
testJar
=
new
File
(
"."
,
"test.jar"
);
List
<
String
>
cmds
=
new
ArrayList
<
String
>();
cmds
.
add
(
pack200Cmd
);
cmds
.
add
(
"--repack"
);
cmds
.
add
(
"-v"
);
cmds
.
add
(
testJar
.
getAbsolutePath
());
cmds
.
add
(
badAttrJar
.
getAbsolutePath
());
List
<
String
>
output
=
Utils
.
runExec
(
cmds
);
/*
* compare the repacked jar bit-wise, as all the files
* should be transmitted "as-is".
*/
Utils
.
doCompareBitWise
(
badAttrJar
.
getAbsoluteFile
(),
testJar
.
getAbsoluteFile
());
String
[]
expectedStrings
=
{
"WARNING: Passing class file uncompressed due to unrecognized"
+
" attribute: Foo.class"
,
"INFO: com.sun.java.util.jar.pack.Attribute$FormatException: "
+
"class attribute \"XourceFile\": is unknown attribute "
+
"in class Foo"
,
"INFO: com.sun.java.util.jar.pack.ClassReader$ClassFormatException: "
+
"AnnotationDefault: attribute length cannot be zero, in Test.message()"
,
"WARNING: Passing class file uncompressed due to unknown class format: Test.class"
};
List
<
String
>
notfoundList
=
new
ArrayList
<
String
>();
notfoundList
.
addAll
(
Arrays
.
asList
(
expectedStrings
));
// make sure the expected messages are emitted
for
(
String
x
:
output
)
{
findString
(
x
,
notfoundList
,
expectedStrings
);
}
if
(!
notfoundList
.
isEmpty
())
{
System
.
out
.
println
(
"Not found:"
);
for
(
String
x
:
notfoundList
)
{
System
.
out
.
println
(
x
);
}
throw
new
Exception
(
"Test fails: "
+
notfoundList
.
size
()
+
" expected strings not found"
);
}
testJar
.
delete
();
badAttrJar
.
delete
();
}
private
static
void
findString
(
String
outputStr
,
List
<
String
>
notfoundList
,
String
[]
expectedStrings
)
{
for
(
String
y
:
expectedStrings
)
{
if
(
outputStr
.
contains
(
y
))
{
notfoundList
.
remove
(
y
);
return
;
}
}
}
}
test/tools/pack200/badattr.jar
0 → 100644
浏览文件 @
5e476a0e
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录