可序列化的自定义异常类?
Google App Engine 要求我先将对象序列化,然后才能将其用作会话 bean。现在我有一个 Product 类,我使这个 Product 类可序列化,但是它的构造函数之一和一些 setter 具有检查异常,这些检查异常是自定义异常。我的问题是:我应该序列化这些自定义异常类吗?
Google App Engine requires me to make objects serializable before I can use it as a session bean. Now I have a Product class, I made this Product class serializable, but one of its constructors and some setters have checked exceptions, these checked exceptions are custom exceptions. My question is: should I serialize these custom exception classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果异常不是类的字段,则无需使它们可序列化,因为它们不会被存储。默认情况下,异常无论如何都是可序列化的
If the Exceptions are not a field of your class, there is no need to make them serializable because they won´t be stored. By default Exception are serializable anyway