0N/A/*
2362N/A * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/* @test
0N/A * @bug 4180735
0N/A *
0N/A * @clean GetFieldWrite Foo TestClass
0N/A * @build GetFieldWrite
0N/A * @run main GetFieldWrite
0N/A * @clean GetFieldRead TestClass
0N/A * @build GetFieldRead
0N/A * @run main GetFieldRead
0N/A *
0N/A * @summary Make sure that fields that are defaulted can be of primitive and
0N/A * object type.
0N/A *
0N/A */
0N/A
0N/Aimport java.io.*;
0N/Aclass TestClass implements Serializable {
0N/A
0N/A private static final long serialVersionUID = 5748652654655279289L;
0N/A
0N/A // Fields to be serialized.
0N/A private final static ObjectStreamField[] serialPersistentFields = {
0N/A new ObjectStreamField("objectI", Integer.class)};
0N/A
0N/A Integer objectI;
0N/A int primitiveI;
0N/A Foo foo;
0N/A
0N/A public TestClass(Foo f, Integer I, int i) {
0N/A foo = f;
0N/A objectI = I;
0N/A primitiveI = i;
0N/A }
0N/A};
0N/A
0N/Apublic class GetFieldWrite {
0N/A public static void main(String[] args)
0N/A throws ClassNotFoundException, IOException
0N/A {
0N/A FileOutputStream fos = new FileOutputStream("data.ser");
0N/A ObjectOutput out = new ObjectOutputStream(fos);
0N/A out.writeObject(new TestClass(new Foo(100, 200), new Integer(100),
0N/A 200));
0N/A out.close();
0N/A }
0N/A};
0N/A
0N/A/*
0N/A * Test class to be used as data field
0N/A */
0N/Aclass Foo implements Serializable{
0N/A int a;
0N/A int b;
0N/A public Foo() {
0N/A a = 10; b= 20;
0N/A }
0N/A
0N/A public Foo(int a1, int b1)
0N/A {
0N/A a = a1; b = b1;
0N/A }
0N/A
0N/A public String toString() {
0N/A return new String("a = " + a + " b = " + b);
0N/A }
0N/A}