java对象序列化是否在1.5和1.6之间兼容 [英] Is java object serialization compatible between 1.5 and 1.6

查看:161
本文介绍了java对象序列化是否在1.5和1.6之间兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道混合jdk 1.5和1.6(Java 6)对象序列化(biderctional communication)是否安全。我搜索了太阳关于这个问题的明确声明,但没有成功。所以,除了技术可行性之外,我正在寻找关于这个问题的官方声明。

I am wondering whether it is safe to mix jdk 1.5 and 1.6 (Java 6) object serialization (biderctional communication). I searched for an explicit statement from sun concerning this question but did not succeed. So, besides the technical feasability I am searching for an "official" statement concerning the problem.

推荐答案

序列化机制本身没有改变。对于个别课程,它将取决于具体的课程。如果类具有serialVersionUID字段,则应该指示序列化兼容性。

The serialization mechanism itself has not changed. For individual classes it will depend on the specific class. If a class has a serialVersionUID field, this is supposed to indicate serialization compatiblity.

类似于:

private static final long serialVersionUID = 8683452581122892189L;

如果不变,则序列化版本兼容。对于JDK类,这是有保证的,但当然总是可能在进行重大更改后忘记更新serialVersionUID。

If it is unchanged, the serialized versions are compatible. For JDK classes this is guaranteed, but of course it is always possible to forget to update the serialVersionUID after making a breaking change.

当JDK类不能保证兼容时,这通常在Javadoc中提到。

When JDK classes are not guaranteed to be compatible, this is usually mentioned in the Javadoc.


警告:此类的序列化对象与未来的Swing版本不兼容

Warning: Serialized objects of this class will not be compatible with future Swing releases

这篇关于java对象序列化是否在1.5和1.6之间兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆