SerializationStressTest1.java revision 561ee011997c6c2f1befbfaa9d5f0a99771c1d63
1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17package org.apache.harmony.luni.tests.java.io;
18
19import java.io.IOException;
20import java.io.NotSerializableException;
21import java.io.Serializable;
22import java.util.Arrays;
23import java.util.Hashtable;
24import java.util.Vector;
25
26@SuppressWarnings( { "serial", "unused" })
27public class SerializationStressTest1 extends SerializationStressTest {
28
29	// The purpose of these two classes is to test if serialization, when
30	// loading, runs the object's constructor (wrong) or the constructor defined
31	// at the topmost Serializable superclass(correct).
32	static final int INIT_INT_VALUE = 7;
33
34	// HAS to be static class so that our constructor signature will remain
35	// untouched (no synthetic param)
36	private static class SerializationTest implements java.io.Serializable {
37		int anInt = INIT_INT_VALUE;
38
39		public SerializationTest() {
40			super();
41		}
42	}
43
44	static final String INIT_STR_VALUE = "a string that is blortz";
45
46	// HAS to be static class so that our constructor signature will remain
47	// untouched (no synthetic param)
48	private static class SerializationTestSubclass1 extends SerializationTest {
49		String aString = INIT_STR_VALUE;
50
51		public SerializationTestSubclass1() {
52			super();
53			// Just to change default superclass init value
54			anInt = INIT_INT_VALUE / 2;
55		}
56	}
57
58	// -----------------------------------------------------------------------------------
59
60	private static class SpecTestSuperClass implements Runnable {
61		protected java.lang.String instVar;
62
63		public void run() {
64		}
65	}
66
67	private static class SpecTest extends SpecTestSuperClass implements
68			Cloneable, Serializable {
69		public java.lang.String instVar1;
70
71		public static java.lang.String staticVar1;
72
73		public static java.lang.String staticVar2;
74		{
75			instVar1 = "NonStaticInitialValue";
76		}
77		static {
78			staticVar1 = "StaticInitialValue";
79			staticVar1 = new String(staticVar1);
80		}
81
82		public Object method(Object objParam, Object objParam2) {
83			return new Object();
84		}
85
86		public boolean method(boolean bParam, Object objParam) {
87			return true;
88		}
89
90		public boolean method(boolean bParam, Object objParam, Object objParam2) {
91			return true;
92		}
93
94	}
95
96	private static class SpecTestSubclass extends SpecTest {
97		public transient java.lang.String transientInstVar = "transientValue";
98	}
99
100	// -----------------------------------------------------------------------------------
101
102	// This one tests what happens if the read/writeObject methods are defined
103	// Serialization should work fine.
104	private static class ReadWriteObject implements java.io.Serializable {
105		public boolean calledWriteObject = false;
106
107		public boolean calledReadObject = false;
108
109		public ReadWriteObject() {
110			super();
111		}
112
113		private void readObject(java.io.ObjectInputStream in)
114				throws java.io.IOException, ClassNotFoundException {
115			calledReadObject = true;
116			in.readObject();
117		}
118
119		private void writeObject(java.io.ObjectOutputStream out)
120				throws java.io.IOException {
121			calledWriteObject = true;
122			out.writeObject(FOO);
123		}
124	}
125
126	// This one tests what happens if the read/writeObject methods are not
127	// private.
128	// Serialization should fail.
129	private static class PublicReadWriteObject implements java.io.Serializable {
130		public boolean calledWriteObject = false;
131
132		public boolean calledReadObject = false;
133
134		public PublicReadWriteObject() {
135			super();
136		}
137
138		public void readObject(java.io.ObjectInputStream in)
139				throws java.io.IOException, ClassNotFoundException {
140			calledReadObject = true;
141			in.readObject();
142		}
143
144		public void writeObject(java.io.ObjectOutputStream out)
145				throws java.io.IOException {
146			calledWriteObject = true;
147			out.writeObject(FOO);
148		}
149	}
150
151	// This one tests if field names are serialized in the same way (sorting)
152	// across different VMs
153	private static class FieldOrder implements Serializable {
154		String aaa1NonPrimitive = "aaa1";
155
156		int bbb1PrimitiveInt = 5;
157
158		boolean aaa2PrimitiveBoolean = true;
159
160		String bbb2NonPrimitive = "bbb2";
161	}
162
163	// This one tests what happens if you define just readObject, but not
164	// writeObject.
165	// Does it run or not ?
166	private static class JustReadObject implements java.io.Serializable {
167		public boolean calledReadObject = false;
168
169		public JustReadObject() {
170			super();
171		}
172
173		private void readObject(java.io.ObjectInputStream in)
174				throws java.io.IOException, ClassNotFoundException {
175			calledReadObject = true;
176			in.defaultReadObject();
177		}
178	}
179
180	// This one tests what happens if you define just writeObject, but not
181	// readObject.
182	// Does it run or not ?
183	private static class JustWriteObject implements java.io.Serializable {
184		public boolean calledWriteObject = false;
185
186		public JustWriteObject() {
187			super();
188		}
189
190		private void writeObject(java.io.ObjectOutputStream out)
191				throws java.io.IOException, ClassNotFoundException {
192			calledWriteObject = true;
193			out.defaultWriteObject();
194		}
195	}
196
197	// This one tests class-based replacement when dumping
198	private static class ClassBasedReplacementWhenDumping implements
199			java.io.Serializable {
200		public boolean calledReplacement = false;
201
202		public ClassBasedReplacementWhenDumping() {
203			super();
204		}
205
206		private Object writeReplace() {
207			calledReplacement = true;
208			return FOO; // Replacement is a String
209		}
210	}
211
212	// This one tests whether class-based replacement supports multiple levels.
213	// MultipleClassBasedReplacementWhenDumping -> C1 -> C2 -> C3 -> FOO
214	private static class MultipleClassBasedReplacementWhenDumping implements
215			java.io.Serializable {
216		private static class C1 implements java.io.Serializable {
217			private Object writeReplace() {
218				return new C2();
219			}
220		}
221
222		private static class C2 implements java.io.Serializable {
223			private Object writeReplace() {
224				return new C3();
225			}
226		}
227
228		private static class C3 implements java.io.Serializable {
229			private Object writeReplace() {
230				return FOO;
231			}
232		}
233
234		public MultipleClassBasedReplacementWhenDumping() {
235			super();
236		}
237
238		private Object writeReplace() {
239			return new C1();
240		}
241	}
242
243	// This one tests class-based replacement when loading
244	private static class ClassBasedReplacementWhenLoading implements
245			java.io.Serializable {
246		public ClassBasedReplacementWhenLoading() {
247			super();
248		}
249
250		private Object readResolve() {
251			return FOO; // Replacement is a String
252		}
253	}
254
255	// This one tests what happens if a loading-replacement is not
256	// type-compatible with the original object
257	private static class ClassBasedReplacementWhenLoadingViolatesFieldType
258			implements java.io.Serializable {
259		public ClassBasedReplacementWhenLoading classBasedReplacementWhenLoading = new ClassBasedReplacementWhenLoading();
260
261		public ClassBasedReplacementWhenLoadingViolatesFieldType() {
262			super();
263		}
264	}
265
266	// What happens if dumping causes an error and you try to reload ?
267	// Should the load throw the same exception ?
268	private static class MyExceptionWhenDumping1 implements
269			java.io.Serializable {
270		private static class MyException extends java.io.IOException {
271		};
272
273		// A primitive instance variable exposes a bug in the serialization
274		// spec.
275		// Primitive instance variables are written without primitive data tags
276		// and so are read without checking for tags. If an exception is
277		// written, reading primitive data will just read bytes from the stream
278		// which may be tags
279		public boolean anInstanceVar = false;
280
281		public MyExceptionWhenDumping1() {
282			super();
283		}
284
285		private void readObject(java.io.ObjectInputStream in)
286				throws java.io.IOException, ClassNotFoundException {
287			in.defaultReadObject();
288		}
289
290		private void writeObject(java.io.ObjectOutputStream out)
291				throws java.io.IOException, ClassNotFoundException {
292			throw new MyException();
293		}
294	}
295
296	// What happens if dumping causes an error and you try to reload ?
297	// Should the load throw the same exception ?
298	private static class MyExceptionWhenDumping2 implements
299			java.io.Serializable {
300		private static class MyException extends java.io.IOException {
301		};
302
303		public Integer anInstanceVar = new Integer(0xA1);
304
305		public MyExceptionWhenDumping2() {
306			super();
307		}
308
309		private void readObject(java.io.ObjectInputStream in)
310				throws java.io.IOException, ClassNotFoundException {
311			in.defaultReadObject();
312		}
313
314		private void writeObject(java.io.ObjectOutputStream out)
315				throws java.io.IOException, ClassNotFoundException {
316			throw new MyException();
317		}
318	}
319
320	// What happens if dumping causes an error (NonSerializable inst var) and
321	// you try to reload ?
322	// Should the load throw the same exception ?
323	private static class NonSerializableExceptionWhenDumping implements
324			java.io.Serializable {
325		public Object anInstanceVar = new Object();
326
327		public NonSerializableExceptionWhenDumping() {
328			super();
329		}
330	}
331
332	// What happens if dumping causes an error (which is not serializable) and
333	// you try to reload ?
334	// Should the load throw the same exception ?
335	private static class MyUnserializableExceptionWhenDumping implements
336			java.io.Serializable {
337		private static class MyException extends java.io.IOException {
338			private Object notSerializable = new Object();
339		};
340
341		public boolean anInstanceVar = false;
342
343		public MyUnserializableExceptionWhenDumping() {
344			super();
345		}
346
347		private void readObject(java.io.ObjectInputStream in)
348				throws java.io.IOException, ClassNotFoundException {
349			in.defaultReadObject();
350		}
351
352		private void writeObject(java.io.ObjectOutputStream out)
353				throws java.io.IOException, ClassNotFoundException {
354			throw new MyException();
355		}
356	}
357
358	public SerializationStressTest1(String name) {
359		super(name);
360	}
361
362	public void test_18_1_writeObject() {
363		// Test for method void
364		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
365
366		Object objToSave = null;
367		Object objLoaded;
368
369		try {
370			objToSave = "HelloWorld";
371			if (DEBUG)
372				System.out.println("Obj = " + objToSave);
373			objLoaded = dumpAndReload(objToSave);
374			assertTrue(MSG_TEST_FAILED + objToSave, (((String) objLoaded)
375					.equals((String) objToSave)));
376
377		} catch (IOException e) {
378			fail("IOException serializing data : " + e.getMessage());
379		} catch (ClassNotFoundException e) {
380			fail("ClassNotFoundException reading Object type: "
381					+ e.getMessage());
382		} catch (Error err) {
383			System.out.println("Error when obj = " + objToSave);
384			// err.printStackTrace();
385			throw err;
386		}
387	}
388
389	public void test_18_2_writeObject() {
390		// Test for method void
391		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
392
393		Object objToSave = null;
394		Object objLoaded;
395
396		try {
397			objToSave = null;
398			if (DEBUG)
399				System.out.println("Obj = " + objToSave);
400			objLoaded = dumpAndReload(objToSave);
401			assertTrue(MSG_TEST_FAILED + objToSave, objLoaded == objToSave);
402
403		} catch (IOException e) {
404			fail("IOException serializing data : " + e.getMessage());
405		} catch (ClassNotFoundException e) {
406			fail("ClassNotFoundException reading Object type : "
407					+ e.getMessage());
408		} catch (Error err) {
409			System.out.println("Error when obj = " + objToSave);
410			// err.printStackTrace();
411			throw err;
412		}
413	}
414
415	public void test_18_3_writeObject() {
416		// Test for method void
417		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
418
419		Object objToSave = null;
420		Object objLoaded;
421
422		try {
423			byte[] bytes = { 0, 1, 2, 3 };
424			objToSave = bytes;
425			if (DEBUG)
426				System.out.println("Obj = " + objToSave);
427			objLoaded = dumpAndReload(objToSave);
428			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
429					(byte[]) objLoaded, (byte[]) objToSave));
430
431		} catch (IOException e) {
432			fail("IOException serializing data : " + e.getMessage());
433		} catch (ClassNotFoundException e) {
434			fail("ClassNotFoundException reading Object type : "
435					+ e.getMessage());
436		} catch (Error err) {
437			System.out.println("Error when obj = " + objToSave);
438			// err.printStackTrace();
439			throw err;
440		}
441	}
442
443	public void test_18_4_writeObject() {
444		// Test for method void
445		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
446
447		Object objToSave = null;
448		Object objLoaded;
449
450		try {
451			int[] ints = { 0, 1, 2, 3 };
452			objToSave = ints;
453			if (DEBUG)
454				System.out.println("Obj = " + objToSave);
455			objLoaded = dumpAndReload(objToSave);
456			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
457					(int[]) objLoaded, (int[]) objToSave));
458
459		} catch (IOException e) {
460			fail("IOException serializing data : " + e.getMessage());
461		} catch (ClassNotFoundException e) {
462			fail("ClassNotFoundException reading Object type : "
463					+ e.getMessage());
464		} catch (Error err) {
465			System.out.println("Error when obj = " + objToSave);
466			throw err;
467		}
468	}
469
470	public void test_18_5_writeObject() {
471		// Test for method void
472		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
473
474		Object objToSave = null;
475		Object objLoaded;
476
477		try {
478
479			short[] shorts = { 0, 1, 2, 3 };
480			objToSave = shorts;
481			if (DEBUG)
482				System.out.println("Obj = " + objToSave);
483			objLoaded = dumpAndReload(objToSave);
484			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
485					(short[]) objLoaded, (short[]) objToSave));
486
487		} catch (IOException e) {
488			fail("IOException serializing data : " + e.getMessage());
489		} catch (ClassNotFoundException e) {
490			fail("ClassNotFoundException reading Object type : "
491					+ e.getMessage());
492		} catch (Error err) {
493			System.out.println("Error when obj = " + objToSave);
494			// err.printStackTrace();
495			throw err;
496		}
497	}
498
499	public void test_18_6_writeObject() {
500		// Test for method void
501		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
502
503		Object objToSave = null;
504		Object objLoaded;
505
506		try {
507			long[] longs = { 0, 1, 2, 3 };
508			objToSave = longs;
509			if (DEBUG)
510				System.out.println("Obj = " + objToSave);
511			objLoaded = dumpAndReload(objToSave);
512			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
513					(long[]) objLoaded, (long[]) objToSave));
514
515		} catch (IOException e) {
516			fail("IOException serializing data : " + e.getMessage());
517		} catch (ClassNotFoundException e) {
518			fail("ClassNotFoundException reading Object type : "
519					+ e.getMessage());
520		} catch (Error err) {
521			System.out.println("Error when obj = " + objToSave);
522			// err.printStackTrace();
523			throw err;
524		}
525	}
526
527	public void test_18_7_writeObject() {
528		// Test for method void
529		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
530
531		Object objToSave = null;
532		Object objLoaded;
533
534		try {
535			float[] floats = { 0.0f, 1.1f, 2.2f, 3.3f };
536			objToSave = floats;
537			if (DEBUG)
538				System.out.println("Obj = " + objToSave);
539			objLoaded = dumpAndReload(objToSave);
540			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
541					(float[]) objLoaded, (float[]) objToSave));
542
543		} catch (IOException e) {
544			fail("IOException serializing data: " + e.getMessage());
545		} catch (ClassNotFoundException e) {
546			fail("ClassNotFoundException reading Object type : "
547					+ e.getMessage());
548		} catch (Error err) {
549			System.out.println("Error when obj = " + objToSave);
550			// err.printStackTrace();
551			throw err;
552		}
553	}
554
555	public void test_18_8_writeObject() {
556		// Test for method void
557		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
558
559		Object objToSave = null;
560		Object objLoaded;
561
562		try {
563			double[] doubles = { 0.0, 1.1, 2.2, 3.3 };
564			objToSave = doubles;
565			if (DEBUG)
566				System.out.println("Obj = " + objToSave);
567			objLoaded = dumpAndReload(objToSave);
568			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
569					(double[]) objLoaded, (double[]) objToSave));
570
571		} catch (IOException e) {
572			fail("IOException serializing data : " + e.getMessage());
573		} catch (ClassNotFoundException e) {
574			fail("ClassNotFoundException reading Object type : "
575					+ e.getMessage());
576		} catch (Error err) {
577			System.out.println("Error when obj = " + objToSave);
578			// err.printStackTrace();
579			throw err;
580		}
581	}
582
583	public void test_18_9_writeObject() {
584		// Test for method void
585		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
586
587		Object objToSave = null;
588		Object objLoaded;
589
590		try {
591			boolean[] booleans = { true, false, false, true };
592			objToSave = booleans;
593			if (DEBUG)
594				System.out.println("Obj = " + objToSave);
595			objLoaded = dumpAndReload(objToSave);
596			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
597					(boolean[]) objLoaded, (boolean[]) objToSave));
598
599		} catch (IOException e) {
600			fail("IOException serializing data : " + e.getMessage());
601		} catch (ClassNotFoundException e) {
602			fail("ClassNotFoundException reading Object type : " + e.getMessage());
603		} catch (Error err) {
604			System.out.println("Error when obj = " + objToSave);
605			// err.printStackTrace();
606			throw err;
607		}
608	}
609
610	public void test_18_10_writeObject() {
611		// Test for method void
612		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
613
614		Object objToSave = null;
615		Object objLoaded;
616
617		try {
618
619			String[] strings = { "foo", "bar", "java" };
620			objToSave = strings;
621			if (DEBUG)
622				System.out.println("Obj = " + objToSave);
623			objLoaded = dumpAndReload(objToSave);
624			assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
625					(Object[]) objLoaded, (Object[]) objToSave));
626
627		} catch (IOException e) {
628			fail("IOException serializing " + objToSave + " : "
629					+ e.getMessage());
630		} catch (ClassNotFoundException e) {
631			fail("Unable to read Object type: " + e.toString());
632		} catch (Error err) {
633			System.out.println("Error when obj = " + objToSave);
634			// err.printStackTrace();
635			throw err;
636		}
637	}
638
639	public void test_18_11_writeObject() {
640		// Test for method void
641		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
642
643		Object objToSave = null;
644        Object objLoaded;
645
646		try {
647
648			objToSave = new Object(); // Not serializable
649			if (DEBUG)
650				System.out.println("Obj = " + objToSave);
651			boolean passed = false;
652			Throwable t = null;
653			try {
654				objLoaded = dumpAndReload(objToSave);
655			} catch (NotSerializableException ns) {
656				passed = true;
657				t = ns;
658			} catch (Exception wrongExc) {
659				passed = false;
660				t = wrongExc;
661			}
662			assertTrue(
663					"Failed to throw NotSerializableException when serializing "
664							+ objToSave + " Threw(if non-null) this: " + t,
665					passed);
666		} catch (Error err) {
667			System.out.println("Error when obj = " + objToSave);
668			// err.printStackTrace();
669			throw err;
670		}
671	}
672
673	public void test_18_12_writeObject() {
674		// Test for method void
675		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
676
677		try {
678			if (DEBUG)
679				System.out.println("Obj = <mixed>");
680			t_MixPrimitivesAndObjects();
681		} catch (IOException e) {
682			fail("IOException serializing data : " + e.getMessage());
683		} catch (ClassNotFoundException e) {
684			fail("ClassNotFoundException reading Object type : "
685					+ e.getMessage());
686		} catch (Error err) {
687			System.out.println("Error when dumping mixed types");
688			// err.printStackTrace();
689			throw err;
690		}
691	}
692
693	public void test_18_13_writeObject() {
694		// Test for method void
695		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
696
697		Object objToSave = null;
698		Object objLoaded;
699
700		try {
701			SerializationTestSubclass1 st = new SerializationTestSubclass1();
702			// Just change the default ivar values
703			st.anInt = Integer.MAX_VALUE;
704			st.aString = FOO;
705			objToSave = st;
706			if (DEBUG)
707				System.out.println("Obj = " + objToSave);
708			objLoaded = dumpAndReload(objToSave);
709			// non-serializable inst var has to be initialized from top
710			// constructor
711			assertTrue(
712					MSG_TEST_FAILED + objToSave,
713					((SerializationTestSubclass1) objLoaded).anInt == Integer.MAX_VALUE);
714			// but serialized var has to be restored as it was in the object
715			// when dumped
716			assertTrue(MSG_TEST_FAILED + objToSave,
717					((SerializationTestSubclass1) objLoaded).aString
718							.equals(FOO));
719		} catch (IOException e) {
720			fail("Exception serializing " + objToSave + "\t->"
721					+ e.toString());
722		} catch (ClassNotFoundException e) {
723			fail("ClassNotFoundException reading Object type : "
724					+ e.getMessage());
725		} catch (Error err) {
726			System.out.println("Error when obj = " + objToSave);
727			err.printStackTrace();
728			throw err;
729		}
730	}
731
732	public void test_18_14_writeObject() {
733		// Test for method void
734		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
735
736		Object objToSave = null;
737		Object objLoaded;
738
739		try {
740			SpecTest specTest = new SpecTest();
741			// Just change the default ivar values
742			specTest.instVar = FOO;
743			specTest.instVar1 = specTest.instVar;
744			objToSave = specTest;
745			if (DEBUG)
746				System.out.println("Obj = " + objToSave);
747			objLoaded = dumpAndReload(objToSave);
748			// non-serializable inst var has to be initialized from top
749			// constructor
750			assertNull(MSG_TEST_FAILED + objToSave,
751					((SpecTest) objLoaded).instVar);
752			// instVar from non-serialized class, cant  be  saved/restored
753			// by serialization but serialized ivar has to be restored as it
754			// was in the object when dumped
755			assertTrue(MSG_TEST_FAILED + objToSave,
756					((SpecTest) objLoaded).instVar1.equals(FOO));
757
758		} catch (IOException e) {
759			fail("Exception serializing " + objToSave + "\t->"
760					+ e.toString());
761		} catch (ClassNotFoundException e) {
762			fail("ClassNotFoundException reading Object type : "
763					+ e.getMessage());
764		} catch (Error err) {
765			System.out.println("Error when obj = " + objToSave);
766			// err.printStackTrace();
767			throw err;
768		}
769	}
770
771	public void test_18_15_writeObject() {
772		// Test for method void
773		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
774
775		Object objToSave = null;
776		Object objLoaded;
777
778		try {
779			SpecTestSubclass specTestSubclass = new SpecTestSubclass();
780			// Just change the default ivar values
781			specTestSubclass.transientInstVar = FOO;
782			objToSave = specTestSubclass;
783			if (DEBUG)
784				System.out.println("Obj = " + objToSave);
785			objLoaded = dumpAndReload(objToSave);
786			// non-serializable inst var cant be saved, and it is not init'ed
787			// from top constructor in this case
788			assertNull(MSG_TEST_FAILED + objToSave,
789					((SpecTestSubclass) objLoaded).transientInstVar);
790			// transient slot, cant be saved/restored by serialization
791		} catch (IOException e) {
792			fail("Exception serializing " + objToSave + "\t->"
793					+ e.toString());
794		} catch (ClassNotFoundException e) {
795			fail("ClassNotFoundException reading Object type : "
796					+ e.getMessage());
797		} catch (Error err) {
798			System.out.println("Error when obj = " + objToSave);
799			// err.printStackTrace();
800			throw err;
801		}
802	}
803
804	public void test_18_16_writeObject() {
805		// Test for method void
806		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
807
808		Object objToSave = null;
809		Object objLoaded;
810
811		try {
812
813			String[] strings = new String[2];
814			strings[0] = FOO;
815			strings[1] = (" " + FOO + " ").trim(); // Safe way to get a copy
816			// that is not ==
817			objToSave = strings;
818			if (DEBUG)
819				System.out.println("Obj = " + objToSave);
820			objLoaded = dumpAndReload(objToSave);
821			String[] stringsLoaded = (String[]) objLoaded;
822			// Serialization has to use identity-based table for assigning IDs
823			assertTrue(MSG_TEST_FAILED + objToSave,
824					!(stringsLoaded[0] == stringsLoaded[1]));
825		} catch (IOException e) {
826			fail("Exception serializing " + objToSave + "\t->"
827					+ e.toString());
828		} catch (ClassNotFoundException e) {
829			fail("ClassNotFoundException reading Object type : "
830					+ e.getMessage());
831		} catch (Error err) {
832			System.out.println("Error when obj = " + objToSave);
833			// err.printStackTrace();
834			throw err;
835		}
836	}
837
838	public void test_18_17_writeObject() {
839		// Test for method void
840		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
841
842		Object objToSave = null;
843		Object objLoaded;
844
845		try {
846
847			ReadWriteObject readWrite = new ReadWriteObject();
848			objToSave = readWrite;
849			if (DEBUG)
850				System.out.println("Obj = " + objToSave);
851			objLoaded = dumpAndReload(objToSave);
852			// has to have called the writeObject on the instance to dump
853			assertTrue(MSG_TEST_FAILED + objToSave, readWrite.calledWriteObject);
854			// has to have called the readObject on the instance loaded
855			assertTrue(MSG_TEST_FAILED + objToSave,
856					((ReadWriteObject) objLoaded).calledReadObject);
857
858		} catch (IOException e) {
859			fail("Exception serializing " + objToSave + "\t->"
860					+ e.toString());
861		} catch (ClassNotFoundException e) {
862			fail("ClassNotFoundException reading Object type : "
863					+ e.getMessage());
864		} catch (Error err) {
865			System.out.println("Error when obj = " + objToSave);
866			// err.printStackTrace();
867			throw err;
868		}
869	}
870
871	public void test_18_18_writeObject() {
872		// Test for method void
873		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
874
875		Object objToSave = null;
876		Object objLoaded;
877
878		try {
879			PublicReadWriteObject publicReadWrite = new PublicReadWriteObject();
880			objToSave = publicReadWrite;
881			if (DEBUG)
882				System.out.println("Obj = " + objToSave);
883			objLoaded = dumpAndReload(objToSave);
884			// Can't have called the writeObject on the instance to dump
885			assertTrue(MSG_TEST_FAILED + objToSave,
886					!publicReadWrite.calledWriteObject);
887			// Can't have called the readObject on the instance loaded
888			assertTrue(MSG_TEST_FAILED + objToSave,
889					!((PublicReadWriteObject) objLoaded).calledReadObject);
890
891		} catch (IOException e) {
892			fail("Exception serializing " + objToSave + "\t->"
893					+ e.toString());
894		} catch (ClassNotFoundException e) {
895			fail("ClassNotFoundException reading Object type : "
896					+ e.getMessage());
897		} catch (Error err) {
898			System.out.println("Error when obj = " + objToSave);
899			// err.printStackTrace();
900			throw err;
901		}
902	}
903
904	public void test_18_19_writeObject() {
905		// Test for method void
906		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
907
908		Object objToSave = null;
909		Object objLoaded;
910
911		try {
912			FieldOrder fieldOrder = new FieldOrder();
913			objToSave = fieldOrder;
914			if (DEBUG)
915				System.out.println("Obj = " + objToSave);
916			objLoaded = dumpAndReload(objToSave);
917			// This test is only useful for X-loading, so if it managed to
918			// dump&load, we passed the test
919			assertTrue(MSG_TEST_FAILED + objToSave, true);
920
921		} catch (IOException e) {
922			fail("IOException serializing " + objToSave + " : "
923					+ e.getMessage());
924		} catch (ClassNotFoundException e) {
925			fail("ClassNotFoundException reading Object type : "
926					+ e.getMessage());
927		} catch (Error err) {
928			System.out.println("Error when obj = " + objToSave);
929			// err.printStackTrace();
930			throw err;
931		}
932	}
933
934	public void test_18_20_writeObject() {
935		// Test for method void
936		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
937
938		Object objToSave = null;
939		Object objLoaded;
940
941		try {
942			objToSave = Class.forName("java.lang.Integer");
943			if (DEBUG)
944				System.out.println("Obj = " + objToSave);
945			objLoaded = dumpAndReload(objToSave);
946			// Classes with the same name are unique, so test for ==
947			assertTrue(MSG_TEST_FAILED + objToSave, objLoaded == objToSave);
948
949		} catch (IOException e) {
950			fail("IOException serializing " + objToSave + " : "
951					+ e.getMessage());
952		} catch (ClassNotFoundException e) {
953			fail("ClassNotFoundException reading Object type : "
954					+ e.getMessage());
955		} catch (Error err) {
956			System.out.println("Error when obj = " + objToSave);
957			// err.printStackTrace();
958			throw err;
959		}
960	}
961
962	public void test_18_21_writeObject() {
963		// Test for method void
964		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
965
966		Object objToSave = null;
967		Object objLoaded;
968
969		try {
970			// Even though instances of java.lang.Object are not Serializable,
971			// instances of java.lang.Class are. So, the object
972			// java.lang.Object.class
973			// should be serializable
974			objToSave = Class.forName("java.lang.Object");
975			if (DEBUG)
976				System.out.println("Obj = " + objToSave);
977			objLoaded = dumpAndReload(objToSave);
978			// Classes with the same name are unique, so test for ==
979			assertTrue(MSG_TEST_FAILED + objToSave, objLoaded == objToSave);
980
981		} catch (IOException e) {
982			fail("IOException serializing " + objToSave + " : "
983					+ e.getMessage());
984		} catch (ClassNotFoundException e) {
985			fail("ClassNotFoundException reading Object type : "
986					+ e.getMessage());
987		} catch (Error err) {
988			System.out.println("Error when obj = " + objToSave);
989			// err.printStackTrace();
990			throw err;
991		}
992	}
993
994	public void test_18_22_writeObject() {
995		// Test for method void
996		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
997
998		Object objToSave = null;
999		Object objLoaded;
1000
1001		try {
1002			java.net.URL url = new java.net.URL("http://localhost/a.txt");
1003			objToSave = url;
1004			if (DEBUG)
1005				System.out.println("Obj = " + objToSave);
1006			objLoaded = dumpAndReload(objToSave);
1007			assertTrue("URLs are not the same: " + url + "\t,\t" + objLoaded,
1008					url.equals(objLoaded));
1009
1010		} catch (IOException e) {
1011			fail("IOException serializing " + objToSave + " : "
1012					+ e.getMessage());
1013		} catch (ClassNotFoundException e) {
1014			fail("ClassNotFoundException reading Object type : "
1015					+ e.getMessage());
1016		} catch (Error err) {
1017			System.out.println("Error when obj = " + objToSave);
1018			// err.printStackTrace();
1019			throw err;
1020		}
1021	}
1022
1023	public void test_18_23_writeObject() {
1024		// Test for method void
1025		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1026
1027		Object objToSave = null;
1028		Object objLoaded;
1029
1030		try {
1031
1032			JustReadObject justReadObject = new JustReadObject();
1033			objToSave = justReadObject;
1034			if (DEBUG)
1035				System.out.println("Obj = " + objToSave);
1036			objLoaded = dumpAndReload(objToSave);
1037			// Only calls readObject on the instance loaded if writeObject was
1038			// also defined
1039			assertTrue("Called readObject on an object without a writeObject",
1040					!((JustReadObject) objLoaded).calledReadObject);
1041
1042		} catch (IOException e) {
1043			fail("IOException serializing " + objToSave + " : "
1044					+ e.getMessage());
1045		} catch (ClassNotFoundException e) {
1046			fail("ClassNotFoundException reading Object type : "
1047					+ e.getMessage());
1048		} catch (Error err) {
1049			System.out.println("Error when obj = " + objToSave);
1050			// err.printStackTrace();
1051			throw err;
1052		}
1053	}
1054
1055	public void test_18_24_writeObject() {
1056		// Test for method void
1057		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1058
1059		Object objToSave = null;
1060		Object objLoaded;
1061
1062		try {
1063
1064			JustWriteObject justWriteObject = new JustWriteObject();
1065			objToSave = justWriteObject;
1066			if (DEBUG)
1067				System.out.println("Obj = " + objToSave);
1068			objLoaded = dumpAndReload(objToSave);
1069			// Call writeObject on the instance even if it does not define
1070			// readObject
1071			assertTrue(MSG_TEST_FAILED + objToSave,
1072					justWriteObject.calledWriteObject);
1073
1074		} catch (IOException e) {
1075			fail("IOException serializing " + objToSave + " : "
1076					+ e.getMessage());
1077		} catch (ClassNotFoundException e) {
1078			fail("ClassNotFoundException reading Object type: "
1079					+ e.getMessage());
1080		} catch (Error err) {
1081			System.out.println("Error when obj = " + objToSave);
1082			// err.printStackTrace();
1083			throw err;
1084		}
1085	}
1086
1087	public void test_18_25_writeObject() {
1088		// Test for method void
1089		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1090
1091		Object objToSave = null;
1092		Object objLoaded;
1093
1094		try {
1095			Vector<String> vector = new Vector<String>(1);
1096			vector.add(FOO);
1097			objToSave = vector;
1098			if (DEBUG)
1099				System.out.println("Obj = " + objToSave);
1100			objLoaded = dumpAndReload(objToSave);
1101			// Has to have the string there
1102			assertTrue(MSG_TEST_FAILED + objToSave, FOO
1103					.equals(((java.util.Vector) objLoaded).elementAt(0)));
1104
1105		} catch (IOException e) {
1106			fail("IOException serializing " + objToSave + " : "
1107					+ e.getMessage());
1108		} catch (ClassNotFoundException e) {
1109			fail("ClassNotFoundException reading Object type : "
1110					+ e.getMessage());
1111		} catch (Error err) {
1112			System.out.println("Error when obj = " + objToSave);
1113			throw err;
1114		}
1115	}
1116
1117	public void test_18_26_writeObject() {
1118		// Test for method void
1119		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1120
1121		Object objToSave = null;
1122		Object objLoaded;
1123
1124		try {
1125			Hashtable<String, String> hashTable = new Hashtable<String, String>(
1126                    5);
1127            hashTable.put(FOO, FOO);
1128            objToSave = hashTable;
1129            if (DEBUG)
1130				System.out.println("Obj = " + objToSave);
1131			objLoaded = dumpAndReload(objToSave);
1132			java.util.Hashtable loadedHashTable = (java.util.Hashtable) objLoaded;
1133			// Has to have the key/value there (FOO -> FOO)
1134			assertTrue(MSG_TEST_FAILED + objToSave, FOO.equals(loadedHashTable
1135					.get(FOO)));
1136
1137		} catch (IOException e) {
1138			fail("IOException serializing " + objToSave + " : "
1139					+ e.getMessage());
1140		} catch (ClassNotFoundException e) {
1141			fail("ClassNotFoundException reading Object type : "
1142					+ e.getMessage());
1143		} catch (Error err) {
1144			System.out.println("Error when obj = " + objToSave);
1145			throw err;
1146		}
1147	}
1148
1149	public void test_18_27_writeObject() {
1150		// Test for method void
1151		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1152
1153		Object objToSave = null;
1154		Object objLoaded;
1155
1156		try {
1157			ClassBasedReplacementWhenDumping classBasedReplacementWhenDumping = new ClassBasedReplacementWhenDumping();
1158			objToSave = classBasedReplacementWhenDumping;
1159			if (DEBUG)
1160				System.out.println("Obj = " + objToSave);
1161			objLoaded = dumpAndReload(objToSave);
1162			// Has to have run the replacement method
1163			assertTrue("Did not run writeReplace",
1164					classBasedReplacementWhenDumping.calledReplacement);
1165
1166			// Has to have loaded a String (replacement object)
1167			assertTrue("Did not replace properly", FOO.equals(objLoaded));
1168
1169		} catch (IOException e) {
1170			fail("IOException serializing " + objToSave + " : "
1171					+ e.getMessage());
1172		} catch (ClassNotFoundException e) {
1173			fail("ClassNotFoundException reading Object type : "
1174					+ e.getMessage());
1175		} catch (Error err) {
1176			System.out.println("Error when obj = " + objToSave);
1177			// err.printStackTrace();
1178			throw err;
1179		}
1180	}
1181
1182	public void test_18_28_writeObject() {
1183		// Test for method void
1184		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1185
1186		Object objToSave = null;
1187		Object objLoaded;
1188
1189		try {
1190			MultipleClassBasedReplacementWhenDumping multipleClassBasedReplacementWhenDumping = new MultipleClassBasedReplacementWhenDumping();
1191			objToSave = multipleClassBasedReplacementWhenDumping;
1192			if (DEBUG)
1193				System.out.println("Obj = " + objToSave);
1194			objLoaded = dumpAndReload(objToSave);
1195			// Has to have loaded a String (replacement object)
1196			assertTrue(
1197					"Executed multiple levels of replacement (see PR 1F9RNT1), loaded= "
1198							+ objLoaded,
1199					objLoaded instanceof MultipleClassBasedReplacementWhenDumping.C1);
1200
1201		} catch (IOException e) {
1202			fail("IOException serializing " + objToSave + " : "
1203					+ e.getMessage());
1204		} catch (ClassNotFoundException e) {
1205			fail("ClassNotFoundException reading Object type : "
1206					+ e.toString());
1207		} catch (Error err) {
1208			System.out.println("Error when obj = " + objToSave);
1209			// err.printStackTrace();
1210			throw err;
1211		}
1212	}
1213
1214	public void test_18_29_writeObject() {
1215		// Test for method void
1216		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1217
1218		Object objToSave = null;
1219		Object objLoaded;
1220
1221		try {
1222			ClassBasedReplacementWhenLoading classBasedReplacementWhenLoading = new ClassBasedReplacementWhenLoading();
1223			objToSave = classBasedReplacementWhenLoading;
1224			if (DEBUG)
1225				System.out.println("Obj = " + objToSave);
1226			objLoaded = dumpAndReload(objToSave);
1227			// Has to have loaded a String (replacement object)
1228			assertTrue("Did not run readResolve", FOO.equals(objLoaded));
1229
1230		} catch (IOException e) {
1231			fail("IOException serializing " + objToSave + " : "
1232					+ e.getMessage());
1233		} catch (ClassNotFoundException e) {
1234			fail("ClassNotFoundException reading Object type : "
1235					+ e.getMessage());
1236		} catch (Error err) {
1237			System.out.println("Error when obj = " + objToSave);
1238			// err.printStackTrace();
1239			throw err;
1240		}
1241	}
1242
1243	public void test_18_30_writeObject() {
1244		// Test for method void
1245		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1246
1247		Object objToSave = null;
1248		Object objLoaded;
1249
1250		try {
1251			ClassBasedReplacementWhenLoadingViolatesFieldType classBasedReplacementWhenLoadingViolatesFieldType = new ClassBasedReplacementWhenLoadingViolatesFieldType();
1252			objToSave = classBasedReplacementWhenLoadingViolatesFieldType;
1253			if (DEBUG)
1254				System.out.println("Obj = " + objToSave);
1255			objLoaded = dumpAndReload(objToSave);
1256			// We cannot gere here, the load replacement must have caused a
1257			// field type violation
1258			fail(
1259					"Loading replacements can cause field type violation in this implementation");
1260
1261		} catch (IOException e) {
1262			fail("IOException serializing " + objToSave + " : "
1263					+ e.getMessage());
1264		} catch (ClassNotFoundException e) {
1265			fail("ClassNotFoundException reading Object type : "
1266					+ e.getMessage());
1267		} catch (ClassCastException e) {
1268			assertTrue(
1269					"Loading replacements can NOT cause field type violation in this implementation",
1270					true);
1271		} catch (Error err) {
1272			System.out.println("Error when obj = " + objToSave);
1273			// err.printStackTrace();
1274			throw err;
1275		}
1276	}
1277
1278	public void test_18_31_writeObject() {
1279		// Test for method void
1280		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1281
1282		Object objToSave = null;
1283		Object objLoaded;
1284
1285		try {
1286			MyExceptionWhenDumping1 exceptionWhenDumping = new MyExceptionWhenDumping1();
1287			objToSave = exceptionWhenDumping;
1288			if (DEBUG)
1289				System.out.println("Obj = " + objToSave);
1290			boolean causedException = false;
1291			try {
1292				dump(objToSave);
1293			} catch (MyExceptionWhenDumping1.MyException e) {
1294				causedException = true;
1295			}
1296			;
1297			assertTrue("Should have caused an exception when dumping",
1298					causedException);
1299			causedException = false;
1300			try {
1301				objLoaded = reload();
1302				// Although the spec says we should get a WriteAbortedException,
1303				// the serialization format handle an Exception when reading
1304				// primitive data so we get ClassCastException instead
1305			} catch (ClassCastException e) {
1306				causedException = true;
1307			}
1308			;
1309			assertTrue("Should have caused a ClassCastException when loading",
1310					causedException);
1311		} catch (IOException e) {
1312			fail("IOException serializing " + objToSave + " : "
1313					+ e.getMessage());
1314		} catch (ClassNotFoundException e) {
1315			fail("ClassNotFoundException reading Object type : "
1316					+ e.getMessage());
1317		} catch (Error err) {
1318			System.out.println("Error when obj = " + objToSave);
1319			// err.printStackTrace();
1320			throw err;
1321		}
1322	}
1323
1324	public void test_18_32_writeObject() {
1325		// Test for method void
1326		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1327
1328		Object objToSave = null;
1329		Object objLoaded;
1330
1331		try {
1332			MyExceptionWhenDumping2 exceptionWhenDumping = new MyExceptionWhenDumping2();
1333			objToSave = exceptionWhenDumping;
1334			if (DEBUG)
1335				System.out.println("Obj = " + objToSave);
1336			boolean causedException = false;
1337			try {
1338				dump(objToSave);
1339			} catch (MyExceptionWhenDumping2.MyException e) {
1340				causedException = true;
1341			}
1342			;
1343			assertTrue("Should have caused an exception when dumping",
1344					causedException);
1345			causedException = false;
1346			try {
1347				objLoaded = reload();
1348			} catch (java.io.WriteAbortedException e) {
1349				causedException = true;
1350			}
1351			;
1352			assertTrue(
1353					"Should have caused a java.io.WriteAbortedException when loading",
1354					causedException);
1355		} catch (IOException e) {
1356			fail("IOException serializing " + objToSave + " : "
1357					+ e.getMessage());
1358		} catch (ClassNotFoundException e) {
1359			fail("ClassNotFoundException reading Object type : "
1360					+ e.getMessage());
1361		} catch (ClassCastException e) {
1362			fail("ClassCastException : " + e.getMessage());
1363		} catch (Error err) {
1364			System.out.println("Error when obj = " + objToSave);
1365			throw err;
1366		}
1367	}
1368
1369	public void test_NonSerializableExceptionWhenDumping() {
1370		// Test for method void
1371		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1372
1373		Object objToSave = null;
1374		Object objLoaded;
1375
1376		try {
1377			NonSerializableExceptionWhenDumping nonSerializableExceptionWhenDumping = new NonSerializableExceptionWhenDumping();
1378			objToSave = nonSerializableExceptionWhenDumping;
1379			if (DEBUG)
1380				System.out.println("Obj = " + objToSave);
1381			boolean causedException = false;
1382			try {
1383				dump(objToSave);
1384			} catch (java.io.NotSerializableException e) {
1385				causedException = true;
1386			}
1387			;
1388			assertTrue("Should have caused an exception when dumping",
1389					causedException);
1390			causedException = false;
1391			try {
1392				objLoaded = reload();
1393			} catch (java.io.WriteAbortedException e) {
1394				causedException = true;
1395			}
1396			;
1397			assertTrue(
1398					"Should have caused a java.io.WriteAbortedException when loading",
1399					causedException);
1400		} catch (IOException e) {
1401			fail("IOException serializing " + objToSave + " : "
1402					+ e.getMessage());
1403		} catch (ClassNotFoundException e) {
1404			fail("ClassNotFoundException reading Object type : "
1405					+ e.getMessage());
1406		} catch (Error err) {
1407			System.out.println("Error when obj = " + objToSave);
1408			// err.printStackTrace();
1409			throw err;
1410		}
1411	}
1412
1413	public void test_18_33_writeObject() {
1414		// Test for method void
1415		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1416
1417		Object objToSave = null;
1418		Object objLoaded;
1419
1420		try {
1421			MyUnserializableExceptionWhenDumping exceptionWhenDumping = new MyUnserializableExceptionWhenDumping();
1422			objToSave = exceptionWhenDumping;
1423			if (DEBUG)
1424				System.out.println("Obj = " + objToSave);
1425			boolean causedException = false;
1426			try {
1427				dump(objToSave);
1428			} catch (java.io.StreamCorruptedException e) {
1429				causedException = true;
1430			}
1431			;
1432			assertTrue("Should have caused an exception when dumping",
1433					causedException);
1434			// As the stream is corrupted, reading the stream will have
1435			// undefined results
1436		} catch (IOException e) {
1437			fail("IOException serializing " + objToSave + " : "
1438					+ e.getMessage());
1439		} catch (ClassNotFoundException e) {
1440			fail("ClassNotFoundException reading Object type : "
1441					+ e.getMessage());
1442		} catch (Error err) {
1443			System.out.println("Error when obj = " + objToSave);
1444			// err.printStackTrace();
1445			throw err;
1446		}
1447	}
1448
1449	public void test_18_34_writeObject() {
1450		// Test for method void
1451		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1452
1453		Object objToSave = null;
1454		Object objLoaded;
1455
1456		try {
1457			java.io.IOException ioe = new java.io.IOException();
1458			objToSave = ioe;
1459			if (DEBUG)
1460				System.out.println("Obj = " + objToSave);
1461			objLoaded = dumpAndReload(objToSave);
1462			// Has to be able to save/load an exception
1463			assertTrue(MSG_TEST_FAILED + objToSave, true);
1464
1465		} catch (IOException e) {
1466			fail("IOException serializing " + objToSave + " : "
1467					+ e.getMessage());
1468		} catch (ClassNotFoundException e) {
1469			fail("ClassNotFoundException reading Object type : "
1470					+ e.getMessage());
1471		} catch (Error err) {
1472			System.out.println("Error when obj = " + objToSave);
1473			// err.printStackTrace();
1474			throw err;
1475		}
1476	}
1477
1478	public void test_18_35_writeObject() {
1479		// Test for method void
1480		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1481
1482		Object objToSave = null;
1483		Object objLoaded;
1484
1485		try {
1486			objToSave = Class.forName("java.util.Hashtable");
1487			if (DEBUG)
1488				System.out.println("Obj = " + objToSave);
1489			objLoaded = dumpAndReload(objToSave);
1490			// Classes with the same name are unique, so test for ==
1491			assertTrue(MSG_TEST_FAILED + objToSave, objLoaded == objToSave);
1492
1493		} catch (IOException e) {
1494			fail("IOException serializing " + objToSave + " : "
1495					+ e.getMessage());
1496		} catch (ClassNotFoundException e) {
1497			fail("ClassNotFoundException reading Object type : "
1498					+ e.getMessage());
1499		} catch (Error err) {
1500			System.out.println("Error when obj = " + objToSave);
1501			// err.printStackTrace();
1502			throw err;
1503		}
1504	}
1505
1506	public void test_18_36_writeObject() {
1507		// Test for method void
1508		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1509
1510		Object objToSave = null;
1511		Object objLoaded;
1512
1513		try {
1514			java.io.IOException ex = new java.io.InvalidClassException(FOO);
1515			objToSave = ex;
1516			if (DEBUG)
1517				System.out.println("Obj = " + objToSave);
1518			objLoaded = dumpAndReload(objToSave);
1519			// Has to be able to save/load an exception
1520			assertTrue(MSG_TEST_FAILED + objToSave, true);
1521
1522		} catch (IOException e) {
1523			fail("IOException serializing " + objToSave + " : "
1524					+ e.getMessage());
1525		} catch (ClassNotFoundException e) {
1526			fail("ClassNotFoundException reading Object type : "
1527					+ e.getMessage());
1528		} catch (Error err) {
1529			System.out.println("Error when obj = " + objToSave);
1530			// err.printStackTrace();
1531			throw err;
1532		}
1533	}
1534
1535	public void test_18_37_writeObject() {
1536		// Test for method void
1537		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1538
1539		Object objToSave = null;
1540		Object objLoaded;
1541
1542		try {
1543			java.io.IOException ex = new java.io.InvalidObjectException(FOO);
1544			objToSave = ex;
1545			if (DEBUG)
1546				System.out.println("Obj = " + objToSave);
1547			objLoaded = dumpAndReload(objToSave);
1548			// Has to be able to save/load an exception
1549			assertTrue(MSG_TEST_FAILED + objToSave, true);
1550
1551		} catch (IOException e) {
1552			fail("IOException serializing " + objToSave + " : "
1553					+ e.getMessage());
1554		} catch (ClassNotFoundException e) {
1555			fail("ClassNotFoundException reading Object type : "
1556					+ e.getMessage());
1557		} catch (Error err) {
1558			System.out.println("Error when obj = " + objToSave);
1559			// err.printStackTrace();
1560			throw err;
1561		}
1562	}
1563
1564	public void test_18_38_writeObject() {
1565		// Test for method void
1566		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1567
1568		Object objToSave = null;
1569		Object objLoaded;
1570
1571		try {
1572			java.io.IOException ex = new java.io.NotActiveException(FOO);
1573			objToSave = ex;
1574			if (DEBUG)
1575				System.out.println("Obj = " + objToSave);
1576			objLoaded = dumpAndReload(objToSave);
1577			// Has to be able to save/load an exception
1578			assertTrue(MSG_TEST_FAILED + objToSave, true);
1579
1580		} catch (IOException e) {
1581			fail("IOException serializing " + objToSave + " : "
1582					+ e.getMessage());
1583		} catch (ClassNotFoundException e) {
1584			fail("ClassNotFoundException reading Object type : "
1585					+ e.getMessage());
1586		} catch (Error err) {
1587			System.out.println("Error when obj = " + objToSave);
1588			// err.printStackTrace();
1589			throw err;
1590		}
1591	}
1592
1593	public void test_18_39_writeObject() {
1594		// Test for method void
1595		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1596
1597		Object objToSave = null;
1598		Object objLoaded;
1599
1600		try {
1601			java.io.IOException ex = new java.io.NotSerializableException(FOO);
1602			objToSave = ex;
1603			if (DEBUG)
1604				System.out.println("Obj = " + objToSave);
1605			objLoaded = dumpAndReload(objToSave);
1606			// Has to be able to save/load an exception
1607			assertTrue(MSG_TEST_FAILED + objToSave, true);
1608
1609		} catch (IOException e) {
1610			fail("IOException serializing " + objToSave + " : "
1611					+ e.getMessage());
1612		} catch (ClassNotFoundException e) {
1613			fail("ClassNotFoundException reading Object type : "
1614					+ e.getMessage());
1615		} catch (Error err) {
1616			System.out.println("Error when obj = " + objToSave);
1617			// err.printStackTrace();
1618			throw err;
1619		}
1620	}
1621
1622	public void test_18_40_writeObject() {
1623		// Test for method void
1624		// java.io.ObjectOutputStream.writeObject(java.lang.Object)
1625
1626		Object objToSave = null;
1627		Object objLoaded;
1628
1629		try {
1630			java.io.IOException ex = new java.io.StreamCorruptedException(FOO);
1631			objToSave = ex;
1632			if (DEBUG)
1633				System.out.println("Obj = " + objToSave);
1634			objLoaded = dumpAndReload(objToSave);
1635			// Has to be able to save/load an exception
1636			assertTrue(MSG_TEST_FAILED + objToSave, true);
1637
1638		} catch (IOException e) {
1639			fail("IOException serializing " + objToSave + " : "
1640					+ e.getMessage());
1641		} catch (ClassNotFoundException e) {
1642			fail("ClassNotFoundException reading Object type : "
1643					+ e.getMessage());
1644		} catch (Error err) {
1645			System.out.println("Error when obj = " + objToSave);
1646			// err.printStackTrace();
1647			throw err;
1648		}
1649	}
1650}
1651