java.io
Class ObjectInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.ObjectInputStream
- All Implemented Interfaces:
- DataInput, ObjectInput, ObjectStreamConstants
- Direct Known Subclasses:
- UnserializationStream
- public class ObjectInputStream
- extends InputStream
- implements ObjectInput, ObjectStreamConstants
Untamed:
Field Summary
private java.io.ObjectInputStream.BlockDataInputStream
bin
filter stream for handling block data conversion
private boolean
closed
whether stream is closed
private java.io.ObjectInputStream.GetFieldImpl
curGet
current GetField object
private boolean
defaultDataEnd
flag set when at end of field value block with no TC_ENDBLOCKDATA
private int
depth
recursion depth
private boolean
enableOverride
if true, invoke readObjectOverride() instead of readObject()
private java.io.ObjectInputStream.HandleTable
handles
wire handle -> obj/exception map
private static int
NULL_HANDLE
handle value representing null
private int
passHandle
scratch field for passing handle values up/down call stack
private static HashMap
primClasses
table mapping primitive type names to corresponding class objects
private byte[]
primVals
buffer for reading primitive field values
private static sun.misc.SoftCache
subclassAudits
cache of subclass security audit results
private java.io.ObjectInputStream.ValidationList
vlist
validation callback list
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
Constructor Summary
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.
Method Summary
private static boolean
auditSubclass(Class subcl)
Performs reflective checks on given subclass to verify that it doesn't
override security-sensitive non-final methods.
int
available()
Enabled: Returns the number of bytes that can be read without blocking.
private static void
bytesToDoubles(byte[] src,
int srcpos,
double[] dst,
int dstpos,
int ndoubles)
Converts specified span of bytes into double values.
private static void
bytesToFloats(byte[] src,
int srcpos,
float[] dst,
int dstpos,
int nfloats)
Converts specified span of bytes into float values.
private Object
checkResolve(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.
private void
clear()
Clears internal data structures.
void
close()
Enabled: Closes the input stream.
void
defaultReadObject()
Enabled: Read the non-static and non-transient fields of the current class from
this stream.
protected boolean
enableResolveObject(boolean enable)
Enable the stream to allow objects read from the stream to be replaced.
private void
handleReset()
If recursion depth is 0, clears internal data structures; otherwise,
throws a StreamCorruptedException.
private static ClassLoader
latestUserDefinedLoader()
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.
int
read()
Enabled: Reads a byte of data.
int
read(byte[] buf,
int off,
int len)
Enabled: Reads into an array of bytes.
private Object
readArray(boolean unshared)
Reads in and returns array object, or null if array class is
unresolvable.
byte
readByte()
Enabled: Reads an 8 bit byte.
char
readChar()
Enabled: Reads a 16 bit char.
private Class
readClass(boolean unshared)
Reads in and returns class object.
double
readDouble()
Enabled: Reads a 64 bit double.
java.io.ObjectInputStream.GetField
readFields()
Enabled: Reads the persistent fields from the stream and makes them available by
name.
float
readFloat()
Enabled: Reads a 32 bit float.
void
readFully(byte[] buf)
Enabled: Reads bytes, blocking until all bytes are read.
void
readFully(byte[] buf,
int off,
int len)
Enabled: Reads bytes, blocking until all bytes are read.
private Object
readHandle(boolean unshared)
Reads in object handle, sets passHandle to the read handle, and returns
object associated with the handle.
int
readInt()
Enabled: Reads a 32 bit int.
String
readLine()
Deprecated. This method does not properly convert bytes to characters.
see DataInputStream for the details and alternatives.
long
readLong()
Enabled: Reads a 64 bit long.
private Object
readNull()
Reads in null code, sets passHandle to NULL_HANDLE and returns null.
protected Object
readObjectOverride()
This method is called by trusted subclasses of ObjectOutputStream that
constructed ObjectOutputStream using the protected no-arg constructor.
private Object
readOrdinaryObject(boolean unshared)
Reads and returns "ordinary" (i.e., not a String, Class,
ObjectStreamClass or array) object, or null if object's class is
unresolvable (in which case a ClassNotFoundException will be associated
with object's handle).
private void
readSerialData(Object obj,
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.
short
readShort()
Enabled: Reads a 16 bit short.
protected void
readStreamHeader()
The readStreamHeader method is provided to allow subclasses to read and
verify their own stream headers.
(package private) String
readTypeString()
Reads string without allowing it to be replaced in stream.
protected Object
resolveObject(Object obj)
This method will allow trusted subclasses of ObjectInputStream to
substitute one object for another during deserialization.
protected Class
resolveProxyClass(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.
int
skipBytes(int len)
Enabled: Skips bytes, block until all bytes are skipped.
private void
skipCustomData()
Skips over all block data and objects until TC_ENDBLOCKDATA is
encountered.
private void
verifySubclass()
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.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.io.DataInput
Field Detail
NULL_HANDLE
private static final int NULL_HANDLE
- handle value representing null
unsharedMarker
private static final Object unsharedMarker
- marker for unshared objects in internal handle table
primClasses
private static final HashMap primClasses
- table mapping primitive type names to corresponding class objects
subclassAudits
private static final sun.misc.SoftCache subclassAudits
- cache of subclass security audit results
bin
private final java.io.ObjectInputStream.BlockDataInputStream bin
- filter stream for handling block data conversion
vlist
private final java.io.ObjectInputStream.ValidationList vlist
- validation callback list
depth
private int depth
- recursion depth
closed
private boolean closed
- whether stream is closed
handles
private final java.io.ObjectInputStream.HandleTable handles
- wire handle -> obj/exception map
passHandle
private int passHandle
- scratch field for passing handle values up/down call stack
defaultDataEnd
private boolean defaultDataEnd
- flag set when at end of field value block with no TC_ENDBLOCKDATA
primVals
private byte[] primVals
- buffer for reading primitive field values
enableOverride
private final boolean enableOverride
- if true, invoke readObjectOverride() instead of readObject()
enableResolve
private boolean enableResolve
- if true, invoke resolveObject()
curObj
private Object curObj
- object currently being deserialized
curDesc
private ObjectStreamClass curDesc
- descriptor for current class (null if in readExternal())
curGet
private java.io.ObjectInputStream.GetFieldImpl curGet
- current GetField object
Constructor Detail
ObjectInputStream
public ObjectInputStream(InputStream in)
throws IOException
- Enabled: 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.
- Parameters:
in - input stream to read from
- Throws:
StreamCorruptedException - if the stream header is incorrect
IOException - if an I/O error occurs while reading stream header
SecurityException - if untrusted subclass illegally overrides
security-sensitive methods
NullPointerException - if in is null- See Also:
ObjectInputStream(),
readFields(),
ObjectOutputStream.ObjectOutputStream(OutputStream)
ObjectInputStream
protected ObjectInputStream()
throws IOException,
SecurityException
- 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.
IOException- See Also:
SecurityManager.checkPermission(java.security.Permission),
java.io.SerializablePermission
Method Detail
readObject
public final Object readObject()
throws IOException,
ClassNotFoundException
- Enabled: 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 completly 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.
- Specified by:
readObject in interface ObjectInput
- Returns:
- the object read from the stream
- Throws:
ClassNotFoundException - Class of a serialized object cannot be
found.
InvalidClassException - Something is wrong with a class used by
serialization.
StreamCorruptedException - Control information in the
stream is inconsistent.
OptionalDataException - Primitive data was found in the
stream instead of objects.
IOException - Any of the usual Input/Output related exceptions.
readObjectOverride
protected Object readObjectOverride()
throws IOException,
ClassNotFoundException
- 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".
-
- Returns:
- the Object read from the stream.
- Throws:
ClassNotFoundException - Class definition of a serialized object
cannot be found.
OptionalDataException - Primitive data was found in the stream
instead of objects.
IOException - if I/O errors occurred while reading from the
underlying stream- Since:
- 1.2
- See Also:
ObjectInputStream(),
readObject()
readUnshared
public Object readUnshared()
throws IOException,
ClassNotFoundException
- Enabled: 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 obtainable elsewhere in the stream or through external means.
However, for objects which are not 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.
-
- Returns:
- reference to deserialized object
- Throws:
ClassNotFoundException - if class of an object to deserialize
cannot be found
StreamCorruptedException - if control information in the stream
is inconsistent
ObjectStreamException - if object to deserialize has already
appeared in stream
OptionalDataException - if primitive data is next in stream
IOException - if an I/O error occurs during deserialization
defaultReadObject
public void defaultReadObject()
throws IOException,
ClassNotFoundException
- Enabled: 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.
IOException - if an I/O error occurs.
NotActiveException - if the stream is not currently reading
objects.
readFields
public java.io.ObjectInputStream.GetField readFields()
throws IOException,
ClassNotFoundException
- Enabled: Reads the persistent fields from the stream and makes them available by
name.
-
- Returns:
- 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.
IOException - if an I/O error occurs.
NotActiveException - if the stream is not currently reading
objects.- Since:
- 1.2
registerValidation
public void registerValidation(ObjectInputValidation obj,
int prio)
throws NotActiveException,
InvalidObjectException
- Enabled: 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.
-
- Parameters:
obj - the object to receive the validation callback.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.
InvalidObjectException - The validation object is null.
resolveClass
protected Class resolveClass(ObjectStreamClass desc)
throws IOException,
ClassNotFoundException
- 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.
-
- Parameters:
desc - an instance of class ObjectStreamClass
- Returns:
- a
Class object corresponding to desc
- Throws:
IOException - any of the usual input/output exceptions
ClassNotFoundException - if class of a serialized object cannot
be found
resolveProxyClass
protected Class resolveProxyClass(String[] interfaces)
throws IOException,
ClassNotFoundException
- 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.
-
- Parameters:
interfaces - the list of interface names that were
deserialized in the proxy class descriptor
- Returns:
- a proxy class for the specified interfaces
- Throws:
IOException - any exception thrown by the underlying
InputStream
ClassNotFoundException - if the proxy class or any of the
named interfaces could not be found- Since:
- 1.3
- See Also:
ObjectOutputStream.annotateProxyClass(Class)
resolveObject
protected Object resolveObject(Object obj)
throws IOException
- 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.
-
- Parameters:
obj - object to be substituted
- Returns:
- the substituted object
- Throws:
IOException - Any of the usual Input/Output exceptions.
enableResolveObject
protected boolean enableResolveObject(boolean enable)
throws SecurityException
- 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.
-
- Parameters:
enable - true for enabling use of resolveObject for
every object being deserialized
- Returns:
- 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 Also:
SecurityManager.checkPermission(java.security.Permission),
java.io.SerializablePermission
readStreamHeader
protected void readStreamHeader()
throws IOException,
StreamCorruptedException
- 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
StreamCorruptedException - if control information in the stream
is inconsistent
readClassDescriptor
protected ObjectStreamClass readClassDescriptor()
throws IOException,
ClassNotFoundException
- 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.
-
- Returns:
- the class descriptor read
- Throws:
IOException - If an I/O error has occurred.
ClassNotFoundException - If the Class of a serialized object used
in the class descriptor representation cannot be found- Since:
- 1.3
- See Also:
java.io.ObjectOutputStream#writeClassDescriptor(java.io.ObjectStreamClass)
read
public int read()
throws IOException
- Enabled: Reads a byte of data. This method will block if no input is available.
- Specified by:
read in interface ObjectInput- Specified by:
read in class InputStream
- Returns:
- the byte read, or -1 if the end of the stream is reached.
- Throws:
IOException - If an I/O error has occurred.
read
public int read(byte[] buf,
int off,
int len)
throws IOException
- Enabled: 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.
- Specified by:
read in interface ObjectInput- Overrides:
read in class InputStream
- Parameters:
buf - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes read
- Returns:
- 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 Also:
java.io.DataInputStream#readFully(byte[],int,int)
available
public int available()
throws IOException
- Enabled: Returns the number of bytes that can be read without blocking.
- Specified by:
available in interface ObjectInput- Overrides:
available in class InputStream
- Returns:
- the number of available bytes.
- Throws:
IOException - if there are I/O errors while reading from the
underlying InputStream
close
public void close()
throws IOException
- Enabled: Closes the input stream. Must be called to release any resources
associated with the stream.
- Specified by:
close in interface ObjectInput- Overrides:
close in class InputStream
- Throws:
IOException - If an I/O error has occurred.
readBoolean
public boolean readBoolean()
throws IOException
- Enabled: Reads in a boolean.
- Specified by:
readBoolean in interface DataInput
- Returns:
- the boolean read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readByte
public byte readByte()
throws IOException
- Enabled: Reads an 8 bit byte.
- Specified by:
readByte in interface DataInput
- Returns:
- the 8 bit byte read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readUnsignedByte
public int readUnsignedByte()
throws IOException
- Enabled: Reads an unsigned 8 bit byte.
- Specified by:
readUnsignedByte in interface DataInput
- Returns:
- the 8 bit byte read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readChar
public char readChar()
throws IOException
- Enabled: Reads a 16 bit char.
- Specified by:
readChar in interface DataInput
- Returns:
- the 16 bit char read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readShort
public short readShort()
throws IOException
- Enabled: Reads a 16 bit short.
- Specified by:
readShort in interface DataInput
- Returns:
- the 16 bit short read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readUnsignedShort
public int readUnsignedShort()
throws IOException
- Enabled: Reads an unsigned 16 bit short.
- Specified by:
readUnsignedShort in interface DataInput
- Returns:
- the 16 bit short read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readInt
public int readInt()
throws IOException
- Enabled: Reads a 32 bit int.
- Specified by:
readInt in interface DataInput
- Returns:
- the 32 bit integer read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readLong
public long readLong()
throws IOException
- Enabled: Reads a 64 bit long.
- Specified by:
readLong in interface DataInput
- Returns:
- the read 64 bit long.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readFloat
public float readFloat()
throws IOException
- Enabled: Reads a 32 bit float.
- Specified by:
readFloat in interface DataInput
- Returns:
- the 32 bit float read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readDouble
public double readDouble()
throws IOException
- Enabled: Reads a 64 bit double.
- Specified by:
readDouble in interface DataInput
- Returns:
- the 64 bit double read.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readFully
public void readFully(byte[] buf)
throws IOException
- Enabled: Reads bytes, blocking until all bytes are read.
- Specified by:
readFully in interface DataInput
- Parameters:
buf - the buffer into which the data is read
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readFully
public void readFully(byte[] buf,
int off,
int len)
throws IOException
- Enabled: Reads bytes, blocking until all bytes are read.
- Specified by:
readFully in interface DataInput
- Parameters:
buf - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes to read
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
skipBytes
public int skipBytes(int len)
throws IOException
- Enabled: Skips bytes, block until all bytes are skipped.
- Specified by:
skipBytes in interface DataInput
- Parameters:
len - the number of bytes to be skipped
- Returns:
- the actual number of bytes skipped.
- Throws:
EOFException - If end of file is reached.
IOException - If other I/O error has occurred.
readLine
public String readLine()
throws IOException
- Deprecated. This method does not properly convert bytes to characters.
see DataInputStream for the details and alternatives.
- Enabled: Reads in a line that has been terminated by a \n, \r, \r\n or EOF.
- Specified by:
readLine in interface DataInput
- Returns:
- a String copy of the line.
- Throws:
IOException - if there are I/O errors while reading from the
underlying InputStream
readUTF
public String readUTF()
throws IOException
- Enabled: Reads a UTF format String.
- Specified by:
readUTF in interface DataInput
- Returns:
- the String.
- Throws:
IOException - if there are I/O errors while reading from the
underlying InputStream
UTFDataFormatException - if read bytes do not represent a valid
UTF-8 encoding of a string
verifySubclass
private void verifySubclass()
- 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.
-
-
auditSubclass
private static boolean auditSubclass(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.
-
-
clear
private void clear()
- Clears internal data structures.
-
-
readObject0
private Object readObject0(boolean unshared)
throws IOException
- Underlying readObject implementation.
-
IOException
checkResolve
private Object checkResolve(Object obj)
throws IOException
- 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.
-
IOException
readTypeString
String readTypeString()
throws IOException
- Reads string without allowing it to be replaced in stream. Called from
within ObjectStreamClass.read().
-
IOException
readNull
private Object readNull()
throws IOException
- Reads in null code, sets passHandle to NULL_HANDLE and returns null.
-
IOException
readHandle
private Object readHandle(boolean unshared)
throws IOException
- Reads in object handle, sets passHandle to the read handle, and returns
object associated with the handle.
-
IOException
readClass
private Class readClass(boolean unshared)
throws IOException
- 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).
-
IOException
readClassDesc
private ObjectStreamClass readClassDesc(boolean unshared)
throws IOException
- 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.
-
IOException
readProxyDesc
private ObjectStreamClass readProxyDesc(boolean unshared)
throws IOException
- 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.
-
IOException
readNonProxyDesc
private ObjectStreamClass readNonProxyDesc(boolean unshared)
throws IOException
- 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.
-
IOException
readString
private String readString(boolean unshared)
throws IOException
- Reads in and returns new string. Sets passHandle to new string's
assigned handle.
-
IOException
readArray
private Object readArray(boolean unshared)
throws IOException
- Reads in and returns array object, or null if array class is
unresolvable. Sets passHandle to array's assigned handle.
-
IOException
readOrdinaryObject
private Object readOrdinaryObject(boolean unshared)
throws IOException
- Reads and returns "ordinary" (i.e., not a String, Class,
ObjectStreamClass or array) 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.
-
IOException
readExternalData
private void readExternalData(Externalizable obj,
ObjectStreamClass desc)
throws IOException
- 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.
-
IOException
readSerialData
private void readSerialData(Object obj,
ObjectStreamClass desc)
throws IOException
- 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.
-
IOException
skipCustomData
private void skipCustomData()
throws IOException
- Skips over all block data and objects until TC_ENDBLOCKDATA is
encountered.
-
IOException
defaultReadFields
private void defaultReadFields(Object obj,
ObjectStreamClass desc)
throws IOException
- 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.
-
IOException
readFatalException
private IOException readFatalException()
throws IOException
- 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.
-
IOException
handleReset
private void handleReset()
throws StreamCorruptedException
- If recursion depth is 0, clears internal data structures; otherwise,
throws a StreamCorruptedException. This method is called when a
TC_RESET typecode is encountered.
-
StreamCorruptedException
bytesToFloats
private static void bytesToFloats(byte[] src,
int srcpos,
float[] dst,
int dstpos,
int nfloats)
- Converts specified span of bytes into float values.
-
-
bytesToDoubles
private static void bytesToDoubles(byte[] src,
int srcpos,
double[] dst,
int dstpos,
int ndoubles)
- Converts specified span of bytes into double values.
-
-
latestUserDefinedLoader
private static ClassLoader latestUserDefinedLoader()
- 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.
-
-