jdk/test/java/io/Serializable/subclass/AbstractObjectOutputStream.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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.Modifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * This class provides a means for a subclass to re-implement Serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * while preserving the existing public API to Serialization. A complimentary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * subclass of AbstractObjectInputStream must also be implemented to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * deserializa the new implementation.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Since serialization must override java access rules in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * access private, protected and package accessible Serializable fields,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * only trusted classes are allowed to subclass AbstractObjectInputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Subclasses of AbstractObjectOututStream must have SerializablePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * "enableAbstractSubclass" or this constructor will throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * SecurityException.Implementations of this class should protect themselves
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * from being subclassed in a way that will provide access to object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * references and other sensitive info. Specifically, writeObjectOverride()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * should be made final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * A subclass of AbstractObjectOutputStream writes primitive data types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * and graphs of Java objects to an ObjectOutputStream.  The objects can be read
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * (reconstituted) using he complimentary subclass of AbstractObjectInputStream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Persistent storage of objects can be accomplished by using a file for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * the stream. If the stream is a network socket stream, the objects can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * be reconstituted on another host or in another process. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * Only objects that support the java.io.Serializable interface can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * written to streams.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * The method <STRONG>writeObjectOverride</STRONG> is used to write an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * to the stream.  Any object, including Strings and arrays, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * written with writeObject. Multiple objects or primitives can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * written to the stream.  The objects must be read back from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * corresponding subclass of AbstractObjectInputstream with the same types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * and in the same order as they were written.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * Primitive data types can also be written to the stream using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * appropriate methods from DataOutput. Strings can also be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * using the writeUTF method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * The default serialization mechanism for an object is defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * defaultWriteObject(). References to other objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * (except in transient or static fields) cause those objects to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * written also. Multiple references to a single object are encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * using a reference sharing mechanism so that graphs of objects can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * be restored to the same shape as when the original was written. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * Classes that require special handling during the serialization and deserialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * process must implement special methods with these exact signatures: <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * private void readObject(java.io.ObjectInputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *     throws IOException, ClassNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * private void writeObject(java.io.ObjectOutputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *     throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * </PRE><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * The writeObject method is responsible for writing the state of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * the object for its particular class so that the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * readObject method can restore it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * The method does not need to concern itself with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * state belonging to the object's superclasses or subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * State is saved by writing the individual fields to the ObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * using the writeObject method or by using the methods for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * primitive data types supported by DataOutput. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * Serialization does not write out the fields of any object that does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * not implement the java.io.Serializable interface.  Subclasses of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * Objects that are not serializable can be serialized. In this case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * the non-serializable class must have a no-arg constructor to allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * its fields to be initialized.  In this case it is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * responsibility of the subclass to save and restore the state of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * non-serializable class. It is frequently the case that the fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * of that class are accessible (public, package, or protected) or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * that there are get and set methods that can be used to restore the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * state. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * Serialization of an object can be prevented by implementing writeObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * and readObject methods that throw the NotSerializableException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * The exception will be caught by the ObjectOutputStream and abort the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * serialization process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * Implementing the Externalizable interface allows the object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * assume complete control over the contents and format of the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * serialized form.  The methods of the Externalizable interface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * writeExternal and readExternal, are called to save and restore the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * objects state.  When implemented by a class they can write and read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * their own state using all of the methods of ObjectOutput and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * ObjectInput.  It is the responsibility of the objects to handle any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * versioning that occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * @author      Joe Fialli
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * @see java.io.ObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * @see java.io.DataOutput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * @see java.io.Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * @see java.io.Externalizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * @see java.io.Replaceable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * @see java.io.ext.AbstractObjectInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @since       JDK1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   137
public abstract class AbstractObjectOutputStream extends ObjectOutputStream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected OutputStream out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /* Stream Management Methods. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Creates an ObjectOutputStream that writes to the specified OutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Add the following line to the security policy file to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * subclassing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *     permission SerializablePermission "enableAbstractSubclass" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * </PRE><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @exception IOException Any exception thrown by the underlying OutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see java.io.ObjectOutputStream#writeStreamHeader()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public AbstractObjectOutputStream(OutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        this.out = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   159
    public abstract void reset() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   160
    protected abstract void drain() throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   161
    public abstract void close() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /*******************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /* Write Objects to Stream */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Write the specified object to a subclass of AbstractObjectOutputStream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * NOTE: The override method of this class should have the modifier final.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Default serialization for a class can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * overridden by defining writeObject and the readObject methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * for the Serializable class. Objects referenced by this object are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * written transitively so that a complete equivalent graph of objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * can be reconstructed by an ObjectInputStream.  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * This method must implement the substitution semantics on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * object to be written, write Externalizable objects with its classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * override of writeExternal, and it must call annotateClass when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * writing an ObjectStreamClass to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Exceptions can be thrown for problems with the OutputStream and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * for classes that should not be serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * For security's sake, any overrides of this method should be final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Serialization typically needs to disable java access rules
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * to serialize private, protected and package accessible Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * fields. This method gets called for ALL Serializable objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @exception InvalidClassException Something is wrong with a class used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *     serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @exception NotSerializableException Some object to be serialized does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *    implement the java.io.Serializable interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @exception IOException Any exception thrown by the underlying OutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @see java.io.Externalizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see java.io.ObjectOutputStream#replaceObject(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @see java.io.Replaceable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @see java.io.ObjectOutputStream#annotateClass(Class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    protected void writeObjectOverride(Object obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Write the Serializable fields of the current object to this stream.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Note: The object being serialized is not passed to this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *       For security purposes, the initial implementation maintained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *       the state of the last object to be passed to writeObject and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *       only allowed this method to be invoked for this object.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @exception NotActiveException  Thrown if a writeObject method is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *                                active.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   217
    public abstract void defaultWriteObject() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /*************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /* Use the methods of PutField to map between Serializable fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * and actual fields of a Serializable class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   224
    public abstract ObjectOutputStream.PutField putFields() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Note: The PutField being serialized is not passed to this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *       For security purposes, the initial implementation maintained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *       the state of the last putFields call and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *       only allowed this method to be invoked for that PutFields object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   232
    public abstract void writeFields() throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   234
    protected abstract boolean enableReplaceObject(boolean enable) throws SecurityException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /*******************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /* Write Primitive Data to stream.  DataOutput methods. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   239
    public abstract void write(int data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   240
    public abstract void write(byte b[]) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   241
    public abstract void write(byte b[], int off, int len) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   242
    public abstract void writeBoolean(boolean data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   243
    public abstract void writeByte(int data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   244
    public abstract void writeShort(int data)  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   245
    public abstract void writeChar(int data)  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   246
    public abstract void writeInt(int data)  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   247
    public abstract void writeLong(long data)  throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   248
    public abstract void writeFloat(float data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   249
    public abstract void writeDouble(double data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   250
    public abstract void writeBytes(String data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   251
    public abstract void writeChars(String data) throws IOException;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   252
    public abstract void writeUTF(String data) throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
};