java 序列化 uid,Java中的序列化版本uid

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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/371180.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HTML5本地存储

什么是Web Storage Web Storage是HTML5里面引入的一个类似于cookie的本地存储功能,可以用于客户端的本地存储,其相对于cookie来说有以下几点优势: 存储空间大:cookie只有4KB的存储空间,而Web Storage在官方建议中为每个…

番石榴秒表

番石榴的秒表是番石榴第10版的另一个新番石榴类(作为Optional ,这是另一篇近期文章的主题)。 顾名思义,这个简单的类提供了一种方便地测量两个代码点之间经过的时间的方法。 与使用System.currentTimeMillis(&#xff…

CF 839 E-最大团

CF 839 E Soltion: 就是怎么求最大团的问题: 以下是\(O(7000\times n^2)\)的做法 求一个最大团,然后将所有的药水平均分配,到最大团的所有点上,计算答案. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorit…

sse java_SSE详解

SSE(Server-Sent Events):通俗解释起来就是一种基于HTTP的&#xff0c;以流的形式由服务端持续向客户端发送数据的技术应用场景由于HTTP是无状态的传输协议,每次请求需由客户端向服务端建立连接,HTTPS还需要交换秘钥&#xff0c;所以一次请求,建立连接的过程占了很大比例在http…

520. Detect Capital

题目&#xff1a; Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA".A…

盒模型的属性丶display显示丶浮动

一丶盒模型的属性(重要) 1.padding padding是标准文档流,父子之间调整位置 <!DOCTYPE html><html><head><meta charset"UTF-8"><title>padding</title><style>*{padding: 0;margin: 0;}.box{width: 200px;height: 200px;b…

MapReduce:通过数据密集型文本处理

自上次发布以来已经有一段时间了&#xff0c;因为我一直在忙于Coursera提供的一些课程。 有一些非常有趣的产品&#xff0c;值得一看。 前一段时间&#xff0c;我购买了Jimmy Lin和Chris Dyer的MapReduce数据密集型处理程序 。 本书以伪代码格式介绍了几种关键的MapReduce算法。…

ubuntu(deepin)安装apache2并支持php7.0

linux虚拟机下用于开发环境测试&#xff0c;安装的apache和php7.0&#xff0c;但是简单安装完两者后apache并不能解析php&#xff0c;原因是确实apache的php扩展。 # 首先安装apache sudo apt-get install apache2 # 然后安装php7.0 sudo apt-get install php7.0 # 一般执行完这…

java applet 换行_Java复习题

一、选择题1.有Java语句如下&#xff0c;则说法正确的是()A.此语句是错误的B. a.length的值为5C. b.length的值为5D. a.length和b.length的值都为52.整数除法中&#xff0c;如果除数为0&#xff0c;则将导致的异常是( B )A. NullPointerExceptionB. ArithmeticExceptionC. Arra…

解决:MVC对象转json包含\r \n

项目中对象转json字符串时&#xff0c;如下&#xff1a;JsonSerializerSettings jsetting new JsonSerializerSettings(); jsetting.DefaultValueHandling DefaultValueHandling.Ignore; return JsonConvert.SerializeObject(resultMoldels, Formatting.Indented, jsetting);…

CSS 小结笔记之滑动门技术

所谓的滑动门技术&#xff0c;就是指盒子背景能够自动拉伸以适应不同长度的文本。即当文字增多时&#xff0c;背景看起来也会变长。 大多数应用于导航栏之中&#xff0c;如微信导航栏: 具体实现方法如下&#xff1a; 1、首先每一块文本内容是由a标签与span标签组成 <a hr…

使用API​​身份验证的Spring Security

背景 尽管有许多博客文章详细介绍了如何使用Spring Security&#xff0c;但是当问题域位于标准LDAP或数据库身份验证之外时&#xff0c;我仍然经常发现配置挑战。 在本文中&#xff0c;我将介绍一些针对Spring Security的简单自定义&#xff0c;使其能够与基于REST的API调用一起…

java nlpir_4-NLPIR汉语分词系统-JAVA

好吧&#xff0c;之前用的是旧版的&#xff0c;现在出了个新版的&#xff0c;优先选择用新版的哈。从官网下载相应的开发包&#xff0c;然后主要需要找到这几个东西添加到项目工程里面&#xff0c;1.Data文件夹 2.NLPIR_JNI.DLL 3.NLPIR.jar 4.nlpir.properties添加完那些东西后…

浅析C语言中assert的用法(转)

原文地址&#xff1a;http://www.jb51.net/article/39685.htm 以下是对C语言中assert的使用方法进行了介绍&#xff0c;需要的朋友可以参考下。 assert宏的原型定义在<assert.h>中&#xff0c;其作用是如果它的条件返回错误&#xff0c;则终止程序执行&#xff0c;原型定…

hihocoder offer收割编程练习赛12 D 寻找最大值

思路&#xff1a; 可能数据太水了&#xff0c;随便乱搞就过了。 实现&#xff1a; 1 #include <iostream>2 #include <cstdio>3 #include <algorithm>4 using namespace std;5 typedef long long ll;6 7 int a[100005], n;8 9 int main() 10 { 11 int t;…

vue error:The template root requires exactly one element.

error:[vue/valid-template-root] The template root requires exactly one element. 原因&#xff1a; 因为vue的模版中只有能一个根节点&#xff0c;所以在<template>中插入第二个元素就会报错 解决方案&#xff1a; 将<template>中的元素先用一个<div>…

测试驱动陷阱,第2部分

单元测试中单元的故事 在本文的上半部分 &#xff0c;您可能会看到一些不好但很流行的测试示例。 但是我不是一个专业评论家&#xff08;也被称为“巨魔”或“仇恨者”&#xff09;&#xff0c;没有任何建设性的话就抱怨。 多年的TDD教给我的不仅仅是事情会变得多么糟糕。 有许…

java 代码 设置环境变量_Java 配置环境变量教程

【声明】欢迎转载&#xff0c;但请保留文章原始出处→_→【正文】1、安装JDK开发环境开始安装JDK&#xff1a;修改安装目录如下&#xff1a;确定之后&#xff0c;单击“下一步”。注&#xff1a;当提示安装JRE时&#xff0c;可以选择不要安装。2、配置环境变量&#xff1a;对于…

组合数据类型练习,英文词频统计实例上(2017.9.22)

字典实例&#xff1a;建立学生学号成绩字典&#xff0c;做增删改查遍历操作。 sno[33号,34号,35号,36号] grade[100,90,80,120] d{33号:100,34号:90,35号:80,36号:120} print(d) print(每个学号对应分数:,d.items()) print(弹出35号的分数:,d.pop(35号)) print(获取学号:,d.key…

java 代码中设置 临时 环境变量

System.setProperty("hadoop.home.dir", "D:\\software\\software_install\\dev_install\\hadoop-2.4.1"); 转载于:https://www.cnblogs.com/zychengzhiit1/p/6662376.html