jdk/test/java/io/Serializable/subclass/XObjectInputStream.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, 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
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
import java.lang.reflect.Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.lang.reflect.Modifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
class XObjectInputStream extends AbstractObjectInputStream {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    XObjectInputStream(InputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
        throws IOException, StreamCorruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
            super(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
            dis = new DataInputStream(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
    40
    public final void defaultReadObject()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        throws IOException, ClassNotFoundException, NotActiveException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
    45
    protected final Object readObjectOverride()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        throws OptionalDataException, ClassNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        Object readResult = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        Object prevObject = currentObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        Class  prevDesc   = currentClassDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        boolean NotImplemented = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        if (NotImplemented)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            throw new IOException("readObjectOverride not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            currentObject = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            //Read in class of object to currentDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            String className = dis.readUTF();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            currentClassDescriptor = Class.forName(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                //currentObject = Allocate a new instance of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                currentObject =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                    allocateNewObject(currentClassDescriptor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                                   currentClassDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            } catch (InstantiationException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                throw new InvalidClassException(currentClassDescriptor.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                                e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                throw new InvalidClassException(currentClassDescriptor.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                                                e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            //if currentDescriptor.isAssignable(Externalizable.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            //    Object[] argList = {this};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            //    InvokeMethod(currentObject, readExternalMethod, argList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            //} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            //    Does currentDescriptor have a readObject method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            //    if it does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            //        invokeMethod(this, readObjectMethod, {this});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            //    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            //        defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            //}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            // check for replacement on currentObject.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            // if toplevel readobject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            //    doObjectValidations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            readResult = currentObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            currentObject = prevObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        return readResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public ObjectInputStream.GetField readFields()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        throws IOException, ClassNotFoundException, NotActiveException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            throw new Error("not implememted");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public synchronized void registerValidation(ObjectInputValidation obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                                int prio)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        throws NotActiveException, InvalidObjectException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public int read() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return dis.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public int read(byte[] data, int offset, int length) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        return dis.read(data, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public int available() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return in.available();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public boolean readBoolean() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public byte readByte() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public int readUnsignedByte()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public short readShort()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public int readUnsignedShort() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public char readChar()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public int readInt()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public long readLong()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public float readFloat() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public double readDouble() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public void readFully(byte[] data) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public void readFully(byte[] data, int offset, int size) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public int skipBytes(int len) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public String readLine() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public String readUTF() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        throw new IOException("Not Implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**********************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Provide access to the persistent fields read from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     public static class InternalGetField extends ObjectInputStream.GetField {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         * Get the ObjectStreamClass that describes the fields in the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        public ObjectStreamClass getObjectStreamClass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
         * Return true if the named field is defaulted and has no value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
         * in this stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        public boolean defaulted(String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            throws IOException, IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            //ObjectStreamField field = checkField(name, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
         public boolean get(String name, boolean defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
         public char get(String name, char defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
         public byte get(String name, byte defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
         public short get(String name, short defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
         public int get(String name, int defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         public long get(String name, long defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
         public float get(String name, float defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
         public double get(String name, double defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
         public Object get(String name, Object defvalue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
             throws IOException, IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
             throw new Error("not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
         public void read(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
             throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    private Object currentObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    private Class currentClassDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /****************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /* CODE LIFTED FROM ObjectStreamClass constuctor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * ObjectStreamClass.readObjectMethod is private.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * Look for the readObject method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Set the accessible flag on it here. ObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * will call it as necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   259
    public static Method getReadObjectMethod(final Class cl) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        Method readObjectMethod = (Method)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            java.security.AccessController.doPrivileged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            (new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    Method m = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                        Class[] args = {ObjectInputStream.class};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                        m = cl.getDeclaredMethod("readObject", args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                        int mods = m.getModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                        // Method must be private and non-static
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                        if (!Modifier.isPrivate(mods) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                            Modifier.isStatic(mods)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                            m = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                            m.setAccessible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                    } catch (NoSuchMethodException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                        m = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    return m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return readObjectMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /*************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /* taken verbatim from ObjectInputStream. */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 5506
diff changeset
   289
    private static void invokeMethod(final Object obj, final Method m,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                                        final Object[] argList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            java.security.AccessController.doPrivileged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                (new java.security.PrivilegedExceptionAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    public Object run() throws InvocationTargetException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                        java.lang.IllegalAccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                        m.invoke(obj, argList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        } catch (java.security.PrivilegedActionException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            Exception ex = e.getException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            if (ex instanceof InvocationTargetException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                Throwable t =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                        ((InvocationTargetException)ex).getTargetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                if (t instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                    throw (IOException)t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                else if (t instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                    throw (RuntimeException) t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                else if (t instanceof Error)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    throw (Error) t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                    throw new Error("interal error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                // IllegalAccessException cannot happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    protected boolean enableResolveObject(boolean enable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        throw new Error("To be implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    private DataInputStream dis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
};