Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
47d4546f
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看板
提交
47d4546f
编写于
6月 18, 2010
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6962045: TEST_BUG: Tests in test/java/io/Serializable leave files open
Reviewed-by: mchung
上级
7ff91a0f
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
371 addition
and
299 deletion
+371
-299
test/ProblemList.txt
test/ProblemList.txt
+0
-81
test/java/io/Serializable/ClassCastExceptionDetail/Read.java
test/java/io/Serializable/ClassCastExceptionDetail/Read.java
+4
-2
test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java
...Serializable/auditStreamSubclass/AuditStreamSubclass.java
+2
-0
test/java/io/Serializable/backRefCNFException/Read.java
test/java/io/Serializable/backRefCNFException/Read.java
+9
-5
test/java/io/Serializable/checkModifiers/CheckModifiers.java
test/java/io/Serializable/checkModifiers/CheckModifiers.java
+32
-26
test/java/io/Serializable/classDescFlagConflict/Read.java
test/java/io/Serializable/classDescFlagConflict/Read.java
+9
-4
test/java/io/Serializable/classDescHooks/ClassDescHooks.java
test/java/io/Serializable/classDescHooks/ClassDescHooks.java
+15
-6
test/java/io/Serializable/duplicateSerialFields/Test.java
test/java/io/Serializable/duplicateSerialFields/Test.java
+10
-2
test/java/io/Serializable/enum/badResolve/Read.java
test/java/io/Serializable/enum/badResolve/Read.java
+4
-2
test/java/io/Serializable/enum/constantSubclasses/Read.java
test/java/io/Serializable/enum/constantSubclasses/Read.java
+10
-6
test/java/io/Serializable/enum/missingConstant/Read.java
test/java/io/Serializable/enum/missingConstant/Read.java
+16
-12
test/java/io/Serializable/fieldTypeString/Read.java
test/java/io/Serializable/fieldTypeString/Read.java
+17
-10
test/java/io/Serializable/illegalHandle/Test.java
test/java/io/Serializable/illegalHandle/Test.java
+18
-8
test/java/io/Serializable/longString/LongString.java
test/java/io/Serializable/longString/LongString.java
+14
-6
test/java/io/Serializable/oldTests/AnnotateClass.java
test/java/io/Serializable/oldTests/AnnotateClass.java
+34
-27
test/java/io/Serializable/oldTests/ArrayFields.java
test/java/io/Serializable/oldTests/ArrayFields.java
+8
-3
test/java/io/Serializable/oldTests/ArraysOfArrays.java
test/java/io/Serializable/oldTests/ArraysOfArrays.java
+6
-2
test/java/io/Serializable/oldTests/BinaryTree.java
test/java/io/Serializable/oldTests/BinaryTree.java
+24
-18
test/java/io/Serializable/oldTests/CircularList.java
test/java/io/Serializable/oldTests/CircularList.java
+8
-3
test/java/io/Serializable/oldTests/SimpleArrays.java
test/java/io/Serializable/oldTests/SimpleArrays.java
+6
-2
test/java/io/Serializable/oldTests/WritePrimitive.java
test/java/io/Serializable/oldTests/WritePrimitive.java
+6
-2
test/java/io/Serializable/packageAccess/Test.java
test/java/io/Serializable/packageAccess/Test.java
+2
-1
test/java/io/Serializable/parents/EvolvedClass.java
test/java/io/Serializable/parents/EvolvedClass.java
+6
-2
test/java/io/Serializable/parents/OriginalClass.java
test/java/io/Serializable/parents/OriginalClass.java
+7
-3
test/java/io/Serializable/proxy/Basic.java
test/java/io/Serializable/proxy/Basic.java
+1
-1
test/java/io/Serializable/proxy/skipMissing/Read.java
test/java/io/Serializable/proxy/skipMissing/Read.java
+17
-13
test/java/io/Serializable/proxy/skipMissing/Write.java
test/java/io/Serializable/proxy/skipMissing/Write.java
+1
-1
test/java/io/Serializable/readObjectNoData/Read.java
test/java/io/Serializable/readObjectNoData/Read.java
+12
-8
test/java/io/Serializable/skipWriteObject/Read.java
test/java/io/Serializable/skipWriteObject/Read.java
+7
-3
test/java/io/Serializable/skippedObjCNFException/Read.java
test/java/io/Serializable/skippedObjCNFException/Read.java
+7
-3
test/java/io/Serializable/stopCustomDeserialization/Read.java
.../java/io/Serializable/stopCustomDeserialization/Read.java
+13
-9
test/java/io/Serializable/unresolvedClassDesc/Read.java
test/java/io/Serializable/unresolvedClassDesc/Read.java
+14
-10
test/java/io/Serializable/unshared/Read.java
test/java/io/Serializable/unshared/Read.java
+19
-9
test/java/io/Serializable/wrongReturnTypes/Read.java
test/java/io/Serializable/wrongReturnTypes/Read.java
+13
-9
未找到文件。
test/ProblemList.txt
浏览文件 @
47d4546f
...
...
@@ -196,80 +196,6 @@ java/beans/XMLEncoder/6329581/Test6329581.java generic-all
java/io/BufferedReader/BigMark.java generic-all
java/io/BufferedReader/ReadLineSync.java generic-all
# One of these is leaving "a.ser" file open, windows samevm
java/io/Serializable/duplicateSerialFields/Setup.java generic-all
java/io/Serializable/duplicateSerialFields/Test.java generic-all
# One of these leaving foo.ser open, windows samevm problem
java/io/Serializable/enum/constantSubclasses/Read.java generic-all
java/io/Serializable/enum/constantSubclasses/Write.java generic-all
java/io/Serializable/enum/missingConstant/Read.java generic-all
java/io/Serializable/enum/missingConstant/Write.java generic-all
# This is leaving subtest1.tmp open, windows samevm problem
java/io/Serializable/oldTests/AnnotateClass.java generic-all
# One or more of these leave a piotest* file open, windows samevm
java/io/Serializable/oldTests/ArrayFields.java generic-all
java/io/Serializable/oldTests/ArraysOfArrays.java generic-all
java/io/Serializable/oldTests/BinaryTree.java generic-all
java/io/Serializable/oldTests/CircularList.java generic-all
java/io/Serializable/oldTests/SerializeWithException.java generic-all
java/io/Serializable/oldTests/SimpleArrays.java generic-all
java/io/Serializable/oldTests/WritePrimitive.java generic-all
# Missing close on file 0.ser, windows samevm
java/io/Serializable/enum/badResolve/Read.java generic-all
java/io/Serializable/enum/badResolve/Write.java generic-all
# One of these tests is leaving parents.ser open, windows samevm
java/io/Serializable/parents/EvolvedClass.java generic-all
java/io/Serializable/parents/OriginalClass.java generic-all
# One of these tests is leaving file foo.ser and/or bar.ser open, windows samevm
java/io/Serializable/fieldTypeString/Read.java generic-all
java/io/Serializable/fieldTypeString/Write.java generic-all
# One of these tests is leaving tmp.ser file open, windows samevm
java/io/Serializable/ClassCastExceptionDetail/Read.java generic-all
java/io/Serializable/ClassCastExceptionDetail/Write.java generic-all
java/io/Serializable/GetField/Read.java generic-all
java/io/Serializable/GetField/Read2.java generic-all
java/io/Serializable/GetField/Write.java generic-all
java/io/Serializable/PutField/Read.java generic-all
java/io/Serializable/PutField/Read2.java generic-all
java/io/Serializable/PutField/Write.java generic-all
java/io/Serializable/PutField/Write2.java generic-all
java/io/Serializable/arraySuidConflict/Read.java generic-all
java/io/Serializable/arraySuidConflict/Write.java generic-all
java/io/Serializable/backRefCNFException/Read.java generic-all
java/io/Serializable/backRefCNFException/Write.java generic-all
java/io/Serializable/class/Test.java generic-all
java/io/Serializable/evolution/AddedExternField/ReadAddedField.java generic-all
java/io/Serializable/evolution/AddedExternField/WriteAddedField.java generic-all
java/io/Serializable/evolution/AddedExternField/run.sh generic-all
java/io/Serializable/evolution/AddedField/ReadAddedField.java generic-all
java/io/Serializable/evolution/AddedField/WriteAddedField.java generic-all
java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass.java generic-all
java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass2.java generic-all
java/io/Serializable/evolution/AddedSuperClass/WriteAddedSuperClass.java generic-all
java/io/Serializable/proxy/skipMissing/Read.java generic-all
java/io/Serializable/proxy/skipMissing/Write.java generic-all
java/io/Serializable/readObjectNoData/Read.java generic-all
java/io/Serializable/readObjectNoData/Write.java generic-all
java/io/Serializable/skipWriteObject/Read.java generic-all
java/io/Serializable/skipWriteObject/Write.java generic-all
java/io/Serializable/skippedObjCNFException/Read.java generic-all
java/io/Serializable/skippedObjCNFException/Write.java generic-all
java/io/Serializable/stopCustomDeserialization/Read.java generic-all
java/io/Serializable/stopCustomDeserialization/Write.java generic-all
java/io/Serializable/unresolvedClassDesc/Read.java generic-all
java/io/Serializable/unresolvedClassDesc/Write.java generic-all
java/io/Serializable/unshared/Read.java generic-all
java/io/Serializable/unshared/Write.java generic-all
java/io/Serializable/wrongReturnTypes/Read.java generic-all
java/io/Serializable/wrongReturnTypes/Write.java generic-all
# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
java/io/DataInputStream/OpsAfterClose.java generic-all
...
...
@@ -323,13 +249,6 @@ java/io/RandomAccessFile/skipBytes/SkipBytes.java generic-all
java/io/readBytes/MemoryLeak.java generic-all
java/io/readBytes/ReadBytesBounds.java generic-all
# Missing close on fields.ser, windows samevm
java/io/Serializable/checkModifiers/CheckModifiers.java generic-all
# Should be othervm, or corrected for samevm, fails with samevm:
java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java generic-all
java/io/Serializable/proxy/Basic.java generic-all
# Possibly not doing a close() on input.txt, windows samevm issues.
java/io/StreamTokenizer/Comment.java generic-all
...
...
test/java/io/Serializable/ClassCastExceptionDetail/Read.java
浏览文件 @
47d4546f
...
...
@@ -40,9 +40,9 @@ class Gub extends Foo {}
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"readObject should not succeed"
);
}
catch
(
ClassCastException
e
)
{
...
...
@@ -57,6 +57,8 @@ public class Read {
{
throw
new
Error
(
"ClassNotFoundException message incomplete"
);
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java
浏览文件 @
47d4546f
...
...
@@ -26,6 +26,8 @@
* @summary Verify that unauthorized ObjectOutputStream and ObjectInputStream
* cannot be constructed if they override security-sensitive non-final
* methods.
* @build AuditStreamSubclass
* @run main/othervm AuditStreamSubclass
*/
import
java.io.*
;
...
...
test/java/io/Serializable/backRefCNFException/Read.java
浏览文件 @
47d4546f
...
...
@@ -38,13 +38,17 @@ class A implements Serializable {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
oin
.
readObject
();
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"back reference read succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
try
{
oin
.
readObject
();
throw
new
Error
(
"back reference read succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/checkModifiers/CheckModifiers.java
浏览文件 @
47d4546f
...
...
@@ -213,33 +213,39 @@ public class CheckModifiers {
FileOutputStream
fos
=
new
FileOutputStream
(
"fields.ser"
);
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
fos
);
System
.
out
.
println
(
"Writing obj 1"
);
oos
.
writeObject
(
tc1
);
System
.
out
.
println
(
"Writing obj 2"
);
oos
.
writeObject
(
tc2
);
System
.
out
.
println
(
"Writing obj 3"
);
oos
.
writeObject
(
tc3
);
System
.
out
.
println
(
"Writing obj 4"
);
oos
.
writeObject
(
tc4
);
try
{
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
fos
);
System
.
out
.
println
(
"Writing obj 1"
);
oos
.
writeObject
(
tc1
);
System
.
out
.
println
(
"Writing obj 2"
);
oos
.
writeObject
(
tc2
);
System
.
out
.
println
(
"Writing obj 3"
);
oos
.
writeObject
(
tc3
);
System
.
out
.
println
(
"Writing obj 4"
);
oos
.
writeObject
(
tc4
);
oos
.
flush
();
}
finally
{
fos
.
close
();
}
FileInputStream
fis
=
new
FileInputStream
(
"fields.ser"
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
fis
);
System
.
out
.
println
(
"Test modifiers for serialPeristentFields "
);
System
.
out
.
println
(
"---------------------------------------- "
);
System
.
out
.
println
(
"Declaration missing final modifier"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration with public instead of private access"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration with different type"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration as in specification"
);
ois
.
readObject
();
try
{
ObjectInputStream
ois
=
new
ObjectInputStream
(
fis
);
System
.
out
.
println
(
"Test modifiers for serialPeristentFields "
);
System
.
out
.
println
(
"---------------------------------------- "
);
System
.
out
.
println
(
"Declaration missing final modifier"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration with public instead of private access"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration with different type"
);
ois
.
readObject
();
System
.
out
.
println
();
System
.
out
.
println
(
"Declaration as in specification"
);
ois
.
readObject
();
}
finally
{
fis
.
close
();
}
}
};
test/java/io/Serializable/classDescFlagConflict/Read.java
浏览文件 @
47d4546f
...
...
@@ -42,10 +42,15 @@ public class Read {
* descriptor.
*/
File
f
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Foo.ser"
);
new
ObjectInputStream
(
new
FileInputStream
(
f
)).
readObject
();
throw
new
Error
(
"read succeeded for object whose class descriptor has "
+
"both SC_SERIALIZABLE and SC_EXTERNALIZABLE flags set"
);
FileInputStream
in
=
new
FileInputStream
(
f
);
try
{
new
ObjectInputStream
(
in
).
readObject
();
throw
new
Error
(
"read succeeded for object whose class descriptor has "
+
"both SC_SERIALIZABLE and SC_EXTERNALIZABLE flags set"
);
}
finally
{
in
.
close
();
}
}
catch
(
InvalidClassException
e
)
{
}
}
...
...
test/java/io/Serializable/classDescHooks/ClassDescHooks.java
浏览文件 @
47d4546f
...
...
@@ -93,8 +93,12 @@ public class ClassDescHooks implements ObjectStreamConstants {
bout
=
new
ByteArrayOutputStream
();
foof
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Foo.ser"
);
fin
=
new
FileInputStream
(
foof
);
while
(
fin
.
available
()
>
0
)
bout
.
write
(
fin
.
read
());
try
{
while
(
fin
.
available
()
>
0
)
bout
.
write
(
fin
.
read
());
}
finally
{
fin
.
close
();
}
byte
[]
buf1
=
bout
.
toByteArray
();
bout
=
new
ByteArrayOutputStream
();
...
...
@@ -107,11 +111,16 @@ public class ClassDescHooks implements ObjectStreamConstants {
if
(!
Arrays
.
equals
(
buf1
,
buf2
))
throw
new
Error
(
"Incompatible stream format (write)"
);
Foo
foocopy
;
fin
=
new
FileInputStream
(
foof
);
oin
=
new
ObjectInputStream
(
fin
);
Foo
foocopy
=
(
Foo
)
oin
.
readObject
();
if
(!
foo
.
equals
(
foocopy
))
throw
new
Error
(
"Incompatible stream format (read)"
);
try
{
oin
=
new
ObjectInputStream
(
fin
);
foocopy
=
(
Foo
)
oin
.
readObject
();
if
(!
foo
.
equals
(
foocopy
))
throw
new
Error
(
"Incompatible stream format (read)"
);
}
finally
{
fin
.
close
();
}
// make sure write hook not called when old protocol in use
bout
=
new
ByteArrayOutputStream
();
...
...
test/java/io/Serializable/duplicateSerialFields/Test.java
浏览文件 @
47d4546f
...
...
@@ -82,18 +82,26 @@ public class Test {
}
catch
(
InvalidClassException
e
)
{
}
FileInputStream
in
=
new
FileInputStream
(
"a.ser"
);
try
{
new
ObjectInputStream
(
new
FileInputStream
(
"a.ser"
)).
readObject
();
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"read of A should fail with InvalidClassException"
);
}
catch
(
InvalidClassException
e
)
{
}
finally
{
in
.
close
();
}
in
=
new
FileInputStream
(
"b.ser"
);
try
{
new
ObjectInputStream
(
new
FileInputStream
(
"b.ser"
)).
readObject
();
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"read of B should fail with InvalidClassException"
);
}
catch
(
InvalidClassException
e
)
{
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/enum/badResolve/Read.java
浏览文件 @
47d4546f
...
...
@@ -44,13 +44,15 @@ public class Read {
}
static
void
read
(
String
filename
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
filename
));
FileInputStream
in
=
new
FileInputStream
(
filename
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
Object
obj
=
oin
.
readObject
();
throw
new
Error
(
"read of "
+
obj
+
" should not have succeeded"
);
}
catch
(
InvalidClassException
e
)
{
System
.
out
.
println
(
"caught expected exception "
+
e
);
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/enum/constantSubclasses/Read.java
浏览文件 @
47d4546f
...
...
@@ -38,13 +38,17 @@ enum Foo {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"foo.ser"
));
for
(
Foo
f
:
Foo
.
values
())
{
Object
obj
=
oin
.
readObject
();
if
(
obj
!=
f
)
{
throw
new
Error
(
"expected "
+
f
+
", got "
+
obj
);
FileInputStream
in
=
new
FileInputStream
(
"foo.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
for
(
Foo
f
:
Foo
.
values
())
{
Object
obj
=
oin
.
readObject
();
if
(
obj
!=
f
)
{
throw
new
Error
(
"expected "
+
f
+
", got "
+
obj
);
}
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/enum/missingConstant/Read.java
浏览文件 @
47d4546f
...
...
@@ -33,19 +33,23 @@ enum Foo { foo, bar }
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"foo.ser"
));
for
(
Foo
f
:
Foo
.
values
())
{
Object
obj
=
oin
.
readObject
();
if
(
obj
!=
f
)
{
throw
new
Error
(
"expected "
+
f
+
", got "
+
obj
);
}
}
FileInputStream
in
=
new
FileInputStream
(
"foo.ser"
);
try
{
Object
obj
=
oin
.
readObject
();
throw
new
Error
(
"read of "
+
obj
+
" should not succeed"
);
}
catch
(
InvalidObjectException
e
)
{
System
.
out
.
println
(
"caught expected exception: "
+
e
);
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
for
(
Foo
f
:
Foo
.
values
())
{
Object
obj
=
oin
.
readObject
();
if
(
obj
!=
f
)
{
throw
new
Error
(
"expected "
+
f
+
", got "
+
obj
);
}
}
try
{
Object
obj
=
oin
.
readObject
();
throw
new
Error
(
"read of "
+
obj
+
" should not succeed"
);
}
catch
(
InvalidObjectException
e
)
{
System
.
out
.
println
(
"caught expected exception: "
+
e
);
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/fieldTypeString/Read.java
浏览文件 @
47d4546f
...
...
@@ -44,23 +44,30 @@ class Bar implements Serializable {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"foo.ser"
));
Foo
foo
=
(
Foo
)
oin
.
readObject
();
if
(!
foo
.
obj
.
equals
(
"foo"
))
{
throw
new
Error
();
}
FileInputStream
in
=
new
FileInputStream
(
"foo.ser"
);
try
{
oin
.
readObject
();
throw
new
Error
();
}
catch
(
ClassCastException
ex
)
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
Foo
foo
=
(
Foo
)
oin
.
readObject
();
if
(!
foo
.
obj
.
equals
(
"foo"
))
{
throw
new
Error
();
}
try
{
oin
.
readObject
();
throw
new
Error
();
}
catch
(
ClassCastException
ex
)
{
}
}
finally
{
in
.
close
();
}
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"bar.ser"
)
);
in
=
new
FileInputStream
(
"bar.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
();
}
catch
(
InvalidClassException
ex
)
{
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/illegalHandle/Test.java
浏览文件 @
47d4546f
...
...
@@ -38,21 +38,31 @@ public class Test {
* serialized String object followed by an illegal handle
*/
File
f
=
new
File
(
base
,
"negativeHandle.ser"
);
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
f
));
oin
.
readObject
();
FileInputStream
in
=
new
FileInputStream
(
f
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"negative handle read should not succeed"
);
}
catch
(
StreamCorruptedException
ex
)
{
try
{
oin
.
readObject
();
throw
new
Error
(
"negative handle read should not succeed"
);
}
catch
(
StreamCorruptedException
ex
)
{
}
}
finally
{
in
.
close
();
}
f
=
new
File
(
base
,
"tooHighHandle.ser"
);
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
f
));
oin
.
readObject
();
in
=
new
FileInputStream
(
f
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"too-high handle read should not succeed"
);
}
catch
(
StreamCorruptedException
ex
)
{
try
{
oin
.
readObject
();
throw
new
Error
(
"too-high handle read should not succeed"
);
}
catch
(
StreamCorruptedException
ex
)
{
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/longString/LongString.java
浏览文件 @
47d4546f
...
...
@@ -68,17 +68,25 @@ public class LongString {
mesgf
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"mesg.ser"
);
fin
=
new
FileInputStream
(
mesgf
);
bout
=
new
ByteArrayOutputStream
();
while
(
fin
.
available
()
>
0
)
bout
.
write
(
fin
.
read
());
try
{
while
(
fin
.
available
()
>
0
)
bout
.
write
(
fin
.
read
());
}
finally
{
fin
.
close
();
}
byte
[]
buf2
=
bout
.
toByteArray
();
if
(!
Arrays
.
equals
(
buf1
,
buf2
))
throw
new
Error
(
"incompatible string format (write)"
);
fin
=
new
FileInputStream
(
mesgf
);
oin
=
new
ObjectInputStream
(
fin
);
String
mesgcopy
=
(
String
)
oin
.
readObject
();
if
(!
mesg
.
equals
(
mesgcopy
))
throw
new
Error
(
"incompatible string format (read)"
);
try
{
oin
=
new
ObjectInputStream
(
fin
);
String
mesgcopy
=
(
String
)
oin
.
readObject
();
if
(!
mesg
.
equals
(
mesgcopy
))
throw
new
Error
(
"incompatible string format (read)"
);
}
finally
{
fin
.
close
();
}
}
}
test/java/io/Serializable/oldTests/AnnotateClass.java
浏览文件 @
47d4546f
...
...
@@ -37,36 +37,43 @@ public class AnnotateClass {
"methods \n"
);
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"subtest1.tmp"
);
TestOutputStream
p
=
new
TestOutputStream
(
ostream
);
p
.
writeObject
(
System
.
out
);
p
.
writeObject
(
System
.
err
);
p
.
writeObject
(
new
PrintStream
(
ostream
));
p
.
flush
();
ostream
.
close
();
try
{
TestOutputStream
p
=
new
TestOutputStream
(
ostream
);
p
.
writeObject
(
System
.
out
);
p
.
writeObject
(
System
.
err
);
p
.
writeObject
(
new
PrintStream
(
ostream
));
p
.
flush
();
}
finally
{
ostream
.
close
();
}
FileInputStream
istream
=
new
FileInputStream
(
"subtest1.tmp"
);
TestInputStream
q
=
new
TestInputStream
(
istream
);
PrintStream
out
=
(
PrintStream
)
q
.
readObject
();
PrintStream
err
=
(
PrintStream
)
q
.
readObject
();
Object
other
=
q
.
readObject
();
if
(
out
!=
System
.
out
)
{
System
.
err
.
println
(
"\nTEST FAILED: System.out not read correctly"
);
throw
new
Error
();
}
if
(
err
!=
System
.
err
)
{
System
.
err
.
println
(
"\nTEST FAILED: System.err not read correctly"
);
throw
new
Error
();
}
if
(
other
!=
null
)
{
System
.
err
.
println
(
"\nTEST FAILED: Non-system PrintStream should have "
+
"been written/read as null"
);
throw
new
Error
();
try
{
TestInputStream
q
=
new
TestInputStream
(
istream
);
PrintStream
out
=
(
PrintStream
)
q
.
readObject
();
PrintStream
err
=
(
PrintStream
)
q
.
readObject
();
Object
other
=
q
.
readObject
();
if
(
out
!=
System
.
out
)
{
System
.
err
.
println
(
"\nTEST FAILED: System.out not read correctly"
);
throw
new
Error
();
}
if
(
err
!=
System
.
err
)
{
System
.
err
.
println
(
"\nTEST FAILED: System.err not read correctly"
);
throw
new
Error
();
}
if
(
other
!=
null
)
{
System
.
err
.
println
(
"\nTEST FAILED: Non-system PrintStream should have "
+
"been written/read as null"
);
throw
new
Error
();
}
}
finally
{
istream
.
close
();
}
System
.
err
.
println
(
"\nTEST PASSED"
);
}
catch
(
Exception
e
)
{
System
.
err
.
print
(
"TEST FAILED: "
);
...
...
test/java/io/Serializable/oldTests/ArrayFields.java
浏览文件 @
47d4546f
...
...
@@ -35,20 +35,22 @@ import java.io.*;
public
class
ArrayFields
{
public
static
void
main
(
String
argv
[])
{
public
static
void
main
(
String
argv
[])
throws
IOException
{
System
.
err
.
println
(
"\nRegression test for testing of "
+
"serialization/deserialization of objects with "
+
"fields of array type\n"
);
FileOutputStream
ostream
=
null
;
FileInputStream
istream
=
null
;
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest4.tmp"
);
ostream
=
new
FileOutputStream
(
"piotest4.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
ArrayTest
array
=
new
ArrayTest
();
p
.
writeObject
(
array
);
p
.
flush
();
FileInputStream
istream
=
new
FileInputStream
(
"piotest4.tmp"
);
istream
=
new
FileInputStream
(
"piotest4.tmp"
);
ObjectInputStream
q
=
new
ObjectInputStream
(
istream
);
Object
obj
=
null
;
...
...
@@ -73,6 +75,9 @@ public class ArrayFields {
System
.
err
.
print
(
"TEST FAILED: "
);
e
.
printStackTrace
();
throw
new
Error
();
}
finally
{
if
(
istream
!=
null
)
istream
.
close
();
if
(
ostream
!=
null
)
ostream
.
close
();
}
}
}
test/java/io/Serializable/oldTests/ArraysOfArrays.java
浏览文件 @
47d4546f
...
...
@@ -31,14 +31,15 @@
import
java.io.*
;
public
class
ArraysOfArrays
{
public
static
void
main
(
String
argv
[])
{
public
static
void
main
(
String
argv
[])
throws
IOException
{
System
.
err
.
println
(
"\nRegression test for testing of "
+
"serialization/deserialization of objects as "
+
"arrays of arrays \n"
);
FileInputStream
istream
=
null
;
FileOutputStream
ostream
=
null
;
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest5.tmp"
);
ostream
=
new
FileOutputStream
(
"piotest5.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
byte
b
[][]
=
{{
0
,
1
},
{
2
,
3
}};
...
...
@@ -207,6 +208,9 @@ public class ArraysOfArrays {
throw
new
Error
();
}
throw
new
Error
();
}
finally
{
if
(
istream
!=
null
)
istream
.
close
();
if
(
ostream
!=
null
)
ostream
.
close
();
}
}
}
test/java/io/Serializable/oldTests/BinaryTree.java
浏览文件 @
47d4546f
...
...
@@ -37,28 +37,34 @@ public class BinaryTree {
"with BinaryTree types \n"
);
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest3.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
BinaryTreeTest
base
=
new
BinaryTreeTest
(
2
);
p
.
writeObject
(
null
);
p
.
writeObject
(
base
);
p
.
flush
();
ostream
.
close
();
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest3.tmp"
);
try
{
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
p
.
writeObject
(
null
);
p
.
writeObject
(
base
);
p
.
flush
();
}
finally
{
ostream
.
close
();
}
FileInputStream
istream
=
new
FileInputStream
(
"piotest3.tmp"
);
ObjectInputStream
q
=
new
ObjectInputStream
(
istream
);
Object
n
=
q
.
readObject
();
if
(
n
!=
null
)
{
System
.
err
.
println
(
"\nnull read as "
+
n
);
}
BinaryTreeTest
nbase
=
(
BinaryTreeTest
)
q
.
readObject
();
if
(!
base
.
equals
(
nbase
))
{
System
.
err
.
println
(
"\nTEST FAILED: BinaryTree read "
+
"incorrectly."
);
throw
new
Error
();
try
{
ObjectInputStream
q
=
new
ObjectInputStream
(
istream
);
Object
n
=
q
.
readObject
();
if
(
n
!=
null
)
{
System
.
err
.
println
(
"\nnull read as "
+
n
);
}
BinaryTreeTest
nbase
=
(
BinaryTreeTest
)
q
.
readObject
();
if
(!
base
.
equals
(
nbase
))
{
System
.
err
.
println
(
"\nTEST FAILED: BinaryTree read "
+
"incorrectly."
);
throw
new
Error
();
}
}
finally
{
istream
.
close
();
}
System
.
err
.
println
(
"\nTEST PASSED"
);
}
catch
(
Exception
e
)
{
System
.
err
.
print
(
"TEST FAILED: "
);
...
...
test/java/io/Serializable/oldTests/CircularList.java
浏览文件 @
47d4546f
...
...
@@ -31,20 +31,22 @@
import
java.io.*
;
public
class
CircularList
{
public
static
void
main
(
String
argv
[])
{
public
static
void
main
(
String
argv
[])
throws
IOException
{
System
.
err
.
println
(
"\nRegression test for testing of "
+
"serialization/deserialization of "
+
"objects with CirculalListType types \n"
);
FileInputStream
istream
=
null
;
FileOutputStream
ostream
=
null
;
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest7.tmp"
);
ostream
=
new
FileOutputStream
(
"piotest7.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
CircularListTest
.
setup
();
p
.
writeObject
(
CircularListTest
.
list
);
p
.
flush
();
FileInputStream
istream
=
new
FileInputStream
(
"piotest7.tmp"
);
istream
=
new
FileInputStream
(
"piotest7.tmp"
);
ObjectInputStream
q
=
new
ObjectInputStream
(
istream
);
CircularListTest
cv
=
(
CircularListTest
)
q
.
readObject
();
...
...
@@ -58,6 +60,9 @@ public class CircularList {
System
.
err
.
print
(
"TEST FAILED: "
);
e
.
printStackTrace
();
throw
new
Error
();
}
finally
{
if
(
istream
!=
null
)
istream
.
close
();
if
(
ostream
!=
null
)
ostream
.
close
();
}
}
}
...
...
test/java/io/Serializable/oldTests/SimpleArrays.java
浏览文件 @
47d4546f
...
...
@@ -35,13 +35,14 @@ import java.io.*;
public
class
SimpleArrays
{
public
static
void
main
(
String
argv
[])
{
public
static
void
main
(
String
argv
[])
throws
IOException
{
System
.
err
.
println
(
"\nRegression test for testing of "
+
"serialization/deserialization of objects with Arrays types\n"
);
FileInputStream
istream
=
null
;
FileOutputStream
ostream
=
null
;
try
{
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest2.tmp"
);
ostream
=
new
FileOutputStream
(
"piotest2.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
byte
b
[]
=
{
0
,
1
};
...
...
@@ -177,6 +178,9 @@ public class SimpleArrays {
throw
new
Error
();
}
throw
new
Error
();
}
finally
{
if
(
istream
!=
null
)
istream
.
close
();
if
(
ostream
!=
null
)
ostream
.
close
();
}
}
}
test/java/io/Serializable/oldTests/WritePrimitive.java
浏览文件 @
47d4546f
...
...
@@ -34,11 +34,12 @@
import
java.io.*
;
public
class
WritePrimitive
{
public
static
void
main
(
String
argv
[])
{
public
static
void
main
(
String
argv
[])
throws
IOException
{
System
.
err
.
println
(
"\nRegression test for testing of "
+
"serialization/deserialization of primitives \n"
);
FileInputStream
istream
=
null
;
FileOutputStream
ostream
=
null
;
try
{
int
i
=
123456
;
byte
b
=
12
;
...
...
@@ -51,7 +52,7 @@ public class WritePrimitive {
String
string
=
"The String"
;
PrimitivesTest
prim
=
new
PrimitivesTest
();
FileOutputStream
ostream
=
new
FileOutputStream
(
"piotest1.tmp"
);
ostream
=
new
FileOutputStream
(
"piotest1.tmp"
);
ObjectOutputStream
p
=
new
ObjectOutputStream
(
ostream
);
p
.
writeInt
(
i
);
...
...
@@ -154,6 +155,9 @@ public class WritePrimitive {
throw
new
Error
();
}
throw
new
Error
();
}
finally
{
if
(
istream
!=
null
)
istream
.
close
();
if
(
ostream
!=
null
)
ostream
.
close
();
}
}
}
test/java/io/Serializable/packageAccess/Test.java
浏览文件 @
47d4546f
...
...
@@ -38,7 +38,8 @@ public class Test {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ClassLoader
ldr
=
new
URLClassLoader
(
new
URL
[]{
new
URL
(
"file:foo.jar"
)
});
new
URLClassLoader
(
new
URL
[]{
new
URL
(
"file:foo.jar"
)
},
Test
.
class
.
getClassLoader
());
bcl
=
Class
.
forName
(
"B"
,
true
,
ldr
);
dcl
=
Class
.
forName
(
"D"
,
true
,
ldr
);
...
...
test/java/io/Serializable/parents/EvolvedClass.java
浏览文件 @
47d4546f
...
...
@@ -34,8 +34,12 @@ public class EvolvedClass {
// Deserialize in to new class object
FileInputStream
fi
=
new
FileInputStream
(
"parents.ser"
);
ObjectInputStream
si
=
new
ObjectInputStream
(
fi
);
cnew
=
(
ASubClass
)
si
.
readObject
();
try
{
ObjectInputStream
si
=
new
ObjectInputStream
(
fi
);
cnew
=
(
ASubClass
)
si
.
readObject
();
}
finally
{
fi
.
close
();
}
System
.
out
.
println
(
"Printing the deserialized class: "
);
System
.
out
.
println
();
...
...
test/java/io/Serializable/parents/OriginalClass.java
浏览文件 @
47d4546f
...
...
@@ -43,9 +43,13 @@ public class OriginalClass {
// Serialize the subclass
FileOutputStream
fo
=
new
FileOutputStream
(
"parents.ser"
);
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
);
so
.
writeObject
(
corg
);
so
.
flush
();
try
{
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
);
so
.
writeObject
(
corg
);
so
.
flush
();
}
finally
{
fo
.
close
();
}
System
.
out
.
println
(
"Printing the serialized class: "
);
System
.
out
.
println
();
...
...
test/java/io/Serializable/proxy/Basic.java
浏览文件 @
47d4546f
...
...
@@ -81,7 +81,7 @@ class ProxyBlindInputStream extends ObjectInputStream {
public
class
Basic
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ClassLoader
loader
=
ClassLoader
.
getSystem
ClassLoader
();
ClassLoader
loader
=
Basic
.
class
.
get
ClassLoader
();
Class
[]
interfaces
=
new
Class
[]
{
Foo
.
class
,
Bar
.
class
};
Random
rand
=
new
Random
();
int
foo
=
rand
.
nextInt
();
...
...
test/java/io/Serializable/proxy/skipMissing/Read.java
浏览文件 @
47d4546f
...
...
@@ -49,20 +49,24 @@ class B implements Serializable {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
A
a
=
(
A
)
oin
.
readObject
();
if
(!
(
a
.
a
.
equals
(
"a"
)
&&
a
.
z
.
equals
(
"z"
)))
{
throw
new
Error
(
"A fields corrupted"
);
}
B
b
=
(
B
)
oin
.
readObject
();
if
(!
b
.
s
.
equals
(
"s"
))
{
throw
new
Error
(
"B fields corrupted"
);
}
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
oin
.
readObject
();
throw
new
Error
(
"proxy read should not succeed"
);
}
catch
(
ClassNotFoundException
ex
)
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
A
a
=
(
A
)
oin
.
readObject
();
if
(!
(
a
.
a
.
equals
(
"a"
)
&&
a
.
z
.
equals
(
"z"
)))
{
throw
new
Error
(
"A fields corrupted"
);
}
B
b
=
(
B
)
oin
.
readObject
();
if
(!
b
.
s
.
equals
(
"s"
))
{
throw
new
Error
(
"B fields corrupted"
);
}
try
{
oin
.
readObject
();
throw
new
Error
(
"proxy read should not succeed"
);
}
catch
(
ClassNotFoundException
ex
)
{
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/proxy/skipMissing/Write.java
浏览文件 @
47d4546f
...
...
@@ -64,7 +64,7 @@ class B implements Serializable {
public
class
Write
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Object
proxy
=
Proxy
.
newProxyInstance
(
ClassLoader
.
getSystem
ClassLoader
(),
Write
.
class
.
get
ClassLoader
(),
new
Class
[]
{
I
.
class
},
new
Handler
());
ObjectOutputStream
oout
=
new
ObjectOutputStream
(
new
FileOutputStream
(
"tmp.ser"
));
...
...
test/java/io/Serializable/readObjectNoData/Read.java
浏览文件 @
47d4546f
...
...
@@ -95,14 +95,18 @@ class F extends E {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
F
f
=
(
F
)
oin
.
readObject
();
if
(
f
.
aCalled
||
f
.
bCalled
||
f
.
dCalled
||
f
.
eCalled
)
{
throw
new
Error
(
"readObjectNoData invoked erroneously"
);
}
if
(!
f
.
cCalled
)
{
throw
new
Error
(
"readObjectNoData not invoked"
);
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
F
f
=
(
F
)
oin
.
readObject
();
if
(
f
.
aCalled
||
f
.
bCalled
||
f
.
dCalled
||
f
.
eCalled
)
{
throw
new
Error
(
"readObjectNoData invoked erroneously"
);
}
if
(!
f
.
cCalled
)
{
throw
new
Error
(
"readObjectNoData not invoked"
);
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/skipWriteObject/Read.java
浏览文件 @
47d4546f
...
...
@@ -38,9 +38,13 @@ public class Read {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
Object
[]
array
=
(
Object
[])
oin
.
readObject
();
if
(!
(
array
[
0
].
equals
(
"before"
)
&&
array
[
2
].
equals
(
"after"
)))
{
throw
new
Error
();
try
{
Object
[]
array
=
(
Object
[])
oin
.
readObject
();
if
(!
(
array
[
0
].
equals
(
"before"
)
&&
array
[
2
].
equals
(
"after"
)))
{
throw
new
Error
();
}
}
finally
{
oin
.
close
();
}
}
}
test/java/io/Serializable/skippedObjCNFException/Read.java
浏览文件 @
47d4546f
...
...
@@ -44,8 +44,12 @@ class B implements Serializable {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
oin
.
readObject
();
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/stopCustomDeserialization/Read.java
浏览文件 @
47d4546f
...
...
@@ -53,16 +53,20 @@ class C extends B {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
oin
.
readObject
();
throw
new
Error
(
"readObject should not succeed"
);
}
catch
(
ClassNotFoundException
e
)
{
// expected
}
if
(!
oin
.
readObject
().
equals
(
"after"
))
{
throw
new
Error
(
"subsequent object corrupted"
);
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
try
{
oin
.
readObject
();
throw
new
Error
(
"readObject should not succeed"
);
}
catch
(
ClassNotFoundException
e
)
{
// expected
}
if
(!
oin
.
readObject
().
equals
(
"after"
))
{
throw
new
Error
(
"subsequent object corrupted"
);
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/unresolvedClassDesc/Read.java
浏览文件 @
47d4546f
...
...
@@ -32,19 +32,23 @@ import java.io.*;
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
oin
.
readObject
();
oin
.
readObject
();
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
(
"read of Foo instance succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
}
try
{
oin
.
readObject
();
throw
new
Error
(
"indirect read of Foo instance succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
try
{
oin
.
readObject
();
throw
new
Error
(
"read of Foo instance succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
}
try
{
oin
.
readObject
();
throw
new
Error
(
"indirect read of Foo instance succeeded"
);
}
catch
(
ClassNotFoundException
ex
)
{
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/unshared/Read.java
浏览文件 @
47d4546f
...
...
@@ -80,20 +80,30 @@ public class Read {
}
// read in objects written by Write.main()
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
oin
.
readObject
();
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
throw
new
Error
();
}
catch
(
ObjectStreamException
ex
)
{
try
{
oin
.
readObject
();
throw
new
Error
();
}
catch
(
ObjectStreamException
ex
)
{
}
}
finally
{
in
.
close
();
}
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
oin
.
readObject
();
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
oin
.
readUnshared
();
throw
new
Error
();
}
catch
(
ObjectStreamException
ex
)
{
oin
=
new
ObjectInputStream
(
in
);
oin
.
readObject
();
try
{
oin
.
readUnshared
();
throw
new
Error
();
}
catch
(
ObjectStreamException
ex
)
{
}
}
finally
{
in
.
close
();
}
}
}
test/java/io/Serializable/wrongReturnTypes/Read.java
浏览文件 @
47d4546f
...
...
@@ -62,15 +62,19 @@ class B extends A {
public
class
Read
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
new
FileInputStream
(
"tmp.ser"
));
B
b
=
(
B
)
oin
.
readObject
();
if
(
A
.
readObjectNoDataCalled
)
{
throw
new
Error
(
"readObjectNoData with wrong return type called"
);
}
else
if
(
B
.
readObjectCalled
)
{
throw
new
Error
(
"readObject with wrong return type called"
);
}
else
if
(
B
.
readResolveCalled
)
{
throw
new
Error
(
"readResolve with wrong return type called"
);
FileInputStream
in
=
new
FileInputStream
(
"tmp.ser"
);
try
{
ObjectInputStream
oin
=
new
ObjectInputStream
(
in
);
B
b
=
(
B
)
oin
.
readObject
();
if
(
A
.
readObjectNoDataCalled
)
{
throw
new
Error
(
"readObjectNoData with wrong return type called"
);
}
else
if
(
B
.
readObjectCalled
)
{
throw
new
Error
(
"readObject with wrong return type called"
);
}
else
if
(
B
.
readResolveCalled
)
{
throw
new
Error
(
"readResolve with wrong return type called"
);
}
}
finally
{
in
.
close
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录