test/jdk/java/io/Serializable/InvalidClassException/noargctor/Serialize/SubclassAcrossPackage.java
author rriggs
Fri, 11 Oct 2019 13:11:56 -0400
changeset 58565 baa5969ecf34
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231427: Warning cleanup in tests of java.io.Serializable Reviewed-by: darcy, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
     2
 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 4093279
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * REMOVED test, build and run tag since could not get this to work.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * Test is run via shell script, run.sh.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
package Serialize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
class PublicSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
extends NonSerializable.PublicCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    37
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    int field1 = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
class ProtectedSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
extends NonSerializable.ProtectedCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    45
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    46
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    int field1 = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
class DifferentPackageSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
extends NonSerializable.PackageCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    53
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    54
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    int field1 = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    DifferentPackageSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        super(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
class SamePackageSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
extends Serialize.SamePackageCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    64
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    65
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    SamePackageSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
class SamePackageProtectedCtor {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    71
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    72
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    protected SamePackageProtectedCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
class SamePackageProtectedSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
extends Serialize.SamePackageProtectedCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    80
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    81
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    SamePackageProtectedSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
class SamePackagePrivateCtor {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    88
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    89
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private SamePackagePrivateCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public SamePackagePrivateCtor(int l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
class SamePackagePrivateSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
extends Serialize.SamePackagePrivateCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
    99
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   100
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    SamePackagePrivateSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        super(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
class PrivateSerializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
extends NonSerializable.PrivateCtor implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
{
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   109
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   110
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    int field1 = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    PrivateSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        super(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
class ExternalizablePublicCtor implements Externalizable {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   119
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   120
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public ExternalizablePublicCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public void writeExternal(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public void readExternal(ObjectInput in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   131
@SuppressWarnings("serial") /* Incorrect declarations are being tested */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
class ExternalizableProtectedCtor implements Externalizable {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   133
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   134
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    protected ExternalizableProtectedCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public void writeExternal(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public void readExternal(ObjectInput in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   145
@SuppressWarnings("serial") /* Incorrect declarations are being tested */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
class ExternalizablePackageCtor implements Externalizable {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   147
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   148
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    ExternalizablePackageCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public void writeExternal(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public void readExternal(ObjectInput in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   159
@SuppressWarnings("serial") /* Incorrect declarations are being tested */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
class ExternalizablePrivateCtor implements Externalizable {
58565
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   161
    private static final long serialVersionUID = 1L;
baa5969ecf34 8231427: Warning cleanup in tests of java.io.Serializable
rriggs
parents: 47216
diff changeset
   162
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    private ExternalizablePrivateCtor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public ExternalizablePrivateCtor(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public void writeExternal(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public void readExternal(ObjectInput in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
public class SubclassAcrossPackage {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public static void main(String args[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            ObjectOutputStream out =   new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            out.writeObject(new PublicSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            out.writeObject(new ProtectedSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            out.writeObject(new SamePackageSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            out.writeObject(new SamePackageProtectedSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            out.writeObject(new DifferentPackageSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            InputStream is = new ByteArrayInputStream(baos.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            ObjectInputStream in = new ObjectInputStream(is);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            /* (PublicSerializable)*/ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            /* (ProtectedSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            /* (SamePackageSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            /* (SamePackageProtectedSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            /* (DifferentPackageSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            out.writeObject(new PrivateSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                /* (PrivateSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                throw new Error("Expected InvalidClassException reading PrivateSerialziable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            out.writeObject(new SamePackagePrivateSerializable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                /* (SamePackagePrivateSerializable) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                throw new Error("Expected InvalidClassException reading PrivateSerialziable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            out.writeObject(new ExternalizablePublicCtor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            /* (ExternalizablePublicCtor) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            out.writeObject(new ExternalizableProtectedCtor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                /* (ExternalizableProtectedCtor) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                throw new Error("Expected InvalidClassException reading ExternalizableProtectedCtor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            out.writeObject(new ExternalizablePackageCtor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                /* (ExternalizablePackageCtor) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                throw new Error("Expected InvalidClassException reading ExternalizablePackageCtor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            baos.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            out = new ObjectOutputStream(baos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            out.writeObject(new ExternalizablePrivateCtor(2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                /* (ExternalizablePrivateCtor) */ in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                throw new Error("Expected InvalidClassException reading ExternalizablePrivateCtor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            } catch (InvalidClassException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            out.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
}