Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0335b4e1
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看板
提交
0335b4e1
编写于
11月 11, 2011
作者:
S
smarks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7110700: Enhance exception throwing mechanism in ObjectStreamClass
Reviewed-by: dmeetry, hawtin
上级
684bdd4c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
29 deletion
+44
-29
src/share/classes/java/io/ObjectStreamClass.java
src/share/classes/java/io/ObjectStreamClass.java
+38
-25
test/java/io/Serializable/expectedStackTrace/ExpectedStackTrace.java
...o/Serializable/expectedStackTrace/ExpectedStackTrace.java
+6
-4
未找到文件。
src/share/classes/java/io/ObjectStreamClass.java
浏览文件 @
0335b4e1
...
...
@@ -123,14 +123,39 @@ public class ObjectStreamClass implements Serializable {
*/
private
boolean
hasBlockExternalData
=
true
;
/**
* Contains information about InvalidClassException instances to be thrown
* when attempting operations on an invalid class. Note that instances of
* this class are immutable and are potentially shared among
* ObjectStreamClass instances.
*/
private
static
class
ExceptionInfo
{
private
final
String
className
;
private
final
String
message
;
ExceptionInfo
(
String
cn
,
String
msg
)
{
className
=
cn
;
message
=
msg
;
}
/**
* Returns (does not throw) an InvalidClassException instance created
* from the information in this object, suitable for being thrown by
* the caller.
*/
InvalidClassException
newInvalidClassException
()
{
return
new
InvalidClassException
(
className
,
message
);
}
}
/** exception (if any) thrown while attempting to resolve class */
private
ClassNotFoundException
resolveEx
;
/** exception (if any) to throw if non-enum deserialization attempted */
private
InvalidClassException
deserializeEx
;
private
ExceptionInfo
deserializeEx
;
/** exception (if any) to throw if non-enum serialization attempted */
private
InvalidClassException
serializeEx
;
private
ExceptionInfo
serializeEx
;
/** exception (if any) to throw if default serialization attempted */
private
InvalidClassException
defaultSerializeEx
;
private
ExceptionInfo
defaultSerializeEx
;
/** serializable fields */
private
ObjectStreamField
[]
fields
;
...
...
@@ -444,7 +469,8 @@ public class ObjectStreamClass implements Serializable {
fields
=
getSerialFields
(
cl
);
computeFieldOffsets
();
}
catch
(
InvalidClassException
e
)
{
serializeEx
=
deserializeEx
=
e
;
serializeEx
=
deserializeEx
=
new
ExceptionInfo
(
e
.
classname
,
e
.
getMessage
());
fields
=
NO_FIELDS
;
}
...
...
@@ -483,15 +509,14 @@ public class ObjectStreamClass implements Serializable {
if
(
deserializeEx
==
null
)
{
if
(
isEnum
)
{
deserializeEx
=
new
InvalidClassException
(
name
,
"enum type"
);
deserializeEx
=
new
ExceptionInfo
(
name
,
"enum type"
);
}
else
if
(
cons
==
null
)
{
deserializeEx
=
new
InvalidClassException
(
name
,
"no valid constructor"
);
deserializeEx
=
new
ExceptionInfo
(
name
,
"no valid constructor"
);
}
}
for
(
int
i
=
0
;
i
<
fields
.
length
;
i
++)
{
if
(
fields
[
i
].
getField
()
==
null
)
{
defaultSerializeEx
=
new
InvalidClassException
(
defaultSerializeEx
=
new
ExceptionInfo
(
name
,
"unmatched serializable field(s) declared"
);
}
}
...
...
@@ -601,8 +626,8 @@ public class ObjectStreamClass implements Serializable {
(
externalizable
!=
localDesc
.
externalizable
)
||
!(
serializable
||
externalizable
))
{
deserializeEx
=
new
InvalidClassException
(
localDesc
.
name
,
"class invalid for deserialization"
);
deserializeEx
=
new
ExceptionInfo
(
localDesc
.
name
,
"class invalid for deserialization"
);
}
}
...
...
@@ -727,11 +752,7 @@ public class ObjectStreamClass implements Serializable {
*/
void
checkDeserialize
()
throws
InvalidClassException
{
if
(
deserializeEx
!=
null
)
{
InvalidClassException
ice
=
new
InvalidClassException
(
deserializeEx
.
classname
,
deserializeEx
.
getMessage
());
ice
.
initCause
(
deserializeEx
);
throw
ice
;
throw
deserializeEx
.
newInvalidClassException
();
}
}
...
...
@@ -742,11 +763,7 @@ public class ObjectStreamClass implements Serializable {
*/
void
checkSerialize
()
throws
InvalidClassException
{
if
(
serializeEx
!=
null
)
{
InvalidClassException
ice
=
new
InvalidClassException
(
serializeEx
.
classname
,
serializeEx
.
getMessage
());
ice
.
initCause
(
serializeEx
);
throw
ice
;
throw
serializeEx
.
newInvalidClassException
();
}
}
...
...
@@ -759,11 +776,7 @@ public class ObjectStreamClass implements Serializable {
*/
void
checkDefaultSerialize
()
throws
InvalidClassException
{
if
(
defaultSerializeEx
!=
null
)
{
InvalidClassException
ice
=
new
InvalidClassException
(
defaultSerializeEx
.
classname
,
defaultSerializeEx
.
getMessage
());
ice
.
initCause
(
defaultSerializeEx
);
throw
ice
;
throw
defaultSerializeEx
.
newInvalidClassException
();
}
}
...
...
test/java/io/Serializable/expectedStackTrace/ExpectedStackTrace.java
浏览文件 @
0335b4e1
...
...
@@ -22,7 +22,7 @@
*/
/* @test
* @bug 6317435
* @bug 6317435
7068148
* @summary Verify that stack trace contains a proper cause of
* InvalidClassException (methods: checkSerialize,
* checkDeserialize or checkDefaultSerialize)
...
...
@@ -59,7 +59,7 @@ public class ExpectedStackTrace {
private
static
final
String
SER_METHOD_NAME
=
"checkSerializable"
;
public
static
final
void
main
(
String
[]
args
)
throws
Exception
{
System
.
err
.
println
(
"\nRegression test for CR
6317435
"
);
System
.
err
.
println
(
"\nRegression test for CR
s 6317435, 7068148
"
);
checkSerializable
(
getObject
());
}
...
...
@@ -99,9 +99,11 @@ public class ExpectedStackTrace {
}
}
if
(
found
)
{
System
.
err
.
println
(
"\nTEST PASSED"
);
if
(
ex
.
getCause
()
!=
null
)
{
throw
new
Error
(
"\nTest for CR 7068148 FAILED"
);
}
}
else
{
throw
new
Error
();
throw
new
Error
(
"\nTest for CR 6317435 FAILED"
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录