- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设类 com.Foo
是从 JAR 加载的,后来加载了一个具有相同名称 com.Foo
的类,但不同的定义(其他字段)被反序列化(例如,从数据库加载或从远程调用接收)。
可能会产生什么后果?新接收的类(class)会有影响吗?假设该类在应用程序的其他部分使用,保存在数据库中并稍后进行序列化/JSON 编码。
最佳答案
如果反序列化 Class<?>
object 然后加载具有完全限定类名的类。如果它已经加载,您将获得对该类的引用。
我认为要获得完整的答案,您应该阅读 Java Object Serialization Specification
以下是我认为有趣的规范中的一些引文:
1.1 概述
Special handling is required for arrays, enum constants, and objects of type Class, ObjectStreamClass, and String. Other objects must implement either the Serializable or the Externalizable interface to be saved in or restored from a stream.
2。对象输出类
If the object is a Class, the corresponding ObjectStreamClass is written to the stream, a handle is assigned for the class, and writeObject returns.
3.对象输入类
If the object in the stream is a Class, read its ObjectStreamClass descriptor, add it and its handle to the set of known objects, and return the corresponding Class object.
关于Java:反序列化已加载的类时会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20347717/
我创建了一个分支来开发新功能。由于这个新功能完全是作为一个新项目开发的,唯一可能的冲突来源是解决方案文件。 随着功能的开发,主分支更新了几次。当我完成开发和测试时,我做了: git checkout
我是一名优秀的程序员,十分优秀!