Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/io/Serializable/oldTests/ArrayFields.java
41153 views
1
/*
2
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/* @test
25
* @summary it is a new version of an old test which was
26
* /src/share/test/serialization/piotest.java
27
* Test of serialization/deserialization
28
* of objects with fields of array type
29
*
30
* @build ArrayTest PrimitivesTest ArrayOpsTest
31
* @run main ArrayFields
32
*/
33
34
import java.io.*;
35
36
public class ArrayFields {
37
38
public static void main (String argv[]) throws IOException {
39
System.err.println("\nRegression test for testing of " +
40
"serialization/deserialization of objects with " +
41
"fields of array type\n");
42
43
FileOutputStream ostream = null;
44
FileInputStream istream = null;
45
try {
46
ostream = new FileOutputStream("piotest4.tmp");
47
ObjectOutputStream p = new ObjectOutputStream(ostream);
48
49
ArrayTest array = new ArrayTest();
50
p.writeObject(array);
51
p.flush();
52
53
istream = new FileInputStream("piotest4.tmp");
54
ObjectInputStream q = new ObjectInputStream(istream);
55
56
Object obj = null;
57
try {
58
obj = q.readObject();
59
} catch (ClassCastException ee) {
60
System.err.println("\nTEST FAILED: An Exception occurred " +
61
ee.getMessage());
62
System.err.println("\nBoolean array read as byte array" +
63
" could not be assigned to field z");
64
throw new Error();
65
}
66
67
ArrayTest array_u = (ArrayTest)obj;
68
if (!array.equals(array_u)) {
69
System.out.println("\nTEST FAILED: Unpickling of objects " +
70
"with ArrayTest failed");
71
throw new Error();
72
}
73
System.err.println("\nTEST PASSED");
74
} catch (Exception e) {
75
System.err.print("TEST FAILED: ");
76
e.printStackTrace();
77
throw new Error();
78
} finally {
79
if (istream != null) istream.close();
80
if (ostream != null) ostream.close();
81
}
82
}
83
}
84
85