-
2005年05月20日
About serialVersionUID when implementing Serializable
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://fireshort.blogbus.com/logs/1198167.html
"When java tries to deserialize an object, it compares the serialized object's serialVersionUID with that of the class the JVM is using for deserializing the object. ...
If the two numbers don't match, the JVM assumes the class is not compatible with the previously-serialized object, and you'll get an exception during deserialization.
So, the solution is to put a serialVersionUID in your class, and then as the class evolves, the serialVersionUID will remain the same and the JVM will say, "Ok, cool, the class is compatible with this serialized object." even though the class has actually changes"If the class has been changed and you want the JVM to not to load the previously serialized classes then the serialVersionUID . Otherwise leave it alone.
随机文章:
javadbf中文问题的解决 2005年10月19日操作dbf的类库 2005年09月08日用Java进行LDAP编程的方式 2007年01月23日Java中对有BOM头的UTF-8文件的处理 2006年10月19日j2ee系统与rtx的整合实现 2006年07月27日
收藏到:Del.icio.us
引用地址:





