- 浏览: 167899 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
小灯笼:
RabbitMQ实战:分布式消息队列高效部署及插件集群开发信息 ...
MQ(一) rabbitmq -
快乐的小六:
分布式消息队列高效部署及插件集群开发信息数据监控、分析实战(R ...
MQ(一) rabbitmq -
lgxjob:
spring schema -
h416373073:
博主写的用心,多谢分享
spring schema -
司马饮之:
顶一个
try catch finally 关闭流标准的写法
JDK Serializable 描述
/**
* Serializability of a class is enabled by the class implementing the
* java.io.Serializable interface. Classes that do not implement this
* interface will not have any of their state serialized or
* deserialized. All subtypes of a serializable class are themselves
* serializable. The serialization interface has no methods or fields
* and serves only to identify the semantics of being serializable. <p>
*
* To allow subtypes of non-serializable classes to be serialized, the
* subtype may assume responsibility for saving and restoring the
* state of the supertype's public, protected, and (if accessible)
* package fields. The subtype may assume this responsibility only if
* the class it extends has an accessible no-arg constructor to
* initialize the class's state. It is an error to declare a class
* Serializable if this is not the case. The error will be detected at
* runtime. <p>
*
* During deserialization, the fields of non-serializable classes will
* be initialized using the public or protected no-arg constructor of
* the class. A no-arg constructor must be accessible to the subclass
* that is serializable. The fields of serializable subclasses will
* be restored from the stream. <p>
*
* When traversing a graph, an object may be encountered that does not
* support the Serializable interface. In this case the
* NotSerializableException will be thrown and will identify the class
* of the non-serializable object. <p>
*
* Classes that require special handling during the serialization and
* deserialization process must implement special methods with these exact
* signatures: <p>
*
* <PRE>
* private void writeObject(java.io.ObjectOutputStream out)
* throws IOException
* private void readObject(java.io.ObjectInputStream in)
* throws IOException, ClassNotFoundException;
* private void readObjectNoData()
* throws ObjectStreamException;
* </PRE>
*
* <p>The writeObject method is responsible for writing the state of the
* object for its particular class so that the corresponding
* readObject method can restore it. The default mechanism for saving
* the Object's fields can be invoked by calling
* out.defaultWriteObject. The method does not need to concern
* itself with the state belonging to its superclasses or subclasses.
* State is saved by writing the individual fields to the
* ObjectOutputStream using the writeObject method or by using the
* methods for primitive data types supported by DataOutput.
*
* <p>The readObject method is responsible for reading from the stream and
* restoring the classes fields. It may call in.defaultReadObject to invoke
* the default mechanism for restoring the object's non-static and
* non-transient fields. The defaultReadObject method uses information in
* the stream to assign the fields of the object saved in the stream with the
* correspondingly named fields in the current object. This handles the case
* when the class has evolved to add new fields. The method does not need to
* concern itself with the state belonging to its superclasses or subclasses.
* State is saved by writing the individual fields to the
* ObjectOutputStream using the writeObject method or by using the
* methods for primitive data types supported by DataOutput.
*
* <p>The readObjectNoData method is responsible for initializing the state of
* the object for its particular class in the event that the serialization
* stream does not list the given class as a superclass of the object being
* deserialized. This may occur in cases where the receiving party uses a
* different version of the deserialized instance's class than the sending
* party, and the receiver's version extends classes that are not extended by
* the sender's version. This may also occur if the serialization stream has
* been tampered; hence, readObjectNoData is useful for initializing
* deserialized objects properly despite a "hostile" or incomplete source
* stream.
*
* <p>Serializable classes that need to designate an alternative object to be
* used when writing an object to the stream should implement this
* special method with the exact signature: <p>
*
* <PRE>
* ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
* </PRE><p>
*
* This writeReplace method is invoked by serialization if the method
* exists and it would be accessible from a method defined within the
* class of the object being serialized. Thus, the method can have private,
* protected and package-private access. Subclass access to this method
* follows java accessibility rules. <p>
*
* Classes that need to designate a replacement when an instance of it
* is read from the stream should implement this special method with the
* exact signature.<p>
*
* <PRE>
* ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
* </PRE><p>
*
* This readResolve method follows the same invocation rules and
* accessibility rules as writeReplace.<p>
*
* The serialization runtime associates with each serializable class a version
* number, called a serialVersionUID, which is used during deserialization to
* verify that the sender and receiver of a serialized object have loaded
* classes for that object that are compatible with respect to serialization.
* If the receiver has loaded a class for the object that has a different
* serialVersionUID than that of the corresponding sender's class, then
* deserialization will result in an {@link InvalidClassException}. A
* serializable class can declare its own serialVersionUID explicitly by
* declaring a field named <code>"serialVersionUID"</code> that must be static,
* final, and of type <code>long</code>:<p>
*
* <PRE>
* ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
* </PRE>
*
* If a serializable class does not explicitly declare a serialVersionUID, then
* the serialization runtime will calculate a default serialVersionUID value
* for that class based on various aspects of the class, as described in the
* Java(TM) Object Serialization Specification. However, it is <em>strongly
* recommended</em> that all serializable classes explicitly declare
* serialVersionUID values, since the default serialVersionUID computation is
* highly sensitive to class details that may vary depending on compiler
* implementations, and can thus result in unexpected
* <code>InvalidClassException</code>s during deserialization. Therefore, to
* guarantee a consistent serialVersionUID value across different java compiler
* implementations, a serializable class must declare an explicit
* serialVersionUID value. It is also strongly advised that explicit
* serialVersionUID declarations use the <code>private</code> modifier where
* possible, since such declarations apply only to the immediately declaring
* class--serialVersionUID fields are not useful as inherited members. Array
* classes cannot declare an explicit serialVersionUID, so they always have
* the default computed value, but the requirement for matching
* serialVersionUID values is waived for array classes.
*
* @author unascribed
* @version 1.25, 11/17/05
* @see java.io.ObjectOutputStream
* @see java.io.ObjectInputStream
* @see java.io.ObjectOutput
* @see java.io.ObjectInput
* @see java.io.Externalizable
* @since JDK1.1
/**
* Serializability of a class is enabled by the class implementing the
* java.io.Serializable interface. Classes that do not implement this
* interface will not have any of their state serialized or
* deserialized. All subtypes of a serializable class are themselves
* serializable. The serialization interface has no methods or fields
* and serves only to identify the semantics of being serializable. <p>
*
* To allow subtypes of non-serializable classes to be serialized, the
* subtype may assume responsibility for saving and restoring the
* state of the supertype's public, protected, and (if accessible)
* package fields. The subtype may assume this responsibility only if
* the class it extends has an accessible no-arg constructor to
* initialize the class's state. It is an error to declare a class
* Serializable if this is not the case. The error will be detected at
* runtime. <p>
*
* During deserialization, the fields of non-serializable classes will
* be initialized using the public or protected no-arg constructor of
* the class. A no-arg constructor must be accessible to the subclass
* that is serializable. The fields of serializable subclasses will
* be restored from the stream. <p>
*
* When traversing a graph, an object may be encountered that does not
* support the Serializable interface. In this case the
* NotSerializableException will be thrown and will identify the class
* of the non-serializable object. <p>
*
* Classes that require special handling during the serialization and
* deserialization process must implement special methods with these exact
* signatures: <p>
*
* <PRE>
* private void writeObject(java.io.ObjectOutputStream out)
* throws IOException
* private void readObject(java.io.ObjectInputStream in)
* throws IOException, ClassNotFoundException;
* private void readObjectNoData()
* throws ObjectStreamException;
* </PRE>
*
* <p>The writeObject method is responsible for writing the state of the
* object for its particular class so that the corresponding
* readObject method can restore it. The default mechanism for saving
* the Object's fields can be invoked by calling
* out.defaultWriteObject. The method does not need to concern
* itself with the state belonging to its superclasses or subclasses.
* State is saved by writing the individual fields to the
* ObjectOutputStream using the writeObject method or by using the
* methods for primitive data types supported by DataOutput.
*
* <p>The readObject method is responsible for reading from the stream and
* restoring the classes fields. It may call in.defaultReadObject to invoke
* the default mechanism for restoring the object's non-static and
* non-transient fields. The defaultReadObject method uses information in
* the stream to assign the fields of the object saved in the stream with the
* correspondingly named fields in the current object. This handles the case
* when the class has evolved to add new fields. The method does not need to
* concern itself with the state belonging to its superclasses or subclasses.
* State is saved by writing the individual fields to the
* ObjectOutputStream using the writeObject method or by using the
* methods for primitive data types supported by DataOutput.
*
* <p>The readObjectNoData method is responsible for initializing the state of
* the object for its particular class in the event that the serialization
* stream does not list the given class as a superclass of the object being
* deserialized. This may occur in cases where the receiving party uses a
* different version of the deserialized instance's class than the sending
* party, and the receiver's version extends classes that are not extended by
* the sender's version. This may also occur if the serialization stream has
* been tampered; hence, readObjectNoData is useful for initializing
* deserialized objects properly despite a "hostile" or incomplete source
* stream.
*
* <p>Serializable classes that need to designate an alternative object to be
* used when writing an object to the stream should implement this
* special method with the exact signature: <p>
*
* <PRE>
* ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
* </PRE><p>
*
* This writeReplace method is invoked by serialization if the method
* exists and it would be accessible from a method defined within the
* class of the object being serialized. Thus, the method can have private,
* protected and package-private access. Subclass access to this method
* follows java accessibility rules. <p>
*
* Classes that need to designate a replacement when an instance of it
* is read from the stream should implement this special method with the
* exact signature.<p>
*
* <PRE>
* ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
* </PRE><p>
*
* This readResolve method follows the same invocation rules and
* accessibility rules as writeReplace.<p>
*
* The serialization runtime associates with each serializable class a version
* number, called a serialVersionUID, which is used during deserialization to
* verify that the sender and receiver of a serialized object have loaded
* classes for that object that are compatible with respect to serialization.
* If the receiver has loaded a class for the object that has a different
* serialVersionUID than that of the corresponding sender's class, then
* deserialization will result in an {@link InvalidClassException}. A
* serializable class can declare its own serialVersionUID explicitly by
* declaring a field named <code>"serialVersionUID"</code> that must be static,
* final, and of type <code>long</code>:<p>
*
* <PRE>
* ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
* </PRE>
*
* If a serializable class does not explicitly declare a serialVersionUID, then
* the serialization runtime will calculate a default serialVersionUID value
* for that class based on various aspects of the class, as described in the
* Java(TM) Object Serialization Specification. However, it is <em>strongly
* recommended</em> that all serializable classes explicitly declare
* serialVersionUID values, since the default serialVersionUID computation is
* highly sensitive to class details that may vary depending on compiler
* implementations, and can thus result in unexpected
* <code>InvalidClassException</code>s during deserialization. Therefore, to
* guarantee a consistent serialVersionUID value across different java compiler
* implementations, a serializable class must declare an explicit
* serialVersionUID value. It is also strongly advised that explicit
* serialVersionUID declarations use the <code>private</code> modifier where
* possible, since such declarations apply only to the immediately declaring
* class--serialVersionUID fields are not useful as inherited members. Array
* classes cannot declare an explicit serialVersionUID, so they always have
* the default computed value, but the requirement for matching
* serialVersionUID values is waived for array classes.
*
* @author unascribed
* @version 1.25, 11/17/05
* @see java.io.ObjectOutputStream
* @see java.io.ObjectInputStream
* @see java.io.ObjectOutput
* @see java.io.ObjectInput
* @see java.io.Externalizable
* @since JDK1.1
发表评论
-
软件移植
2022-01-30 20:17 0此篇是工作随笔: 基础原理: 1、OS所处的 ... -
信号量与PV java
2018-01-02 15:11 1110进程间通信: 进程通常 ... -
http资料整理
2017-09-25 11:11 663http://blog.csdn.net/java199366 ... -
ACL权限管理
2017-09-19 10:56 2489ACL : access control list 访问权限管 ... -
Cookie 浅谈
2017-09-05 20:25 677随记Cookie 先看源码 /** * * ... -
JVM
2017-05-02 17:47 638http://blog.csdn.net/java199366 ... -
dubbo升级dubbox
2016-11-09 14:59 6045笔者公司部分应用用dubbo暴露服务,随着一些新人加盟,很多 ... -
spring 懒加载与dubbo 客户端校验
2016-09-19 18:41 2983Dubbo的启动时服务依赖检查是,对象实例化时,判断远程调用是 ... -
标识接口
2015-01-13 14:26 736摘要:标识接口是没有任何方法和属性的接口.它仅仅表明它的类属于 ... -
排序算法
2014-12-25 16:26 676package a; public class So ... -
java 序列化
2014-11-26 15:02 1074java序列化,是把对象序列化成流,转成流的目的是为了网络传输 ... -
java SPI
2014-11-19 17:30 663Java的SPI http://singleant.iteye ... -
JAR 文件包
2014-11-19 16:19 810JAR 文件就是 Java Archive File,顾名思意 ... -
hadoop
2014-10-15 17:09 1200hadoop官方网站: http://hadoop.apach ... -
JMX
2013-07-26 11:06 654http://docs.oracle.com/javase/7 ... -
分布式事务
2013-07-17 13:57 1765JTA 与 JTS 区别 一. 链 ... -
AJAX
2013-07-07 10:08 997一. AJAX 注意事项 (1)XHR不会修改浏览器历史栈,即 ... -
相等测试equals
2013-06-24 10:29 764Object类是Java中所有类的 ... -
随记小知识点
2013-06-21 10:44 8131. 字符串 从概念上讲,java字条串就是Unicode字符 ... -
Memcache
2013-02-16 17:36 753Memcache windows http://www.cn ...
相关推荐
`java.io.Serializable`接口标记一个类可以被序列化。这个文件通常包含了类如何序列化的详细信息,包括字段的顺序和类型,这对于理解和恢复序列化数据至关重要。 2. **常量值(Constant Values)** `constant-...
TensorFlow API英文版是针对开发者提供的官方文档,其中包含了构建数据流图(Graphs)、操作(Operation)和张量(Tensor)等核心组件的详细说明。 构建数据流图是TensorFlow工作的基础。数据流图由节点(Node)...
- `java.io.ObjectInputStream`和`ObjectOutputStream`支持序列化流的版本控制。 这些知识点构成了JDK 1.4.2的核心特性,对于那些需要兼容旧版本或者研究Java历史演进的开发者来说,官方API文档是非常宝贵的参考...
9. **反射**: Java反射API允许程序在运行时动态地获取类的信息并操作类的对象,这是许多高级功能(如序列化、动态代理)的基础。 10. **泛型**: 泛型引入于Java 5,增强了类型安全性,允许在编译时检查类型。...
这对于理解和实现持久化或网络传输非常重要,因为SwingX的一些组件可能涉及到对象的序列化。 `overview-tree.html`展示了库中所有类的层次结构,以树形结构列出,帮助开发者快速定位和理解类之间的关系。这对于理解...
4. **I/O流**:Java 7的`java.io`包中,流类如`FileInputStream`和`FileOutputStream`用于文件操作,`BufferedReader`和`PrintWriter`用于文本读写,`ObjectInputStream`和`ObjectOutputStream`则支持对象的序列化和...
3. **I/O流**:如`java.io`,支持文件读写、网络数据传输、对象序列化等。 4. **网络编程**:如`java.net`,提供套接字、URL、URI等网络通信相关类。 5. **多线程**:如`java.lang.Thread`和`java.util.concurrent`...
Avro API提供了数据模式定义和数据序列化/反序列化的功能,支持动态类型。 理解Apache API的关键在于熟悉每个组件的核心概念、接口和类。通过阅读英文版的API文档,开发者可以获得详细的方法描述、参数说明和示例...
这个"Java API(官方英文版)"很显然是官方提供的文档,详细阐述了Java API中的每一个类、接口、方法和枚举,是Java程序员不可或缺的参考资料。 在Java API文档中,你可以找到以下关键知识点: 1. **包(Package)**...
中文API文档是为了解决英文API阅读困难,方便中国开发者理解Java类库中的各种类、接口和方法。 在给定的压缩包文件中,我们有以下几个关键文件: 1. `serialized-form.html`: 这个文件通常用于描述Java对象序列化...
Tweener是一款强大的动画库,尤其在ActionScript 3(AS3)开发中广泛应用,用于创建平滑的过渡效果和复杂的动画序列。它允许开发者轻松地在不同属性之间进行缓动,包括对象的位置、大小、颜色等。Tweener不仅支持...
10. **JAXB(Java Architecture for XML Binding)**:JAXB用于XML和Java对象之间的转换,方便XML数据的序列化和反序列化。 这个“JAVA-EE-api-5.0-中英文对照经理版”的文档是学习和开发Java EE 5.0应用的重要参考...
Stream API是Java 8中的新特性,提供了一种序列处理数据的方式,支持集合操作的并行化。通过`stream()`方法,我们可以对集合进行操作,如过滤、映射、查找、排序等。这使得处理大量数据变得更加高效且易于理解。 3...
Redis是一款高性能的键值对数据库,常用于缓存和数据持久化。它的高效性得益于其内存存储特性,但同时也提供了可选的持久化机制来保证数据安全。在本压缩包中,包含的是Redis 2.8版本,适用于Windows 64位操作系统。...
这个压缩包包含的是Cocos2d-x版本3.2和3.6的英文与中文API文档,方便开发者查阅和理解框架的各种功能。以下是这些版本中一些核心知识点的详细解释: 1. **Cocos2d-x架构**: Cocos2d-x是基于C++的,它提供了面向...
Java 7中文API是官方英文API的中文翻译版,对于那些英语阅读能力有限或者希望更快速理解API的开发者来说,是一份非常实用的参考资料。 **CHM 文件格式** CHM是Microsoft的Compiled HTML Help文件格式,它将HTML...
**此“JDK7-API-帮助文档(英文版完整版)”是一个离线版的官方文档,包含了Java 7的所有公共类和接口的详细信息,对于学习和查阅Java 7的API非常有用。** **文档中包含的主要文件有:** 1. **stylesheet.css** - ...
2. **Stream API**:Stream API为处理集合提供了新的方式,支持序列化操作,可以进行高效且易于理解的并行操作。它非常适合数据聚合操作,如查找、过滤、映射和归约。 3. **方法引用**:方法引用允许直接引用已有...
Hibernate是一个流行的Java持久化框架,它允许开发者将对象模型映射到关系数据库,极大地简化了数据库操作。在Hibernate中,注解(Annotation)API是一种声明式的方法,用于定义对象-关系映射(ORM)。让我们深入...
- `serialized-form.html`:序列化形式的类描述。 - `overview-summary.html`:概述摘要。 - `help-doc.html`:帮助文档,介绍如何使用API文档。 以上是HttpClient 4.2.3 API的核心功能和相关知识点。开发者可以...