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

Java Object Serialization Specification: - Exceptions In Object Serialization - JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档

CONTENTS | PREV | NEXT Java Object Serialization Specification

Exceptions In Object Serialization





APPENDIX B

All exceptions thrown by serialization classes are subclasses of ObjectStreamException which is a subclass of IOException.

Exception
Description

ObjectStreamException

Superclass of all serialization exceptions.

InvalidClassException

Thrown when a class cannot be used to restore objects for any of these reasons:

  • The class does not match the serial version of the class in the stream.
  • The class contains fields with invalid primitive data types.
  • The Externalizable class does not have a public no-arg constructor.
  • The Serializable class can not access the no-arg constructor of its closest non-Serializable superclass.
  • NotSerializableException

    Thrown by a readObject or writeObject method to terminate serialization or deserialization.

    StreamCorruptedException

    Thrown:

  • If the stream header is invalid.
  • If control information not found.
  • If control information is invalid.
  • JDKTM 1.1.5 or less attempts to call readExternal on a PROTOCOL_VERSION_2 stream.
  • NotActiveException

    Thrown if writeObject state is invalid within the following ObjectOutputStream methods:

  • defaultWriteObject
  • putFields
  • writeFields
  • Thrown if readObject state is invalid within the following ObjectInputStream methods:

  • defaultReadObject
  • readFields
  • registerValidation
  • InvalidObjectException

    Thrown when a restored object cannot be made valid.

    OptionalDataException

    Thrown by readObject when there is primitive data in the stream and an object is expected. The length field of the exception indicates the number of bytes that are available in the current block.

    WriteAbortedException

    Thrown when reading a stream terminated by an exception that occurred while the stream was being written.



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