CONTENTS | PREV | NEXT Java Object Serialization Specification

4.2 The ObjectStreamField Class

An ObjectStreamField represents a serializable field of a serializable class. The serializable fields of a class can be retrieved from the ObjectStreamClass.

The special static Serializable field, serialPersistentFields, an array of ObjectStreamField components is used to override the default serializable fields.


public class ObjectStreamField {

    public ObjectStreamField(String fieldName, Class fieldType);

    public String getName();

    public Class getType() throws ClassNotFoundException;

    public String toString();
The ObjectStreamField constructor is used to create a new instance of an ObjectStreamField. The argument is the type of the serializable field. For example, Integer.TYPE or java.lang.Hashtable.class. ObjectStreamField objects are used to specify the serializable fields of a class or to describe the fields present in a stream.

The getName method returns the name of the serializable field.

The getType method returns the type of the field.

The toString method returns a printable representation with name and type.

Copyright © 1997-1998 Sun Microsystems, Inc. All Rights Reserved.