|CONTENTS | PREV | NEXT||Java Object Serialization Specification|
ObjectInputStream.GetFieldprovides the API for getting the values of serializable fields. The protocol of the stream is the same as used by
readFieldsto access the serializable fields does not change the format of the stream. It only provides an alternate API to access the values which does not require the class to have the corresponding non-transient and non-static fields for each named serializable field. The serializable fields are those declared using
serialPersistentFieldsor if it is not declared the non-transient and non-static fields of the object. When the stream is read the available serializable fields are those written to the stream when the object was serialized. If the class that wrote the stream is a different version not all fields will correspond to the serializable fields of the current class. The available fields can be retrieved from the
getObjectStreamClassmethod returns an
ObjectStreamClassobject representing the class in the stream. It contains the list of serializable fields.
defaultedmethod returns true if the field is not present in the stream. An
IllegalArgumentExceptionis thrown if the requested field is not a serializable field of the current class.
getmethod returns the specified serializable field from the stream. I/O exceptions will be thrown if the underlying stream throws an exception. An
IllegalArgumentExceptionis thrown if the name or type does not match the name and type of an field serializable field of the current class. The default value is returned if the stream does not contain an explicit value for the field.