java RMI 中的序列化
我正在使用 RMI 用 Java 编写应用程序。我有几个类实现了我编写的接口。为什么我不能让该接口扩展 Serialized 接口,以便实现它的两个类依次可序列化?
I'm writing an application in Java using RMI. I have a couple of classes that implement an interface I've written. Why can't I just make that interface extend the Serializable interface, so that the two classes implementing it would be in turn serializable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不认为 RMI 检查继承链,无论如何,只需向每个类添加实现可序列化就足够容易了。
I don't think that RMI checks the inheritance chain, it's easy enough to just add implements Serializable to each class anyway.
您可以让您的接口扩展 Serialized interafce 和所有实现接口的类也将实现
Serialized
接口。这是关于创建类
Serialized
的好读物 - Java RMI:序列化You can have your interface extend the Serializable interafce and all your classes implementing your interface will be implementing the
Serializable
interface as well.This is a good read on making a class
Serializable
- Java RMI: Serialization你可以。让接口扩展 Serialized 就足够了。从语言的角度来看,这完全等同于让实现类实现 Serialized。
You can. Having the interface extend Serializable is sufficient. From the language point of view this is entirely equivalent to having the implementing classes implement Serializable.