test/jdk/java/io/Serializable/subclass/SubclassTest.java
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
equal deleted inserted replaced
58564:218a1a642c6f 58565:baa5969ecf34
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 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.
    55 
    55 
    56 /**
    56 /**
    57  * Test if customized readObject and writeObject are called.
    57  * Test if customized readObject and writeObject are called.
    58  */
    58  */
    59 class B implements Serializable {
    59 class B implements Serializable {
       
    60     private static final long serialVersionUID = 1L;
       
    61 
    60     public int publicIntField;
    62     public int publicIntField;
    61     public static int numWriteObjectCalled = 0;
    63     public static int numWriteObjectCalled = 0;
    62     B(int v) {
    64     B(int v) {
    63         publicIntField = v;
    65         publicIntField = v;
    64     }
    66     }
    78 /**
    80 /**
    79  * Test PutFields interface.
    81  * Test PutFields interface.
    80  */
    82  */
    81 
    83 
    82 class C implements Serializable {
    84 class C implements Serializable {
       
    85     private static final long serialVersionUID = 1L;
       
    86 
    83     public int xx1;
    87     public int xx1;
    84     public int xx2;
    88     public int xx2;
    85     static final ObjectStreamField[] serialPersistentFields = {
    89     private static final ObjectStreamField[] serialPersistentFields = {
    86         new ObjectStreamField("x1", Integer.TYPE),
    90         new ObjectStreamField("x1", Integer.TYPE),
    87         new ObjectStreamField("x2", Integer.TYPE),
    91         new ObjectStreamField("x2", Integer.TYPE),
    88         new ObjectStreamField("x3", Integer.TYPE),
    92         new ObjectStreamField("x3", Integer.TYPE),
    89         new ObjectStreamField("x4", Integer.TYPE)
    93         new ObjectStreamField("x4", Integer.TYPE)
    90     };
    94     };
   104 
   108 
   105 };
   109 };
   106 
   110 
   107 
   111 
   108 class A implements Serializable {
   112 class A implements Serializable {
       
   113     private static final long serialVersionUID = 1L;
       
   114 
   109     public int  publicIntField;
   115     public int  publicIntField;
   110     public long publicLongField;
   116     public long publicLongField;
   111     public B    publicBField;
   117     public B    publicBField;
   112     public B[]  publicBArray = { new B(4), new B(6)};
   118     public B[]  publicBArray = { new B(4), new B(6)};
   113     public C    publicCField;
   119     public C    publicCField;