java对象序列化格式

stream:

     magic version contents

magic:

     STREAM_MAGIC

version:

     STREAM_VERSION

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

newClassDesc:

     TC_CLASSDESC className serialVersionUID newHandle classDescInfo

     TC_PROXYCLASSDESC newHandle proxyClassDescInfo

className:

     (utf)

serialVersionUID:

    (long)

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

classDescInfo:

      classDescFlags fields classAnnotation superClassDesc

proxyClassDescInfo:
     (int)<count>proxyInterfaceName[count] classAnnotation
     superClassDesc

proxyInterfaceName:
     (utf)

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 containing the field’s type

superClassDesc:

     classDesc

classAnnotation:

     endBlockData
     contents endBlockData // contents written by annotateClass

prim_typecode:

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

obj_typecode:

     `[` // array
     `L' // object

newArray:

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

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

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

externalContents: // externalContent written by

     externalContent // writeExternal in PROTOCOL_VERSION_1
     externalContents externalContent

externalContent: // Only parseable by readExternal

     (bytes)object

blockdata:

    blockdatashort
    blockdatalong

blockdatashort:

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

blockdatalong:

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

endBlockData:

     TC_ENDBLOCKDATA

newString:

     TC_STRING newHandle (utf)

prevObject:

     TC_REFERENCE (int)handle

nullReference:

     TC_NULL

exception:

     TC_EXCEPTION reset(Throwable) object reset

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值