Path: blob/master/test/jdk/java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass2.java
41161 views
/*1* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @bug 407008025*26* @build WriteAddedSuperClass ReadAddedSuperClass227* @run main ReadAddedSuperClass228* @summary 2nd part of test deserializes the serialization stream into an29* instance of the original class WHEN the AddedSuperClass exists30* locally.31*32* Description of failure:33*34* If you delete AddedSuperClass.class before running this test,35* both JDK 1.1.x and 1.2 result in ClassNotFoundException for class36* AddedSuperClass. If the .class file is not deleted, 1.2 does not37* fail. However, JDK 1.1.4 core dumps dereferencing a null class handle38* in the native method for inputClassDescriptor.39*/4041import java.io.*;4243class AddedSuperClass implements Serializable {44private static final long serialVersionUID = 1L;4546// Needed at least one field to recreate failure.47int field;48}4950class A implements Serializable {51// Version 1.0 of class A.52private static final long serialVersionUID = 1L;53}5455public class ReadAddedSuperClass2 {56public static void main(String args[]) throws IOException, ClassNotFoundException {57File f = new File("tmp.ser");58ObjectInput in =59new ObjectInputStream(new FileInputStream(f));60A a = (A)in.readObject();61in.close();62}63}646566