jdk/test/java/io/Serializable/subclass/AbstractObjectInputStream.java
author martin
Tue, 15 Sep 2015 21:56:04 -0700
changeset 32649 2ee9017c7597
parent 5506 202f599c92aa
permissions -rw-r--r--
8136583: Core libraries should use blessed modifier order Summary: Run blessed-modifier-order script (see bug) Reviewed-by: psandoz, chegar, alanb, plevart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2004, 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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Stack;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.Math;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.reflect.Modifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This abstract class enables one to subclass ObjectInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * for the purpose of re-implementing serialization while preserving the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * existing public serialization API. A complimentary subclass of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * AbstractObjectInputStream must also be implemented.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Since serialization must override java access rules in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * access private, protected and package accessible Serializable fields,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * only trusted classes are allowed to subclass AbstractObjectInputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Subclasses of AbstractObjectInputStream must define SerializablePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * "enableAbstractSubclass" within a security policy file or this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * constructor will throw a SecurityException. Implementations of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * class should protect themselves from being subclassed in a way that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * provide access to object references and other sensitive info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Specifically, readObjectOverride() should be made final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * A subclass of AbstractObjectInputStream deserializes primitive data and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * objects previously written by a subclass of AbstractObjectOutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The subclass ensures that the types of all objects in the graph created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * from the stream match the classes present in the Java Virtual Machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Classes are loaded as required using the standard mechanisms. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * Only objects that support the java.io.Serializable or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * java.io.Externalizable interface can be read from streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * The method <STRONG>readObjectOverride</STRONG> is used to read an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * from the stream.  Java's safe casting should be used to get the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * desired type.  In Java, strings and arrays are objects and are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * treated as objects during serialization. When read with readObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * they need to be cast to the expected type.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Primitive data types can be read from the stream using the appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * method on DataInput. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The default deserialization mechanism for objects restores the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * contents of each field to the value and type it had when it was written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * References to other objects cause those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * objects to be read from the stream as necessary.  Graphs of objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * are restored correctly using a reference sharing mechanism.  New
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * objects are always allocated when deserializing, which prevents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * existing objects from being overwritten. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * Reading an object is analogous to running the constructors of a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * object.  Memory is allocated for the object and initialized to zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * (NULL).  No-arg constructors are invoked for the first non-serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * super class and then the fields of the serializable classes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * restored from the stream starting with the serializable class closest to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * java.lang.object and finishing with the object's most specifiec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * class. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Classes control how they are serialized by implementing either the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * java.io.Serializable or java.io.Externalizable interfaces.<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Implementing the Serializable interface allows object serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * to save and restore the entire state of the object and it allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * classes to evolve between the time the stream is written and the time it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * read.  It automatically traverses references between objects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * saving and restoring entire graphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Serializable classes that require special handling during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * serialization and deserialization process should implement both
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * of these methods:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * private void writeObject(java.io.ObjectOutputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *     throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * private void readObject(java.io.ObjectInputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *     throws IOException, ClassNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * </PRE><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * The readObject method is responsible for reading and restoring the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * state of the object for its particular class using data written to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * the stream by the corresponding writeObject method.  The method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * does not need to concern itself with the state belonging to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * superclasses or subclasses.  State is restored by reading data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * the ObjectInputStream for the individual fields and making
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * assignments to the appropriate fields of the object.  Reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * primitive data types is supported by DataInput. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * Serialization does not read or assign values to the fields of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * object that does not implement the java.io.Serializable interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * Subclasses of Objects that are not serializable can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * serializable. In this case the non-serializable class must have an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * accessible no-arg constructor to allow its fields to be initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * In this case it is the responsibility of the subclass to save and restore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * the state of the non-serializable class. It is frequently the case that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * the fields of that class are accessible (public, package, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * protected) or that there are get and set methods that can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * to restore the state. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * Implementing the Externalizable interface allows the object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * assume complete control over the contents and format of the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * serialized form.  The methods of the Externalizable interface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * writeExternal and readExternal, are called to save and restore the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * objects state.  When implemented by a class they can write and read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * their own state using all of the methods of ObjectOutput and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * ObjectInput.  It is the responsibility of the objects to handle any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * versioning that occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * @author  Joe Fialli
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * @see java.io.ObjectInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * @see java.io.DataInput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * @see java.io.Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * @see java.io.Externalizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * @see java.io.ext.AbstractObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * @since   JDK1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   146
public abstract class AbstractObjectInputStream extends ObjectInputStream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    protected InputStream in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Create an ObjectInputStream that reads from the specified InputStream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Add the following line to the security policy file to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * subclassing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *     permission SerializablePermission "enableAbstractSubclass" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * </PRE><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @exception StreamCorruptedException The version or magic number are incorrect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @exception IOException An exception occurred in the underlying stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @exception SecurityException if subclass does not have SerializablePermiision
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *            "enableAbstractSubclass".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public AbstractObjectInputStream(InputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        throws IOException, StreamCorruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            this.in = in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   170
    public abstract void close() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /* Read an object from the stream. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Read an object from the ObjectInputStream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * NOTE: The override method of this class should have the modifier final.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Default deserializing for a class can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * overriden by defining a readObject method for the Serializable class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Objects referenced by this object are read transitively so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * that a complete equivalent graph of objects is reconstructed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * readObject. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * The root object is completely restored when all of its fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * and the objects it references are completely restored. At this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * point the object validation callbacks are executed in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * based on their registered priorities. The callbacks are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * registered by objects (in the readObject special methods)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * as they are individually restored. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * For security's sake, any overrides of this method should be final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Serialization typically needs to disable java access rules
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * to serialize private, protected and package accessible Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * fields. This method gets called for ALL Serializable objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @exception java.lang.ClassNotFoundException Class of a serialized object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *      cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @exception InvalidClassException Something is wrong with a class used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *     serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @exception StreamCorruptedException Control information in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *     stream is inconsistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @exception OptionalDataException Primitive data was found in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * stream instead of objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @exception IOException Any of the usual Input/Output related exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see java.io.ObjectInputStream#resolveObject(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @see java.io.Resolvable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @see java.io.Externalizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @see java.io.ObjectInputValidation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @see #registerValidation(ObjectInputValidation, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @see java.io.ObjectInputStream#resolveClass(ObjectStreamClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    protected Object readObjectOverride()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        throws OptionalDataException, ClassNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Read the Serializable fields of the current object from this stream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Note: The object being deserialized is not passed to this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *       For security purposes, the initial implementation maintained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *       the state of the last object to be read by readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *       only allowed this method to be invoked for this object.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @exception NotActiveException  Thrown if a readObject method is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *                                active.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @exception ClassNotFoundException if no corresponding local class can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *                                   found in the local JVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   233
    public abstract void defaultReadObject()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        throws IOException, ClassNotFoundException, NotActiveException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Enable allocation for subclass reimplementing serialization.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Note: Default allocation does not have the java access priviledges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * to invoke package and protected constructors.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Security alert: this JVM native method is private within ObjectInputStream; however,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *                 it was anticipated that re-implementors of serialization would need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *                 access to this method. Is this allocator considered a security problem? <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @param ctorClass  is the same class or a superclass of <STRONG>ofClass</STRONG>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @param ofClass    the type of the object to allocate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @return   an object of <STRONG>ofClass</STRONG> type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @exception IllegalAccessException if no-arg constructor of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *            <STRONG>ctorClass</STRONG> is not accessible from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *            <STRONG>ofClass</STRONG>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @exception InstantiationException  TBD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   255
    protected final native Object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        allocateNewObject(Class ofClass, Class ctorClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        throws InstantiationException, IllegalAccessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Enable allocation for subclass reimplementing serialization.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Note: Default allocation does not have the java access priviledges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * to invoke package and protected constructors.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Security alert: this JVM native method is private within ObjectInputStream; however,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *                 it was anticipated that re-implementors of serialization would need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *                 access to this method. Is this allocator considered a security problem?<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @exception IllegalAccessException  TBD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @exception InstantiationException  TBD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   273
    protected final native Object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        allocateNewArray(Class componentClass, int length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        throws InstantiationException, IllegalAccessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Reads the Serializable fields from the stream into a buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * and makes the fields available by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @exception java.lang.ClassNotFoundException if the class of a serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *              object could not be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @exception IOException        if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @exception NotActiveException if readObject() is not currently active.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   286
    public abstract ObjectInputStream.GetField readFields()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        throws IOException, ClassNotFoundException, NotActiveException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   289
    protected abstract boolean enableResolveObject(boolean enable) throws SecurityException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   291
    public abstract void registerValidation(ObjectInputValidation obj,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                            int prio)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        throws NotActiveException, InvalidObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /****************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /* Use DataInput methods to read primitive data from the stream. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   300
    public abstract int read() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   301
    public abstract int read(byte[] data, int offset, int length)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        throws IOException;
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   303
    public abstract boolean readBoolean() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   304
    public abstract byte readByte() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   305
    public abstract int readUnsignedByte()  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   306
    public abstract short readShort()  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   307
    public abstract int readUnsignedShort() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   308
    public abstract char readChar()  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   309
    public abstract int readInt()  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   310
    public abstract long readLong()  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   311
    public abstract float readFloat() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   312
    public abstract double readDouble() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   313
    public abstract void readFully(byte[] data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   314
    public abstract void readFully(byte[] data, int offset, int size) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   315
    public abstract String readUTF() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   316
    public abstract int available() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   317
    public abstract int skipBytes(int len) throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /* @deprecated */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   320
    public abstract String readLine() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
};