test/jdk/java/io/Serializable/defaulted/GetFieldWrite.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    60     public static void main(String[] args)
    60     public static void main(String[] args)
    61         throws ClassNotFoundException, IOException
    61         throws ClassNotFoundException, IOException
    62     {
    62     {
    63         FileOutputStream fos = new FileOutputStream("data.ser");
    63         FileOutputStream fos = new FileOutputStream("data.ser");
    64         ObjectOutput out = new ObjectOutputStream(fos);
    64         ObjectOutput out = new ObjectOutputStream(fos);
    65         out.writeObject(new TestClass(new Foo(100, 200), new Integer(100),
    65         out.writeObject(new TestClass(new Foo(100, 200), 100, 200));
    66             200));
       
    67         out.close();
    66         out.close();
    68     }
    67     }
    69 };
    68 };
    70 
    69 
    71 /*
    70 /*
    72  * Test class to be used as data field
    71  * Test class to be used as data field
    73  */
    72  */
    74 class Foo implements Serializable{
    73 class Foo implements Serializable{
       
    74     private static final long serialVersionUID = 1L;
       
    75 
    75     int a;
    76     int a;
    76     int b;
    77     int b;
    77     public Foo() {
    78     public Foo() {
    78         a = 10; b= 20;
    79         a = 10; b= 20;
    79     }
    80     }