How is Serialization id stored in the instance of the object ?

The Serialization id we declare in Java is static field;and static fields are not serialized.

There should be some way to store the static final field then. How does java do it ?

解决方案

The serialVersionUID is not stored in the instance of a "serialized" object, as it is an static field (it is part of the class, not part of the object).

Therefore, it is stored in the compiled bytecode if it is actually defined, otherwise it is computed. In the java specification's words:

If the class has defined serialVersionUID it is retrieved from the class. If the serialVersionUID is >not defined by the class, it is computed from the definition of the class in the virtual machine. If >the specified class is not serializable or externalizable, null is returned.

In the Stream Unique Identifiers section, the algorithm for such computation is explained.

This paragraph is noteworthy (that's why IDEs usually show a warning when a class implementing Serializable has not explicitly defined a serialVersionUID).

Note: 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 serialVersionUID conflicts during deserialization, causing deserialization to fail.

java 序列化 uid,Java中的序列化版本uid相关推荐

  1. java 序列化实例_Java中的序列化与反序列化实例

    创建的字节流与平台无关.因此,在一个平台上序列化的对象可以在另一个平台上反序列化. 为了使Java对象可序列化,我们实现java.io.Serializable可序列化接口. ObjectOutput ...

  2. python中常用的序列化模块_Python中的序列化和反序列化

    为什么要序列化 内存中的字典.列表.集合以及各种对象,如何保存到一个文件中. 设计一套协议,按照某种规则,把内存中的数据保存到文件中,文件是一个个字节序列.所以必须把数据额转换为字节序列,输出到文件, ...

  3. python中常用的序列化模块_Python 中的序列化模块

    封面图片来源:沙沙野 序列化模块前面讲到解码编码的时候提过,网络数据传输只能通过 bytes 类型.而文件写入内容(不是指存储)既可以是 bytes,也可以是 string.这些操作都可以使用 eva ...

  4. java 不能反序列化_java中的序列化与反序列化

    序列化就是将一个对象以及他的属性写入一个文件,保存在存中对象的状态 反序列化就是把保存的对象状态再读出来 实现序列化与反序列化就要使用到IO操作中文件的字节流输入与输出 inputStream与out ...

  5. JAVA免费https,Java与HTTPS

    什么是HTTPS 严格地讲,HTTPS并不是一个单独的协议,而是对工作在一加密连接(TLS或SSL)上的常规HTTP协议的称呼. TLS/SSL 关于TLS/SSL的介绍网上已经有很多,大家可以参考& ...

  6. java中的序列化和反序列化

    一.序列化和反序列化的概念 把对象转换为字节序列的过程称为对象的序列化. 把字节序列恢复为对象的过程称为对象的反序列化. 对象的序列化主要有两种用途: 1) 把对象的字节序列永久地保存到硬盘上,通常存 ...

  7. java序列化库_java 中序列化(Serializable)

    18年5月份,在毕业快一年的时候,我终于把自己从研发助理偏向行政打杂,偶尔写一些前端代码的处境,回归到了初衷-安安静静写前后端代码的小小程序员~过程中的心酸也就不在这里吐啦,毕竟我是小太阳,永不熄灭的 ...

  8. java 四字节uid,Java入门教程-序列化版本号serialVersionUID的作用

    原标题:Java入门教程-序列化版本号serialVersionUID的作用 Java序列化是将一个对象编码成一个字节流,反序列化将字节流编码转换成一个对象.序列化是Java中实现持久化存储的一种方法 ...

  9. 对象序列化Java中的序列化

    首先声明,我是一个菜鸟.一下文章中出现技术误导情况盖不负责 当两个进程在停止远程通信时,彼此可以发送各种类型的数据.无论是何种类型的数据,都市以二进制序列的情势在络网上传送.发送方需要把这个Java对 ...

  10. Java中的序列化到底是什么

    我们都知道,新建一个对象的时候实现 Serializeable 接口,但为什么要这么做?什么时候这样子做?这样子做会不会出现幺蛾子?阿淼一个三连差点把自己都问懵逼了-- 那接下来,大家就和阿淼一起简单 ...

最新文章

  1. jenkins-svn配置
  2. Robotium中定位Android客户端疑难元素
  3. Java和SAP ABAP的异常处理
  4. python打印字符金字塔_Python教程第7篇:print打印字符串
  5. Item-Based Collaborative Recommender System
  6. androidpn的学习研究(五)androidpn-client 常见BUG解决方法
  7. 关于redis性能问题分析和优化
  8. 25.使用getScript()方法异步加载并执行js文件
  9. android listview 行高度自适应,Android ListView 长度自适应item的内容 计算listview的高度...
  10. java jdom格式,java使用jdom生成xml格式文件
  11. U盘插入电脑识别不出来,怎么解决?
  12. 搭建Flutter-iOS开发环境
  13. 腾讯视频外链获取,可以在微信、所有浏览器播放
  14. RPA案例 | 电商使用超自动化平台提升运营精细化
  15. python unrar问题_Python-使用unrar库时Couldn't find path to unrar library的解决办法
  16. Acrobat如何将word文件转换成pdf格式
  17. 区块链技术要用到什么开发语言?
  18. 删除我的电脑中微云、百度网盘、酷我音乐等软件图标
  19. 02.微软官方启动U盘装机教程
  20. fonts/fontawesome-webfont.woff2 404

热门文章

  1. 如何用Python读取Excel中图片?又如何用Python往Excel中写入图片?
  2. Android检测是否有悬浮窗,Android 获取判断是否有悬浮窗权限的方法
  3. 某个元素的距离页面的左边距_在机检测圆心距
  4. hibernate session 新增、删除,修改、查询样例
  5. flow 静态类型检查 js
  6. css渲染(二) 文本
  7. 阅读react-redux源码 - 零
  8. Kubernetes CRD开发模式及源码实现深入剖析-Kubernetes商业环境实战
  9. GT sport赛道详解 - Dragon Trail | 龙之径
  10. jenkins-基础配置