CONTENTS | PREV | NEXT Java Object Serialization Specification


6.4.1 Rules of the Grammar

A Serialized stream is represented by any stream satisfying the stream rule.

stream:
magic version contents

contents:
content
contents content

content:
object
blockdata

object:
newObject
newClass
newArray
newString
newClassDesc
prevObject
nullReference
exception
reset

newClass:
TC_CLASS classDesc newHandle

classDesc:
newClassDesc
nullReference
(ClassDesc)prevObject
         // an object required to be of type ClassDesc

superClassDesc:
classDesc

newClassDesc:
TC_CLASSDESC className serialVersionUID newHandle classDescInfo

classDescInfo:
classDescFlags fields classAnnotation superClassDesc

className:
(utf)

serialVersionUID:
(long)

classDescFlags:
(byte)                                    // Defined in Terminal Symbols and Constants

fields:
(short)<count> fieldDesc[count]

fieldDesc:
primitiveDesc
objectDesc

primitiveDesc:
prim_typecode fieldName

objectDesc:
obj_typecode fieldName className1

fieldName:
(utf)

className1:
(String)object                               // String contains field type

classAnnotation:
endBlockData
contents endBlockData
             // contents written by annotateClass

prim_typecode:
`B'                                                // byte
`C'                                                // char
`D'                                                // double
`F'                                                // float
`I'                                                // integer
`J'                                                // long
`S'                                                // short
`Z'                                                // boolean

obj_typecode:
`[`                                                // array
`L'                                                // object

newArray:
TC_ARRAY classDesc newHandle (int)<size> values[size]

newObject:
TC_OBJECT classDesc newHandle classdata[]      // data for each class

classdata:
nowrclass                                     // SC_SERIALIZABLE & classDescFlag &&
                                                        // !(SC_WRITE_METHOD & classDescFlags)
wrclass objectAnnotation       // SC_SERIALIZABLE & classDescFlag &&
                                                        // SC_WRITE_METHOD & classDescFlags
externalContents
                      // SC_EXTERNALIZABLE & classDescFlag &&
                                                        // !(SC_BLOCKDATA & classDescFlags
objectAnnotation
                      // SC_EXTERNALIZABLE & classDescFlag&&
                                                        // SC_BLOCKDATA & classDescFlags

nowrclass:
values                                           // fields in order of class descriptor

wrclass:
nowrclass

objectAnnotation:
endBlockData
contents endBlockData
          // contents written by writeObject
                                                       // or writeExternal PROTOCOL_VERSION_2.

blockdata:
blockdatashort
blockdatalong

blockdatashort:
TC_BLOCKDATA (unsigned byte)<size> (byte)[size]

blockdatalong:
TC_BLOCKDATALONG (int)<size> (byte)[size]

endBlockData:
TC_ENDBLOCKDATA

externalContent:                                   // Only parseable by readExternal
                                                                    // primitive data
(bytes)object

externalContents:                                // externalContent written by writeExternal
                                                                   // in PROTOCOL_VERSION_1.
externalContent
externalContents externalContent

newString:
TC_STRING newHandle (utf)

prevObject:
TC_REFERENCE (int)handle

nullReference:
TC_NULL

exception:
TC_EXCEPTION reset (Throwable)object reset

magic:
STREAM_MAGIC

version:
STREAM_VERSION

values:                                                       // The size and types are described by the
                                                                    // classDesc for the current object

newHandle:                                             // The next number in sequence is assigned
                                                                    // to the object being serialized or deserialized

reset:                                                         // The set of known objects is discarded
                                                                    // so the objects of the exception do not
                                                                    // overlap with the previously sent objects or
                                                                    // with objects that may be sent after the
                                                                    // exception



CONTENTS | PREV | NEXT
Copyright © 1997-1998 Sun Microsystems, Inc. All Rights Reserved.