Eclipse 可序列化成员验证
当我将 Java 类定义为可序列化时,Eclipse 不会警告我某些成员不可序列化,这可能会导致应用程序在运行时序列化失败。
我找不到任何启用成员验证的设置。
关于如何验证可序列化类的成员也是可序列化的任何想法吗?
谢谢
When I define a Java class to be Serializable, Eclipse does not warn me that Some of the members are not Serializable, which may cause the application to fail serializing @ runtime.
I couldn't find any setting to enable the member validation.
Any idea on how to validate that members of a Serializable class are also Serializable?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设没有人想出一种方法直接在 eclipse 中执行此操作,我会推荐 FindBugs 插件,它有一个规则
SerializedIdiom
我相信它应该突出您担心的问题。如果需要,我可以添加有关规则的更多详细信息。不过,它们在此处显示的格式很痛苦,所以我放弃将它们添加到原始答案中
Assuming no one comes up with a way to do this in eclipse directly, I would reccomend the FindBugs plug-in it has a rule
SerializableIdiom
which I believe should highlight the issue you are worried about.I can add more details on the rule if required. They are pain to format for display in here though so I gave up adding them to the original answer
引用不可序列化的类型是合法的,但最终在运行时指向可序列化对象:
It is legal to have a reference to a type that is not Serializable which ends up pointing at a serializable object at runtime: