站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JDK 5 Documentation v1.4.1, Java 2 SDK 英文文档

Java Object Serialization Specification: 6 - Object Serialization Stream Protocol - JDK 5 Documentation v1.4.1, Java 2 SDK 英文文档

CONTENTS | PREV | NEXT Java Object Serialization Specification


6.3 Stream Protocol Versions

It was necessary to make a change to the serialization stream format in JDKTM 1.2 that is not backwards compatible to all minor releases of JDKTM 1.1. To provide for cases where backwards compatibility is required, a capability has been added to indicate what PROTOCOL_VERSION to use when writing a serialization stream. The method ObjectOutputStream.useProtocolVersion takes as a parameter the protocol version to use to write the serialization stream.

The Stream Protocol Versions are as follows:

  • ObjectStreamConstants.PROTOCOL_VERSION_1
  Indicates the initial stream format.
  • ObjectStreamConstants.PROTOCOL_VERSION_2
  •   Indicates the new external data format. Primitive data is written in block data mode and is terminated with TC_ENDBLOCKDATA.
      Block data boundaries have been standardized. Primitive data written in block data mode is normalized to not exceed 1024 byte chunks. The benefit of this change was to tighten the specification of serialized data format within the stream. This change is fully backward and forward compatible.
    JDKTM 1.2 defaults to writing PROTOCOL_VERSION_2.

    JDKTM 1.1 defaults to writing PROTOCOL_VERSION_1.

    JDKTM 1.1.7 and greater can read both versions.

    Releases prior to JDKTM 1.1.7 can only read PROTOCOL_VERSION_1.



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