http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use-it
http://topic.csdn.net/t/20051017/20/4332328.html
http://blog.csdn.net/hulefei29/article/details/2823221
关于什么是serialVersionUID,可以参考java.io.Serializable的Java Doc,上面描述得很清楚:
java.io.Serializable
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 InvalidClassException
. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID
" that must be static, final, and of type long
:
ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
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 strongly recommended 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 InvalidClassExceptions
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 private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members.
分享到:
相关推荐
Java中serialVersionUID的解释,对于版本的说明解释问题
本篇文章主要介绍了详述IntelliJ IDEA 中自动生成 serialVersionUID 的方法(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
主要介绍了java序列化和serialVersionUID的使用方法实例的相关资料,这里说明很详细的使用方法让你彻底学会,需要的朋友可以参考下
三期第一张IO笔记 6
主要介绍了java类中serialVersionUID的作用及其使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
以下是对Java中的serialVersionUID进行了全面的分析介绍。需要的朋友可以过来参考下
全面解析了java中serialVersionUID的作用,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
主要介绍了idea如何自动生成serialVersionUID,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
【强制】序列化类新增属性时,请不要修改 serialVersionUID 字段,避免反序列失败; 如果 完全不兼容升级,避免反序列化混乱,那么请修改 serialVersionUID 值。 说明:注意 serialVersionUID 不一致会抛出序列化...
序列化版本号serialVersionUID的作用_动力节点Java学院整理.
NULL 博文链接:https://jnh.iteye.com/blog/1300193
614.612.JAVA基础教程_IO流与网络编程-serialVersionUID的理解(614).rar
为什么阿里巴巴建议初始化HashMap的...为什么阿里巴巴禁止开发人员修改serialVersionUID字段的值?97 为什么阿里巴巴建议开发者谨慎使用继承?109 为什么阿里巴巴禁止使用count(列名)或count(常量)来替代count(*) ?111
为什么阿里巴巴禁止开发人员修改 serialVersionUID 字段的值? 97 为什么阿里巴巴建议开发者谨慎使用继承? 109 为什么阿里巴巴禁止使用 count( 列名 ) 或 count( 常量 ) 来替代 count(*) ? 111
对于暂时被注释掉,后续可能恢复使用的代码片断,在注释代码上方,统一规定使用三 个斜杠(///)来说明注释掉代码的理由。 D .不要在视图模板中加入任何复杂的逻辑。 多选 4.关于分页查询,下列哪些说法符合《阿里...
处理方式:确认此局部变量是否会被使用,如果确实不会被用到,请去掉,和 Dead store to local variable一样处理,只是这里针对的是不是局部变量; Call to static DateFormat 描述:调用静态的DateFormat对象 处理...
eclipse序列号生成器,方便大家在使用eclipse的时间生成序列号用。
#Jersey-2 with Guice Persist一个项目,演示如何在Jersey2(JAX-RS)容器中使用JPA配置Google Guice。 该项目不使用Guice servlet模块或Guice持久... private static final long serialVersionUID = 366534908950086
1.serialVersionUID-->适用于Java的序列化机制: 2.具体化序列化过程: 3.serialVersionUID有两种显示的生成方式: