- 浏览: 794211 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (651)
- Java (39)
- Java 初学者小问题 (66)
- 设计模式 (7)
- 项目管理 (3)
- 数据库 (1)
- 算法 (2)
- Java practices (6)
- Effective Java2读书笔记 (78)
- Linux (2)
- programming ruby 读书笔记 (5)
- Core Java Ninth Edition Volume I 读书笔记 (15)
- Pro Git 读书笔记 (12)
- Git (3)
- Maven in Action 读书笔记 (20)
- Web (12)
- 非技术类书籍 (11)
- 电影 (40)
- Web Cache (1)
- jquery (0)
- 历史 (4)
- Dive Into HTML5 读书笔记 (13)
- 三国演义小学毕业考 (79)
- 高效能人士的7个习惯 读书笔记 (12)
- Java Performance 读书笔记 (3)
- Protocol Buffer 学习笔记 (6)
- Mongo DB 学习笔记 (7)
- Morphia 学习笔记 (7)
- Algorithms -- Princeton 学习笔记 (13)
- String研究 (10)
- Hadoop: The Definitive Guide 读书笔记 (3)
- Java与模式读书笔记 (5)
- Date研究 (3)
- The Roman Empire 听课笔记 (4)
- Algorithms -- Standford 学习笔记 (16)
- Core Java Ninth Edition Volume II 读书笔记 (9)
- Thinking in Java 4th Edition 读书笔记 (21)
- Node : Up and Running 学习笔记 (5)
- Eloquent Javascript (8)
- Smashing Node.js 读书笔记 (1)
- Algorithms II -- Standford 学习笔记 (19)
- Algorithm II -- Princeton 学习笔记 (14)
- 网络安全 (2)
- Javascript (4)
- 正则表达式 (1)
- JAVA 7/8 (15)
- JVM (10)
- NodeJS (1)
- 鸟哥的linux私房菜读书笔记 (14)
- Web Service (1)
- The art of programming (9)
- Introduction to Algorithm 读书笔记 (4)
- Java 源码阅读 (0)
- Spring in Action 读书笔记 (2)
- Java Network Programming 读书笔记 (2)
最新评论
-
心存高远:
谢谢作者分享,刚好看到这里不太明白,现在茅塞顿开。不过runt ...
关于 Maven的传递依赖的理解 -
sxlkk:
851228082 写道甚至在某次技术会议现场遇到《Maven ...
关于 Maven的传递依赖的理解 -
851228082:
851228082 写道a----compile----b-- ...
第五章 坐标和依赖 -
851228082:
a----compile----b-----provided- ...
第五章 坐标和依赖 -
851228082:
甚至在某次技术会议现场遇到《Maven in action》的 ...
关于 Maven的传递依赖的理解
Question:
Is there a way to determine the generated
serialVersionUID
of a serialized Java object?
The problem is that I serialized an object without
explicitely specifying the serialVersionUID
. Now the
deserialization process complains about class incompatibilities. However I
didn't change the class in a way which would make it incompatible. So I assume
that it is enough to specify the serialVersionUID
serialVersionUID
in the class as
it is stored in the object data. In order to do this I need to read the
from the serialized data.
Answer:
1)
You can do this by extending ObjectInputStream :
public class PrintUIDs extends ObjectInputStream { public PrintUIDs(InputStream in) throws IOException { super(in); } @Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { ObjectStreamClass descriptor = super.readClassDescriptor(); System.out.println("name=" + descriptor.getName()); System.out.println("serialVersionUID=" + descriptor.getSerialVersionUID()); return descriptor; } public static void main(String[] args) throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); List<Object> list = Arrays.asList((Object) new Date(), UUID.randomUUID()); oos.writeObject(list); oos.close(); InputStream in = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new PrintUIDs(in); ois.readObject(); } }
I believe it would be possible to read all the serialized data by replacing the descriptor returned by the method, but I haven't tried it.
2)
There is metadata associated with the serialized bits
(a header if you like). You can read the value from the metadata if you know at
which position it is (the SerialVersionUID
is written there along
with other info such as the class name).
I think this article might help you: The Java serialization algorithm revealed .
Note that the bits are written "in clear" (unless you
encrypted the stream explicitly) so a HEX editor might be all you need to see
what is the SerialVersionUID
.
This article originates from http://stackoverflow.com/questions/1321988/finding-serialversionuid-of-serialized-object
发表评论
-
Zz The java.lang.LinkageError: loader constraint violation" demystified
2014-05-13 19:24 1508http://frankkieviet.blogspot.c ... -
zz Java NIO 系列教程
2014-05-09 22:38 1159http://www.iteye.com/magazines ... -
Zz Java NIO Tutorial
2014-05-09 22:34 1775http://tutorials.jenkov.com/ja ... -
Zz Spring IOC 好处和劣势
2014-03-28 18:06 1069IoC是什么? Inversion of Contro ... -
Zz ConcurrentHashMap源码解析
2014-03-16 17:29 664ConcurrentHashMap是Java 5中支持高并发 ... -
Zz Java多线程之ConcurrentHashMap深入分析
2014-03-16 14:50 1180一、Map体系 Hashtable是JDK ... -
Zz ConcurrentHashMap原理分析
2014-03-16 14:03 1125集合是编程中最常用的数据结构。而谈到并发,几乎总是离不开集合 ... -
Zz Java并发编程之ConcurrentHashMap
2014-03-16 13:40 2065ConcurrentHashMap Concurrent ... -
关于ConcurrentHashMap 中位移的问题
2014-03-16 14:33 1260拜读了GoldenDoc的大作:《Java并发编程之Con ... -
ConcurrentHashMap 详解
2014-03-15 21:19 01. ConcurrentHashMap 可以做到读取数 ... -
Why java Arrays use two different sort algorithms for different types?
2014-02-25 22:09 1298Java 7 uses Dual-Pivot Quicks ... -
深入探讨 java.lang.ref 包
2014-02-25 19:58 1090回顾了一下三年多前写的文章https://www.i ... -
Zz Java 中使用内存映射文件需要考虑的 10 个问题
2014-02-09 17:18 944java中的内存映射IO和内存映射文件是什么? 内存 ... -
Zz 10 Things to Know about Memory Mapped File in Java
2014-02-09 17:16 628What is Memory Mapped File ... -
Zz Direct vs non-direct ByteBuffer
2014-02-08 12:46 846先解释一下两者的区 ... -
Zz direct buffer VS non-direct buffer
2014-02-08 10:55 864在java NIO中,有两种不同的buffer:direct ... -
Java Generics 小结
2013-03-07 14:12 01. 泛型类型或泛型类 ... -
关于 Java正则表达式中的Possessive数量修饰词的理解
2013-02-26 21:14 1283正则表达式对于数量限定符如 ?, + , *, {n, m ... -
Run Application in debug mode
2013-01-23 13:59 1308Q: I use the Eclipse IDE to de ... -
一个 Dynamic Proxy 的例子
2012-11-22 11:18 1231最近翻出了两年前老吴让我写的一个MockFacotry , ...
相关推荐
本文介绍了一种系统化的方法——统一不可能差分查找方法(Unified Impossible Differential finding method, UID-method),用于高效地寻找各种块密码结构中的不可能差分。这种方法相较于先前由Kim等人提出的U-...
在所给文件标题中提到的“Adaptive Control of Multi-Agent Systems for Finding Peaks of Uncertain Fields”,指的就是在不确定的环境中,通过自适应控制算法来指导多代理系统协同工作,以寻找某个不确定场的峰值...
99 Bottles of OOP is a practical guide to writing cost-effective, maintainable, and pleasing object-oriented code. It explores: Recognizing when code is “good enough” Getting the best value from ...
Chapter 2: Criteria of object orientation 21 2.1 ON THE CRITERIA 21 2.2 METHOD AND LANGUAGE 22 2.3 IMPLEMENTATION AND ENVIRONMENT 31 2.4 LIBRARIES 33 2.5 FOR MORE SNEAK PREVIEW 34 2.6 BIBLIOGRAPHICAL ...
在探讨“finding experts on link of data”这一主题时,我们深入研究了由Lada Adamic与Eytan Adar撰写的论文摘要,该文详细分析了如何在一个社会网络中搜索和定位专家或特定个体,特别是在仅能利用局部信息的情况下...
Finding the area and volume of a circle on matlab
"edge_finding_matlab边缘寻找_"这个标题所指的是使用MATLAB进行图像边缘检测的过程。下面我们将深入探讨这一主题。 边缘检测的主要目的是将图像从二维空间转化为一维边缘描述,从而简化图像并突出重要的特征。...
SeamTech Finding是库卡系统中一款集成视觉探寻功能的软件,用于工业机器人在进行焊接、装配等任务时,通过视觉系统找到焊接缝隙等特征的位置。接下来,将详细介绍SeamTech Finding软件的主要知识点。 ### 1. ...
finding a majority among n votes.pdffinding a majority among n votes.pdffinding a majority among n votes.pdffinding a majority among n votes.pdfv
Satisfiability Modulo Theories (SMT) has contributed to finding excellent ways to pose and solve problems. Uses of temporal logic and data-flow-analysis techniques have also made model checking more ...
在给定的“finding_no_of-clusters_in_kmeans.tar.gz_Kmeans”压缩包文件中,我们可以推测其内容可能涉及到确定K-Means聚类算法的最佳簇数量的过程。这个过程通常称为肘部法则(Elbow Method)或轮廓系数法...
本文介绍的标题是“使用矩阵的特征向量寻找网络中的社团结构”,主要围绕着newman算法及其在解决网络社团划分问题中的应用进行阐述。社团划分问题是一个研究网络中具有密集内部连接和稀疏外部连接的顶点组的重要领域...
信息安全_数据安全_Finding a Domain’s Worth of Malware 云数据库 安全防御 区块链 安全防御 安全芯片
通过对"md.rar_angle of arrival_direction finding_md_测向_高分辨"这一主题的深入研究,我们可以更全面地理解如何利用先进的数学工具来解决实际的工程问题,提高系统的性能和可靠性。对于"md.txt"文件,它可能是对...
We argue that this finding is due to the fact that increasing the frequency of continuous deployment forces improved release and deployment automation, which in turn reduces developer workload....
### Matlab安装Error finding installer class解决方法 #### 问题背景及表现 在安装特定版本的Matlab(例如R2009b、R2010b等)时,可能会遇到一个名为“Error finding installer class”的错误。这个错误通常出现在...
"finding-lungs-in-ct-data.zip" 文件集合显然与CT图像处理相关,特别是关注肺部的分析。这个压缩包包含了几个关键文件,它们提供了用于肺部分割和体积识别的数据和结果。 首先,`lung_stats.csv` 文件很可能是记录...