FileDocCategorySizeDatePackage
ObjectInputStream.javaAPI DocJava SE 5 API108530Fri Aug 26 14:57:00 BST 2005java.io

ObjectInputStream

public class ObjectInputStream extends InputStream implements ObjectStreamConstants, ObjectInput
An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.

ObjectOutputStream and ObjectInputStream can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. ObjectInputStream is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.

ObjectInputStream ensures that the types of all objects in the graph created from the stream match the classes present in the Java Virtual Machine. Classes are loaded as required using the standard mechanisms.

Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.

The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. In Java, strings and arrays are objects and are treated as objects during serialization. When read they need to be cast to the expected type.

Primitive data types can be read from the stream using the appropriate method on DataInput.

The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. Fields declared as transient or static are ignored by the deserialization process. References to other objects cause those objects to be read from the stream as necessary. Graphs of objects are restored correctly using a reference sharing mechanism. New objects are always allocated when deserializing, which prevents existing objects from being overwritten.

Reading an object is analogous to running the constructors of a new object. Memory is allocated for the object and initialized to zero (NULL). No-arg constructors are invoked for the non-serializable classes and then the fields of the serializable classes are restored from the stream starting with the serializable class closest to java.lang.object and finishing with the object's most specific class.

For example to read from a stream as written by the example in ObjectOutputStream:

FileInputStream fis = new FileInputStream("t.tmp");
ObjectInputStream ois = new ObjectInputStream(fis);

int i = ois.readInt();
String today = (String) ois.readObject();
Date date = (Date) ois.readObject();

ois.close();

Classes control how they are serialized by implementing either the java.io.Serializable or java.io.Externalizable interfaces.

Implementing the Serializable interface allows object serialization to save and restore the entire state of the object and it allows classes to evolve between the time the stream is written and the time it is read. It automatically traverses references between objects, saving and restoring entire graphs.

Serializable classes that require special handling during the serialization and deserialization process should implement the following methods:

private void writeObject(java.io.ObjectOutputStream stream)
throws IOException;
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException;
private void readObjectNoData()
throws ObjectStreamException;

The readObject method is responsible for reading and restoring the state of the object for its particular class using data written to the stream by the corresponding writeObject method. The method does not need to concern itself with the state belonging to its superclasses or subclasses. State is restored by reading data from the ObjectInputStream for the individual fields and making assignments to the appropriate fields of the object. Reading primitive data types is supported by DataInput.

Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true. Non-object reads which exceed the end of the allotted data will reflect the end of data in the same way that they would indicate the end of the stream: bytewise reads will return -1 as the byte read or number of bytes read, and primitive reads will throw EOFExceptions. If there is no corresponding writeObject method, then the end of default serialized data marks the end of the allotted data.

Primitive and object read calls issued from within a readExternal method behave in the same manner--if the stream is already positioned at the end of data written by the corresponding writeExternal method, object reads will throw OptionalDataExceptions with eof set to true, bytewise reads will return -1, and primitive reads will throw EOFExceptions. Note that this behavior does not hold for streams written with the old ObjectStreamConstants.PROTOCOL_VERSION_1 protocol, in which the end of data written by writeExternal methods is not demarcated, and hence cannot be detected.

The readObjectNoData method is responsible for initializing the state of the object for its particular class in the event that the serialization stream does not list the given class as a superclass of the object being deserialized. This may occur in cases where the receiving party uses a different version of the deserialized instance's class than the sending party, and the receiver's version extends classes that are not extended by the sender's version. This may also occur if the serialization stream has been tampered; hence, readObjectNoData is useful for initializing deserialized objects properly despite a "hostile" or incomplete source stream.

Serialization does not read or assign values to the fields of any object that does not implement the java.io.Serializable interface. Subclasses of Objects that are not serializable can be serializable. In this case the non-serializable class must have a no-arg constructor to allow its fields to be initialized. In this case it is the responsibility of the subclass to save and restore the state of the non-serializable class. It is frequently the case that the fields of that class are accessible (public, package, or protected) or that there are get and set methods that can be used to restore the state.

Any exception that occurs while deserializing an object will be caught by the ObjectInputStream and abort the reading process.

Implementing the Externalizable interface allows the object to assume complete control over the contents and format of the object's serialized form. The methods of the Externalizable interface, writeExternal and readExternal, are called to save and restore the objects state. When implemented by a class they can write and read their own state using all of the methods of ObjectOutput and ObjectInput. It is the responsibility of the objects to handle any versioning that occurs.

Enum constants are deserialized differently than ordinary serializable or externalizable objects. The serialized form of an enum constant consists solely of its name; field values of the constant are not transmitted. To deserialize an enum constant, ObjectInputStream reads the constant name from the stream; the deserialized constant is then obtained by calling the static method Enum.valueOf(Class, String) with the enum constant's base type and the received constant name as arguments. Like other serializable or externalizable objects, enum constants can function as the targets of back references appearing subsequently in the serialization stream. The process by which enum constants are deserialized cannot be customized: any class-specific readObject, readObjectNoData, and readResolve methods defined by enum types are ignored during deserialization. Similarly, any serialPersistentFields or serialVersionUID field declarations are also ignored--all enum types have a fixed serialVersionUID of 0L.

author
Mike Warres
author
Roger Riggs
version
1.155, 04/05/28
see
java.io.DataInput
see
java.io.ObjectOutputStream
see
java.io.Serializable
see
Object Serialization Specification, Section 3, Object Input Classes
since
JDK1.1

Fields Summary
private static final int
NULL_HANDLE
handle value representing null
private static final Object
unsharedMarker
marker for unshared objects in internal handle table
private static final HashMap
primClasses
table mapping primitive type names to corresponding class objects
private static final sun.misc.SoftCache
subclassAudits
cache of subclass security audit results
private final BlockDataInputStream
bin
filter stream for handling block data conversion
private final ValidationList
vlist
validation callback list
private int
depth
recursion depth
private boolean
closed
whether stream is closed
private final HandleTable
handles
wire handle -> obj/exception map
private int
passHandle
scratch field for passing handle values up/down call stack
private boolean
defaultDataEnd
flag set when at end of field value block with no TC_ENDBLOCKDATA
private byte[]
primVals
buffer for reading primitive field values
private final boolean
enableOverride
if true, invoke readObjectOverride() instead of readObject()
private boolean
enableResolve
if true, invoke resolveObject()
private Object
curObj
object currently being deserialized
private ObjectStreamClass
curDesc
descriptor for current class (null if in readExternal())
private GetFieldImpl
curGet
current GetField object
Constructors Summary
public ObjectInputStream(InputStream in)
Creates an ObjectInputStream that reads from the specified InputStream. A serialization stream header is read from the stream and verified. This constructor will block until the corresponding ObjectOutputStream has written and flushed the header.

If a security manager is installed, this constructor will check for the "enableSubclassImplementation" SerializablePermission when invoked directly or indirectly by the constructor of a subclass which overrides the ObjectInputStream.readFields or ObjectInputStream.readUnshared methods.

param
in input stream to read from
throws
StreamCorruptedException if the stream header is incorrect
throws
IOException if an I/O error occurs while reading stream header
throws
SecurityException if untrusted subclass illegally overrides security-sensitive methods
throws
NullPointerException if in is null
see
ObjectInputStream#ObjectInputStream()
see
ObjectInputStream#readFields()
see
ObjectOutputStream#ObjectOutputStream(OutputStream)



                                                                       	      	       	          	      		  	     	 	 	     
         
	verifySubclass();
	bin = new BlockDataInputStream(in);
	handles = new HandleTable(10);
	vlist = new ValidationList();
	enableOverride = false;
	readStreamHeader();
	bin.setBlockDataMode(true);
    
protected ObjectInputStream()
Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.

If there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubclassImplementation") permission to ensure it's ok to enable subclassing.

throws
SecurityException if a security manager exists and its checkPermission method denies enabling subclassing.
see
SecurityManager#checkPermission
see
java.io.SerializablePermission

	SecurityManager sm = System.getSecurityManager();
	if (sm != null) {
	    sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
	}
	bin = null;
	handles = null;
	vlist = null;
	enableOverride = true;
    
Methods Summary
private static booleanauditSubclass(java.lang.Class subcl)
Performs reflective checks on given subclass to verify that it doesn't override security-sensitive non-final methods. Returns true if subclass is "safe", false otherwise.

	Boolean result = (Boolean) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
		    for (Class cl = subcl;
			 cl != ObjectInputStream.class;
			 cl = cl.getSuperclass())
		    {
			try {
			    cl.getDeclaredMethod("readUnshared", new Class[0]);
			    return Boolean.FALSE;
			} catch (NoSuchMethodException ex) {
			}
			try {
			    cl.getDeclaredMethod("readFields", new Class[0]);
			    return Boolean.FALSE;
			} catch (NoSuchMethodException ex) {
			}
		    }
		    return Boolean.TRUE;
		}
	    }
	);
	return result.booleanValue();
    
public intavailable()
Returns the number of bytes that can be read without blocking.

return
the number of available bytes.
throws
IOException if there are I/O errors while reading from the underlying InputStream

	return bin.available();
    
private static native voidbytesToDoubles(byte[] src, int srcpos, double[] dst, int dstpos, int ndoubles)
Converts specified span of bytes into double values.

private static native voidbytesToFloats(byte[] src, int srcpos, float[] dst, int dstpos, int nfloats)
Converts specified span of bytes into float values.

private java.lang.ObjectcheckResolve(java.lang.Object obj)
If resolveObject has been enabled and given object does not have an exception associated with it, calls resolveObject to determine replacement for object, and updates handle table accordingly. Returns replacement object, or echoes provided object if no replacement occurred. Expects that passHandle is set to given object's handle prior to calling this method.

	if (!enableResolve || handles.lookupException(passHandle) != null) {
	    return obj;
	}
	Object rep = resolveObject(obj);
	if (rep != obj) {
	    handles.setObject(passHandle, rep);
	}
	return rep;
    
private voidclear()
Clears internal data structures.

	handles.clear();
	vlist.clear();
    
public voidclose()
Closes the input stream. Must be called to release any resources associated with the stream.

throws
IOException If an I/O error has occurred.

	/*
	 * Even if stream already closed, propagate redundant close to
	 * underlying stream to stay consistent with previous implementations.
	 */
	closed = true;
	if (depth == 0) {
	    clear();
	}
	bin.close();
    
private voiddefaultReadFields(java.lang.Object obj, java.io.ObjectStreamClass desc)
Reads in values of serializable fields declared by given class descriptor. If obj is non-null, sets field values in obj. Expects that passHandle is set to obj's handle before this method is called.

	// REMIND: is isInstance check necessary?
	Class cl = desc.forClass();
	if (cl != null && obj != null && !cl.isInstance(obj)) {
	    throw new ClassCastException();
	}

	int primDataSize = desc.getPrimDataSize();
	if (primVals == null || primVals.length < primDataSize) {
	    primVals = new byte[primDataSize];
	}
	bin.readFully(primVals, 0, primDataSize, false);
	if (obj != null) {
	    desc.setPrimFieldValues(obj, primVals);
	}
	
	int objHandle = passHandle;
	ObjectStreamField[] fields = desc.getFields(false);
	Object[] objVals = new Object[desc.getNumObjFields()];
	int numPrimFields = fields.length - objVals.length;
	for (int i = 0; i < objVals.length; i++) {
	    ObjectStreamField f = fields[numPrimFields + i];
	    objVals[i] = readObject0(f.isUnshared());
	    if (f.getField() != null) {
		handles.markDependency(objHandle, passHandle);
	    }
	}
	if (obj != null) {
	    desc.setObjFieldValues(obj, objVals);
	}
	passHandle = objHandle;
    
public voiddefaultReadObject()
Read the non-static and non-transient fields of the current class from this stream. This may only be called from the readObject method of the class being deserialized. It will throw the NotActiveException if it is called otherwise.

throws
ClassNotFoundException if the class of a serialized object could not be found.
throws
IOException if an I/O error occurs.
throws
NotActiveException if the stream is not currently reading objects.

	if (curObj == null || curDesc == null) {
	    throw new NotActiveException("not in call to readObject");
	}
	bin.setBlockDataMode(false);
	defaultReadFields(curObj, curDesc);
	bin.setBlockDataMode(true);
	if (!curDesc.hasWriteObjectData()) {
	    /*
	     * Fix for 4360508: since stream does not contain terminating
	     * TC_ENDBLOCKDATA tag, set flag so that reading code elsewhere
	     * knows to simulate end-of-custom-data behavior.
	     */
	    defaultDataEnd = true;
	}
	ClassNotFoundException ex = handles.lookupException(passHandle);
	if (ex != null) {
	    throw ex;
	}
    
protected booleanenableResolveObject(boolean enable)
Enable the stream to allow objects read from the stream to be replaced. When enabled, the resolveObject method is called for every object being deserialized.

If enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure it's ok to enable the stream to allow objects read from the stream to be replaced.

param
enable true for enabling use of resolveObject for every object being deserialized
return
the previous setting before this method was invoked
throws
SecurityException if a security manager exists and its checkPermission method denies enabling the stream to allow objects read from the stream to be replaced.
see
SecurityManager#checkPermission
see
java.io.SerializablePermission

	if (enable == enableResolve) {
	    return enable;
	}
	if (enable) {
	    SecurityManager sm = System.getSecurityManager();
	    if (sm != null) {
		sm.checkPermission(SUBSTITUTION_PERMISSION);
	    }
	}
	enableResolve = enable;
	return !enableResolve;
    
private voidhandleReset()
If recursion depth is 0, clears internal data structures; otherwise, throws a StreamCorruptedException. This method is called when a TC_RESET typecode is encountered.

	if (depth > 0) {
	    throw new StreamCorruptedException("unexpected reset");
	}
	clear();
    
private static native java.lang.ClassLoaderlatestUserDefinedLoader()
Returns the first non-null class loader (not counting class loaders of generated reflection implementation classes) up the execution stack, or null if only code from the null class loader is on the stack. This method is also called via reflection by the following RMI-IIOP class: com.sun.corba.se.internal.util.JDKClassLoader This method should not be removed or its signature changed without corresponding modifications to the above class.

public intread()
Reads a byte of data. This method will block if no input is available.

return
the byte read, or -1 if the end of the stream is reached.
throws
IOException If an I/O error has occurred.

	return bin.read();
    
public intread(byte[] buf, int off, int len)
Reads into an array of bytes. This method will block until some input is available. Consider using java.io.DataInputStream.readFully to read exactly 'length' bytes.

param
buf the buffer into which the data is read
param
off the start offset of the data
param
len the maximum number of bytes read
return
the actual number of bytes read, -1 is returned when the end of the stream is reached.
throws
IOException If an I/O error has occurred.
see
java.io.DataInputStream#readFully(byte[],int,int)

	if (buf == null) {
	    throw new NullPointerException();
	}
	int endoff = off + len;
	if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
	    throw new IndexOutOfBoundsException();
	}
	return bin.read(buf, off, len, false);
    
private java.lang.ObjectreadArray(boolean unshared)
Reads in and returns array object, or null if array class is unresolvable. Sets passHandle to array's assigned handle.

	if (bin.readByte() != TC_ARRAY) {
	    throw new StreamCorruptedException();
	}

	ObjectStreamClass desc = readClassDesc(false);
	int len = bin.readInt();
	
	Object array = null;
	Class cl, ccl = null;
	if ((cl = desc.forClass()) != null) {
	    ccl = cl.getComponentType();
	    array = Array.newInstance(ccl, len);
	}

	int arrayHandle = handles.assign(unshared ? unsharedMarker : array);
	ClassNotFoundException resolveEx = desc.getResolveException();
	if (resolveEx != null) {
	    handles.markException(arrayHandle, resolveEx);
	}
	
	if (ccl == null) {
	    for (int i = 0; i < len; i++) {
		readObject0(false);
	    }
	} else if (ccl.isPrimitive()) {
	    if (ccl == Integer.TYPE) {
		bin.readInts((int[]) array, 0, len);
	    } else if (ccl == Byte.TYPE) {
		bin.readFully((byte[]) array, 0, len, true);
	    } else if (ccl == Long.TYPE) {
		bin.readLongs((long[]) array, 0, len);
	    } else if (ccl == Float.TYPE) {
		bin.readFloats((float[]) array, 0, len);
	    } else if (ccl == Double.TYPE) {
		bin.readDoubles((double[]) array, 0, len);
	    } else if (ccl == Short.TYPE) {
		bin.readShorts((short[]) array, 0, len);
	    } else if (ccl == Character.TYPE) {
		bin.readChars((char[]) array, 0, len);
	    } else if (ccl == Boolean.TYPE) {
		bin.readBooleans((boolean[]) array, 0, len);
	    } else {
		throw new InternalError();
	    }
	} else {
	    Object[] oa = (Object[]) array;
	    for (int i = 0; i < len; i++) {
		oa[i] = readObject0(false);
		handles.markDependency(arrayHandle, passHandle);
	    }
	}
	
	handles.finish(arrayHandle);
	passHandle = arrayHandle;
	return array;
    
public booleanreadBoolean()
Reads in a boolean.

return
the boolean read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readBoolean();
    
public bytereadByte()
Reads an 8 bit byte.

return
the 8 bit byte read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readByte();
    
public charreadChar()
Reads a 16 bit char.

return
the 16 bit char read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readChar();
    
private java.lang.ClassreadClass(boolean unshared)
Reads in and returns class object. Sets passHandle to class object's assigned handle. Returns null if class is unresolvable (in which case a ClassNotFoundException will be associated with the class' handle in the handle table).

	if (bin.readByte() != TC_CLASS) {
	    throw new StreamCorruptedException();
	}
	ObjectStreamClass desc = readClassDesc(false);
	Class cl = desc.forClass();
	passHandle = handles.assign(unshared ? unsharedMarker : cl);

	ClassNotFoundException resolveEx = desc.getResolveException();
	if (resolveEx != null) {
	    handles.markException(passHandle, resolveEx);
	}

	handles.finish(passHandle);
	return cl;
    
private java.io.ObjectStreamClassreadClassDesc(boolean unshared)
Reads in and returns (possibly null) class descriptor. Sets passHandle to class descriptor's assigned handle. If class descriptor cannot be resolved to a class in the local VM, a ClassNotFoundException is associated with the class descriptor's handle.

	switch (bin.peekByte()) {
	    case TC_NULL:
		return (ObjectStreamClass) readNull();

	    case TC_REFERENCE:
		return (ObjectStreamClass) readHandle(unshared);

	    case TC_PROXYCLASSDESC:
		return readProxyDesc(unshared);

	    case TC_CLASSDESC:
		return readNonProxyDesc(unshared);
		
	    default:
		throw new StreamCorruptedException();
	}
    
protected java.io.ObjectStreamClassreadClassDescriptor()
Read a class descriptor from the serialization stream. This method is called when the ObjectInputStream expects a class descriptor as the next item in the serialization stream. Subclasses of ObjectInputStream may override this method to read in class descriptors that have been written in non-standard formats (by subclasses of ObjectOutputStream which have overridden the writeClassDescriptor method). By default, this method reads class descriptors according to the format defined in the Object Serialization specification.

return
the class descriptor read
throws
IOException If an I/O error has occurred.
throws
ClassNotFoundException If the Class of a serialized object used in the class descriptor representation cannot be found
see
java.io.ObjectOutputStream#writeClassDescriptor(java.io.ObjectStreamClass)
since
1.3

	ObjectStreamClass desc = new ObjectStreamClass();
	desc.readNonProxy(this);
	return desc;
    
public doublereadDouble()
Reads a 64 bit double.

return
the 64 bit double read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readDouble();
    
private java.lang.EnumreadEnum(boolean unshared)
Reads in and returns enum constant, or null if enum type is unresolvable. Sets passHandle to enum constant's assigned handle.

	if (bin.readByte() != TC_ENUM) {
	    throw new StreamCorruptedException();
	}

	ObjectStreamClass desc = readClassDesc(false);
	if (!desc.isEnum()) {
	    throw new InvalidClassException("non-enum class: " + desc);
	}

	int enumHandle = handles.assign(unshared ? unsharedMarker : null);
	ClassNotFoundException resolveEx = desc.getResolveException();
	if (resolveEx != null) {
	    handles.markException(enumHandle, resolveEx);
	}

	String name = readString(false);
	Enum en = null;
	Class cl = desc.forClass();
	if (cl != null) {
	    try {
		en = Enum.valueOf(cl, name);
	    } catch (IllegalArgumentException ex) {
		throw (IOException) new InvalidObjectException(
		    "enum constant " + name + " does not exist in " +
		    cl).initCause(ex);
	    }
	    if (!unshared) {
		handles.setObject(enumHandle, en);
	    }
	}

	handles.finish(enumHandle);
	passHandle = enumHandle;
	return en;
    
private voidreadExternalData(java.io.Externalizable obj, java.io.ObjectStreamClass desc)
If obj is non-null, reads externalizable data by invoking readExternal() method of obj; otherwise, attempts to skip over externalizable data. Expects that passHandle is set to obj's handle before this method is called.

	Object oldObj = curObj;
	ObjectStreamClass oldDesc = curDesc;
	GetFieldImpl oldGet = curGet;
	curObj = obj;
	curDesc = null;
	curGet = null;

	boolean blocked = desc.hasBlockExternalData();
	if (blocked) {
	    bin.setBlockDataMode(true);
	}
	if (obj != null) {
	    try {
		obj.readExternal(this);
	    } catch (ClassNotFoundException ex) {
		/*
		 * In most cases, the handle table has already propagated a
		 * CNFException to passHandle at this point; this mark call is
		 * included to address cases where the readExternal method has
		 * cons'ed and thrown a new CNFException of its own.
		 */
		handles.markException(passHandle, ex);
	    }
	}
	if (blocked) {
	    skipCustomData();
	}
	
	/*
	 * At this point, if the externalizable data was not written in
	 * block-data form and either the externalizable class doesn't exist
	 * locally (i.e., obj == null) or readExternal() just threw a
	 * CNFException, then the stream is probably in an inconsistent state,
	 * since some (or all) of the externalizable data may not have been
	 * consumed.  Since there's no "correct" action to take in this case,
	 * we mimic the behavior of past serialization implementations and
	 * blindly hope that the stream is in sync; if it isn't and additional
	 * externalizable data remains in the stream, a subsequent read will
	 * most likely throw a StreamCorruptedException.
	 */
	
	curObj = oldObj;
	curDesc = oldDesc;
	curGet = oldGet;
    
private java.io.IOExceptionreadFatalException()
Reads in and returns IOException that caused serialization to abort. All stream state is discarded prior to reading in fatal exception. Sets passHandle to fatal exception's handle.

	if (bin.readByte() != TC_EXCEPTION) {
	    throw new StreamCorruptedException();
	}
	clear();
	return (IOException) readObject0(false);
    
public java.io.ObjectInputStream$GetFieldreadFields()
Reads the persistent fields from the stream and makes them available by name.

return
the GetField object representing the persistent fields of the object being deserialized
throws
ClassNotFoundException if the class of a serialized object could not be found.
throws
IOException if an I/O error occurs.
throws
NotActiveException if the stream is not currently reading objects.
since
1.2

	if (curGet == null) {
	    if (curObj == null || curDesc == null) {
		throw new NotActiveException("not in call to readObject");
	    }
	    curGet = new GetFieldImpl(curDesc);
	}
	bin.setBlockDataMode(false);
	curGet.readFields();
	bin.setBlockDataMode(true);
	if (!curDesc.hasWriteObjectData()) {
	    /*
	     * Fix for 4360508: since stream does not contain terminating
	     * TC_ENDBLOCKDATA tag, set flag so that reading code elsewhere
	     * knows to simulate end-of-custom-data behavior.
	     */
	    defaultDataEnd = true;
	}

	return curGet;
    
public floatreadFloat()
Reads a 32 bit float.

return
the 32 bit float read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readFloat();
    
public voidreadFully(byte[] buf)
Reads bytes, blocking until all bytes are read.

param
buf the buffer into which the data is read
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	bin.readFully(buf, 0, buf.length, false);
    
public voidreadFully(byte[] buf, int off, int len)
Reads bytes, blocking until all bytes are read.

param
buf the buffer into which the data is read
param
off the start offset of the data
param
len the maximum number of bytes to read
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	int endoff = off + len;
	if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
	    throw new IndexOutOfBoundsException();
	}
	bin.readFully(buf, off, len, false);
    
private java.lang.ObjectreadHandle(boolean unshared)
Reads in object handle, sets passHandle to the read handle, and returns object associated with the handle.

	if (bin.readByte() != TC_REFERENCE) {
	    throw new StreamCorruptedException();
	}
	passHandle = bin.readInt() - baseWireHandle;
	if (passHandle < 0 || passHandle >= handles.size()) {
	    throw new StreamCorruptedException("illegal handle value");
	}
	if (unshared) {
	    // REMIND: what type of exception to throw here?
	    throw new InvalidObjectException(
		"cannot read back reference as unshared");
	}
	
	Object obj = handles.lookupObject(passHandle);
	if (obj == unsharedMarker) {
	    // REMIND: what type of exception to throw here?
	    throw new InvalidObjectException(
		"cannot read back reference to unshared object");
	}
	return obj;
    
public intreadInt()
Reads a 32 bit int.

return
the 32 bit integer read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readInt();
    
public java.lang.StringreadLine()
Reads in a line that has been terminated by a \n, \r, \r\n or EOF.

return
a String copy of the line.
throws
IOException if there are I/O errors while reading from the underlying InputStream
deprecated
This method does not properly convert bytes to characters. see DataInputStream for the details and alternatives.

	return bin.readLine();
    
public longreadLong()
Reads a 64 bit long.

return
the read 64 bit long.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readLong();
    
private java.io.ObjectStreamClassreadNonProxyDesc(boolean unshared)
Reads in and returns class descriptor for a class that is not a dynamic proxy class. Sets passHandle to class descriptor's assigned handle. If class descriptor cannot be resolved to a class in the local VM, a ClassNotFoundException is associated with the descriptor's handle.

	if (bin.readByte() != TC_CLASSDESC) {
	    throw new StreamCorruptedException();
	}
	
	ObjectStreamClass desc = new ObjectStreamClass();
	int descHandle = handles.assign(unshared ? unsharedMarker : desc);
	passHandle = NULL_HANDLE;

	ObjectStreamClass readDesc = null;
	try {
	    readDesc = readClassDescriptor();
	} catch (ClassNotFoundException ex) {
	    throw (IOException) new InvalidClassException(
		"failed to read class descriptor").initCause(ex);
	}
	
	Class cl = null;
	ClassNotFoundException resolveEx = null;
	bin.setBlockDataMode(true);
	try {
	    if ((cl = resolveClass(readDesc)) == null) {
		throw new ClassNotFoundException("null class");
	    }
	} catch (ClassNotFoundException ex) {
	    resolveEx = ex;
	}
	skipCustomData();
	
	desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));

	handles.finish(descHandle);
	passHandle = descHandle;
	return desc;
    
private java.lang.ObjectreadNull()
Reads in null code, sets passHandle to NULL_HANDLE and returns null.

	if (bin.readByte() != TC_NULL) {
	    throw new StreamCorruptedException();
	}
	passHandle = NULL_HANDLE;
	return null;
    
public final java.lang.ObjectreadObject()
Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overriden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completely restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they are individually restored.

Exceptions are thrown for problems with the InputStream and for classes that should not be deserialized. All exceptions are fatal to the InputStream and leave it in an indeterminate state; it is up to the caller to ignore or recover the stream state.

throws
ClassNotFoundException Class of a serialized object cannot be found.
throws
InvalidClassException Something is wrong with a class used by serialization.
throws
StreamCorruptedException Control information in the stream is inconsistent.
throws
OptionalDataException Primitive data was found in the stream instead of objects.
throws
IOException Any of the usual Input/Output related exceptions.

	if (enableOverride) {
	    return readObjectOverride();
	}

	// if nested read, passHandle contains handle of enclosing object
	int outerHandle = passHandle;
	try {
	    Object obj = readObject0(false);
	    handles.markDependency(outerHandle, passHandle);
	    ClassNotFoundException ex = handles.lookupException(passHandle);
	    if (ex != null) {
		throw ex;
	    }
	    if (depth == 0) {
		vlist.doCallbacks();
	    }
	    return obj;
	} finally {
	    passHandle = outerHandle;
	    if (closed && depth == 0) {
		clear();
	    }
	}
    
private java.lang.ObjectreadObject0(boolean unshared)
Underlying readObject implementation.

	boolean oldMode = bin.getBlockDataMode();
	if (oldMode) {
	    int remain = bin.currentBlockRemaining();
	    if (remain > 0) {
		throw new OptionalDataException(remain);
	    } else if (defaultDataEnd) {
		/*
		 * Fix for 4360508: stream is currently at the end of a field
		 * value block written via default serialization; since there
		 * is no terminating TC_ENDBLOCKDATA tag, simulate
		 * end-of-custom-data behavior explicitly.
		 */
		throw new OptionalDataException(true);
	    }
	    bin.setBlockDataMode(false);
	}
	
	byte tc;
	while ((tc = bin.peekByte()) == TC_RESET) {
	    bin.readByte();
	    handleReset();
	}

	depth++;
	try {
	    switch (tc) {
		case TC_NULL:
		    return readNull();

		case TC_REFERENCE:
		    return readHandle(unshared);

		case TC_CLASS:
		    return readClass(unshared);

		case TC_CLASSDESC:
		case TC_PROXYCLASSDESC:
		    return readClassDesc(unshared);

		case TC_STRING:
		case TC_LONGSTRING:
		    return checkResolve(readString(unshared));

		case TC_ARRAY:
		    return checkResolve(readArray(unshared));

		case TC_ENUM:
		    return checkResolve(readEnum(unshared));

		case TC_OBJECT:
		    return checkResolve(readOrdinaryObject(unshared));

		case TC_EXCEPTION:
		    IOException ex = readFatalException();
		    throw new WriteAbortedException("writing aborted", ex);

		case TC_BLOCKDATA:
		case TC_BLOCKDATALONG:
		    if (oldMode) {
			bin.setBlockDataMode(true);
			bin.peek();		// force header read
			throw new OptionalDataException(
			    bin.currentBlockRemaining());
		    } else {
			throw new StreamCorruptedException(
			    "unexpected block data");
		    }
		    
		case TC_ENDBLOCKDATA:
		    if (oldMode) {
			throw new OptionalDataException(true);
		    } else {
			throw new StreamCorruptedException(
			    "unexpected end of block data");
		    }

		default:
		    throw new StreamCorruptedException();
	    }
	} finally {
	    depth--;
	    bin.setBlockDataMode(oldMode);
	}
    
protected java.lang.ObjectreadObjectOverride()
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final".

return
the Object read from the stream.
throws
ClassNotFoundException Class definition of a serialized object cannot be found.
throws
OptionalDataException Primitive data was found in the stream instead of objects.
throws
IOException if I/O errors occurred while reading from the underlying stream
see
#ObjectInputStream()
see
#readObject()
since
1.2

	return null;
    
private java.lang.ObjectreadOrdinaryObject(boolean unshared)
Reads and returns "ordinary" (i.e., not a String, Class, ObjectStreamClass, array, or enum constant) object, or null if object's class is unresolvable (in which case a ClassNotFoundException will be associated with object's handle). Sets passHandle to object's assigned handle.

	if (bin.readByte() != TC_OBJECT) {
	    throw new StreamCorruptedException();
	}

	ObjectStreamClass desc = readClassDesc(false);
	desc.checkDeserialize();

	Object obj;
	try {
	    obj = desc.isInstantiable() ? desc.newInstance() : null;
	} catch (Exception ex) {
	    throw new InvalidClassException(
		desc.forClass().getName(), "unable to create instance");
	}

	passHandle = handles.assign(unshared ? unsharedMarker : obj);
	ClassNotFoundException resolveEx = desc.getResolveException();
	if (resolveEx != null) {
	    handles.markException(passHandle, resolveEx);
	}
	
	if (desc.isExternalizable()) {
	    readExternalData((Externalizable) obj, desc);
	} else {
	    readSerialData(obj, desc);
	}

	handles.finish(passHandle);
	
	if (obj != null && 
	    handles.lookupException(passHandle) == null &&
	    desc.hasReadResolveMethod())
	{
	    Object rep = desc.invokeReadResolve(obj);
	    if (rep != obj) {
		handles.setObject(passHandle, obj = rep);
	    }
	}

	return obj;
    
private java.io.ObjectStreamClassreadProxyDesc(boolean unshared)
Reads in and returns class descriptor for a dynamic proxy class. Sets passHandle to proxy class descriptor's assigned handle. If proxy class descriptor cannot be resolved to a class in the local VM, a ClassNotFoundException is associated with the descriptor's handle.

	if (bin.readByte() != TC_PROXYCLASSDESC) {
	    throw new StreamCorruptedException();
	}
	
	ObjectStreamClass desc = new ObjectStreamClass();
	int descHandle = handles.assign(unshared ? unsharedMarker : desc);
	passHandle = NULL_HANDLE;
	
	int numIfaces = bin.readInt();
	String[] ifaces = new String[numIfaces];
	for (int i = 0; i < numIfaces; i++) {
	    ifaces[i] = bin.readUTF();
	}
	
	Class cl = null;
	ClassNotFoundException resolveEx = null;
	bin.setBlockDataMode(true);
	try {
	    if ((cl = resolveProxyClass(ifaces)) == null) {
		throw new ClassNotFoundException("null class");
	    }
	} catch (ClassNotFoundException ex) {
	    resolveEx = ex;
	}
	skipCustomData();
	
	desc.initProxy(cl, resolveEx, readClassDesc(false));

	handles.finish(descHandle);
	passHandle = descHandle;
	return desc;
    
private voidreadSerialData(java.lang.Object obj, java.io.ObjectStreamClass desc)
Reads (or attempts to skip, if obj is null or is tagged with a ClassNotFoundException) instance data for each serializable class of object in stream, from superclass to subclass. Expects that passHandle is set to obj's handle before this method is called.

	ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout();
	for (int i = 0; i < slots.length; i++) {
	    ObjectStreamClass slotDesc = slots[i].desc;
	    
	    if (slots[i].hasData) {
		if (obj != null && 
		    slotDesc.hasReadObjectMethod() &&
		    handles.lookupException(passHandle) == null) 
		{
		    Object oldObj = curObj;
		    ObjectStreamClass oldDesc = curDesc;
		    GetFieldImpl oldGet = curGet;
		    curObj = obj;
		    curDesc = slotDesc;
		    curGet = null;

		    bin.setBlockDataMode(true);
		    try {
			slotDesc.invokeReadObject(obj, this);
		    } catch (ClassNotFoundException ex) {
			/*
			 * In most cases, the handle table has already
			 * propagated a CNFException to passHandle at this
			 * point; this mark call is included to address cases
			 * where the custom readObject method has cons'ed and
			 * thrown a new CNFException of its own.
			 */
			handles.markException(passHandle, ex);
		    }

		    curObj = oldObj;
		    curDesc = oldDesc;
		    curGet = oldGet;
		    
		    /*
		     * defaultDataEnd may have been set indirectly by custom
		     * readObject() method when calling defaultReadObject() or
		     * readFields(); clear it to restore normal read behavior.
		     */
		    defaultDataEnd = false;
		} else {
		    defaultReadFields(obj, slotDesc);
		}
		if (slotDesc.hasWriteObjectData()) {
		    skipCustomData();
		} else {
		    bin.setBlockDataMode(false);
		}
	    } else {
		if (obj != null && 
		    slotDesc.hasReadObjectNoDataMethod() &&
		    handles.lookupException(passHandle) == null)
		{
		    slotDesc.invokeReadObjectNoData(obj);
		}
	    }
	}
    
public shortreadShort()
Reads a 16 bit short.

return
the 16 bit short read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readShort();
    
protected voidreadStreamHeader()
The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers. It reads and verifies the magic number and version number.

throws
IOException if there are I/O errors while reading from the underlying InputStream
throws
StreamCorruptedException if control information in the stream is inconsistent

	if (bin.readShort() != STREAM_MAGIC ||
	    bin.readShort() != STREAM_VERSION)
	{
	    throw new StreamCorruptedException("invalid stream header");
	}
    
private java.lang.StringreadString(boolean unshared)
Reads in and returns new string. Sets passHandle to new string's assigned handle.

	String str;
	switch (bin.readByte()) {
	    case TC_STRING:
		str = bin.readUTF();
		break;
		
	    case TC_LONGSTRING:
		str = bin.readLongUTF();
		break;
		
	    default:
		throw new StreamCorruptedException();
	}
	passHandle = handles.assign(unshared ? unsharedMarker : str);
	handles.finish(passHandle);
	return str;
    
java.lang.StringreadTypeString()
Reads string without allowing it to be replaced in stream. Called from within ObjectStreamClass.read().

	int oldHandle = passHandle;
	try {
	    switch (bin.peekByte()) {
		case TC_NULL:
		    return (String) readNull();

		case TC_REFERENCE:
		    return (String) readHandle(false);

		case TC_STRING:
		case TC_LONGSTRING:
		    return readString(false);

		default:
		    throw new StreamCorruptedException();
	    }
	} finally {
	    passHandle = oldHandle;
	}
    
public java.lang.StringreadUTF()
Reads a String in modified UTF-8 format.

return
the String.
throws
IOException if there are I/O errors while reading from the underlying InputStream
throws
UTFDataFormatException if read bytes do not represent a valid modified UTF-8 encoding of a string

	return bin.readUTF();
    
public java.lang.ObjectreadUnshared()
Reads an "unshared" object from the ObjectInputStream. This method is identical to readObject, except that it prevents subsequent calls to readObject and readUnshared from returning additional references to the deserialized instance obtained via this call. Specifically:
  • If readUnshared is called to deserialize a back-reference (the stream representation of an object which has been written previously to the stream), an ObjectStreamException will be thrown.
  • If readUnshared returns successfully, then any subsequent attempts to deserialize back-references to the stream handle deserialized by readUnshared will cause an ObjectStreamException to be thrown.
Deserializing an object via readUnshared invalidates the stream handle associated with the returned object. Note that this in itself does not always guarantee that the reference returned by readUnshared is unique; the deserialized object may define a readResolve method which returns an object visible to other parties, or readUnshared may return a Class object or enum constant obtainable elsewhere in the stream or through external means.

However, for objects which are not enum constants or instances of java.lang.Class and do not define readResolve methods, readUnshared guarantees that the returned object reference is unique and cannot be obtained a second time from the ObjectInputStream that created it, even if the underlying data stream has been manipulated. This guarantee applies only to the base-level object returned by readUnshared, and not to any transitively referenced sub-objects in the returned object graph.

ObjectInputStream subclasses which override this method can only be constructed in security contexts possessing the "enableSubclassImplementation" SerializablePermission; any attempt to instantiate such a subclass without this permission will cause a SecurityException to be thrown.

return
reference to deserialized object
throws
ClassNotFoundException if class of an object to deserialize cannot be found
throws
StreamCorruptedException if control information in the stream is inconsistent
throws
ObjectStreamException if object to deserialize has already appeared in stream
throws
OptionalDataException if primitive data is next in stream
throws
IOException if an I/O error occurs during deserialization

	// if nested read, passHandle contains handle of enclosing object
	int outerHandle = passHandle;
	try {
	    Object obj = readObject0(true);
	    handles.markDependency(outerHandle, passHandle);
	    ClassNotFoundException ex = handles.lookupException(passHandle);
	    if (ex != null) {
		throw ex;
	    }
	    if (depth == 0) {
		vlist.doCallbacks();
	    }
	    return obj;
	} finally {
	    passHandle = outerHandle;
	    if (closed && depth == 0) {
		clear();
	    }
	}
    
public intreadUnsignedByte()
Reads an unsigned 8 bit byte.

return
the 8 bit byte read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readUnsignedByte();
    
public intreadUnsignedShort()
Reads an unsigned 16 bit short.

return
the 16 bit short read.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.readUnsignedShort();
    
public voidregisterValidation(java.io.ObjectInputValidation obj, int prio)
Register an object to be validated before the graph is returned. While similar to resolveObject these validations are called after the entire graph has been reconstituted. Typically, a readObject method will register the object with the stream so that when all of the objects are restored a final set of validations can be performed.

param
obj the object to receive the validation callback.
param
prio controls the order of callbacks;zero is a good default. Use higher numbers to be called back earlier, lower numbers for later callbacks. Within a priority, callbacks are processed in no particular order.
throws
NotActiveException The stream is not currently reading objects so it is invalid to register a callback.
throws
InvalidObjectException The validation object is null.

	if (depth == 0) {
	    throw new NotActiveException("stream inactive");
	}
	vlist.register(obj, prio);
    
protected java.lang.ClassresolveClass(java.io.ObjectStreamClass desc)
Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, the serialVersionUID of the class is compared to the serialVersionUID of the serialized class. If there is a mismatch, the deserialization fails and an exception is raised.

By default the class name is resolved relative to the class that called readObject.

param
desc an instance of class ObjectStreamClass
return
a Class object corresponding to desc
throws
IOException any of the usual input/output exceptions
throws
ClassNotFoundException if class of a serialized object cannot be found

	String name = desc.getName();
	try {
	    return Class.forName(name, false, latestUserDefinedLoader());
	} catch (ClassNotFoundException ex) {
	    Class cl = (Class) primClasses.get(name);
	    if (cl != null) {
		return cl;
	    } else {
		throw ex;
	    }
	}
    
protected java.lang.ObjectresolveObject(java.lang.Object obj)
This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization. Replacing objects is disabled until enableResolveObject is called. The enableResolveObject method checks that the stream requesting to resolve object can be trusted. Every reference to serializable objects is passed to resolveObject. To insure that the private state of objects is not unintentionally exposed only trusted streams may use resolveObject.

This method is called after an object has been read but before it is returned from readObject. The default resolveObject method just returns the same object.

When a subclass is replacing objects it must insure that the substituted object is compatible with every field where the reference will be stored. Objects whose type is not a subclass of the type of the field or array element abort the serialization by raising an exception and the object is not be stored.

This method is called only once when each object is first encountered. All subsequent references to the object will be redirected to the new object.

param
obj object to be substituted
return
the substituted object
throws
IOException Any of the usual Input/Output exceptions.

	return obj;
    
protected java.lang.ClassresolveProxyClass(java.lang.String[] interfaces)
Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass. For a given subclass of ObjectInputStream that overrides this method, the annotateProxyClass method in the corresponding subclass of ObjectOutputStream must write any data or objects read by this method.

The default implementation of this method in ObjectInputStream returns the result of calling Proxy.getProxyClass with the list of Class objects for the interfaces that are named in the interfaces parameter. The Class object for each interface name i is the value returned by calling

Class.forName(i, false, loader)
where loader is that of the first non-null class loader up the execution stack, or null if no non-null class loaders are on the stack (the same class loader choice used by the resolveClass method). Unless any of the resolved interfaces are non-public, this same value of loader is also the class loader passed to Proxy.getProxyClass; if non-public interfaces are present, their class loader is passed instead (if more than one non-public interface class loader is encountered, an IllegalAccessError is thrown). If Proxy.getProxyClass throws an IllegalArgumentException, resolveProxyClass will throw a ClassNotFoundException containing the IllegalArgumentException.

param
interfaces the list of interface names that were deserialized in the proxy class descriptor
return
a proxy class for the specified interfaces
throws
IOException any exception thrown by the underlying InputStream
throws
ClassNotFoundException if the proxy class or any of the named interfaces could not be found
see
ObjectOutputStream#annotateProxyClass(Class)
since
1.3

	ClassLoader latestLoader = latestUserDefinedLoader();
	ClassLoader nonPublicLoader = null;
	boolean hasNonPublicInterface = false;

	// define proxy in class loader of non-public interface(s), if any
	Class[] classObjs = new Class[interfaces.length];
	for (int i = 0; i < interfaces.length; i++) {
	    Class cl = Class.forName(interfaces[i], false, latestLoader);
	    if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
		if (hasNonPublicInterface) {
		    if (nonPublicLoader != cl.getClassLoader()) {
			throw new IllegalAccessError(
			    "conflicting non-public interface class loaders");
		    }
		} else {
		    nonPublicLoader = cl.getClassLoader();
		    hasNonPublicInterface = true;
		}
	    }
	    classObjs[i] = cl;
	}
	try {
	    return Proxy.getProxyClass(
		hasNonPublicInterface ? nonPublicLoader : latestLoader,
		classObjs);
	} catch (IllegalArgumentException e) {
	    throw new ClassNotFoundException(null, e);
	}
    
public intskipBytes(int len)
Skips bytes, block until all bytes are skipped.

param
len the number of bytes to be skipped
return
the actual number of bytes skipped.
throws
EOFException If end of file is reached.
throws
IOException If other I/O error has occurred.

	return bin.skipBytes(len);
    
private voidskipCustomData()
Skips over all block data and objects until TC_ENDBLOCKDATA is encountered.

	int oldHandle = passHandle;
	for (;;) {
	    if (bin.getBlockDataMode()) {
		bin.skipBlockData();
		bin.setBlockDataMode(false);
	    }
	    switch (bin.peekByte()) {
		case TC_BLOCKDATA:
		case TC_BLOCKDATALONG:
		    bin.setBlockDataMode(true);
		    break;
		    
		case TC_ENDBLOCKDATA:
		    bin.readByte();
		    passHandle = oldHandle;
		    return;
		    
		default:
		    readObject0(false);
		    break;
	    }
	}
    
private voidverifySubclass()
Verifies that this (possibly subclass) instance can be constructed without violating security constraints: the subclass must not override security-sensitive non-final methods, or else the "enableSubclassImplementation" SerializablePermission is checked.

	Class cl = getClass();
	synchronized (subclassAudits) {
	    Boolean result = (Boolean) subclassAudits.get(cl);
	    if (result == null) {
		/*
		 * Note: only new Boolean instances (i.e., not Boolean.TRUE or
		 * Boolean.FALSE) must be used as cache values, otherwise cache
		 * entry will pin associated class.
		 */
		result = new Boolean(auditSubclass(cl));
		subclassAudits.put(cl, result);
	    }
	    if (result.booleanValue()) {
		return;
	    }
	}
	SecurityManager sm = System.getSecurityManager();
	if (sm != null) {
	    sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
	}