简体   繁体   English

相同的serialversionUID用于相同的已安装Java版本

[英]Same serialversionUID for same installed Java versions

I have a simple question, which wasn't cleared properly by Googling: If I install the same Java binary onto different computers, will their serialversionUID remain the same? 我有一个简单的问题,Googling无法正确清除:如果我将相同的Java二进制文件安装到不同的计算机上,它们的serialversionUID是否会保持不变? If no, then other than explicitly changing, is their any mechanism wherein the serialversionUID's are different? 如果不是,那么除了明确改变之外,是他们的任何机制,其中serialversionUID是不同的? Thanks for the explanation. 感谢您的解释。 (This is a link to the algorithm which generates the UID: algorithm ) (这是生成UID的算法的链接: 算法

Yes, because the serialVersionUIDs are just a member variables set to static values, and you didn't recompile the binaries between placing them on the first machine and the second. 是的,因为serialVersionUID只是一个设置为静态值的成员变量,并且您没有在将它们放在第一台机器和第二台机器上之间重新编译二进制文件。

It is the serialization / deserialization architecture which concerns itself with serialVersionUIDs, at run time. 它是序列化/反序列化体系结构,它在运行时与serialVersionUID有关。 If one modifies the source code of a class with a serialVersionUID, they are supposed to review the class for serialization compatibility with the unmodified version, and if incompatible, adjust the serialVerisonUID to an yet-unused value for that class. 如果使用serialVersionUID修改类的源代码,则应该检查类与未修改版本的序列化兼容性,如果不兼容,则将serialVerisonUID调整为该类的尚未使用的值。

“流唯一标识符是类名,接口类名,方法和字段的64位散列”,如果您没有更改类代码,它应该完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM