blob: 8b942b6f962bb509bede2d387dffc9fdd9d6f337 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 * @bug 4070080
26 *
27 * @build WriteAddedSuperClass ReadAddedSuperClass
28 * @run main ReadAddedSuperClass
29 * @summary Test reading an evolved class serialization into the original class
30 * version. Class evolved by adding a superclass.
31 * This is a compatible class evolution.
32 *
33 * Part a of test serializes an instance of an evolved class to a serialization stream.
34 * Part b of test deserializes the serialization stream into an instance of
35 * the original class.
36 *
37 * Description of failure:
38 *
39 * If you delete AddedSuperClass.class before running this test,
40 * both JDK 1.1.x and 1.2 result in ClassNotFoundException for class
41 * AddedSuperClass. If the .class file is not deleted, 1.2 does not
42 * fail. However, JDK 1.1.4 core dumps dereferencing a null class handle
43 * in the native method for inputClassDescriptor.
44 */
45
46import java.io.*;
47
48class A implements Serializable {
49 // Version 1.0 of class A.
50 private static final long serialVersionUID = 1L;
51}
52
53public class ReadAddedSuperClass {
54 public static void main(String args[]) throws IOException, ClassNotFoundException {
55 File f = new File("tmp.ser");
56 ObjectInput in =
57 new ObjectInputStream(new FileInputStream(f));
58 A a = (A)in.readObject();
59 in.close();
60 }
61}