警告:[serial] 可序列化类 SomeClass 没有 serialVersionUID 的定义 [英] warning: [serial] serializable class SomeClass has no definition of serialVersionUID

查看:19
本文介绍了警告:[serial] 可序列化类 SomeClass 没有 serialVersionUID 的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管该类不打算设置为可序列化,但我收到了这个不寻常的警告!如果您遇到过这种奇怪的警告,有人可以告诉我吗?!

Eventhough this class is not intended ot set to be serializable, I'm getting this unusual warning! Could someone let me know if you have come across such odd warning?!

C:Documents and Settings...filename.java:60: warning: [serial] serializable class SomeClass has no definition of serialVersionUID
public class NewPortalConnection extends javax.swing.JFrame {

问候

推荐答案

当您从实现 Serializable 的类派生时,会出现此警告.在您的情况下,Serializable 父类是 JFrame.

This warning comes when you derive from a class that implements Serializable. In your case, the Serializable parent class is JFrame.

您可以使用@SuppressWarnings("serial") 取消此警告,或为该类提供一个serialVersionUID:private static final long serialVersionUID = ...;(点的长值).

You can suppress this warning with @SuppressWarnings("serial"), or give the class a serialVersionUID: private static final long serialVersionUID = ...; (with a long value for the dots).

这里有一个关于 SO 的讨论,这是更可取的.

There is a discussion here on SO on which is preferable.

这篇关于警告:[serial] 可序列化类 SomeClass 没有 serialVersionUID 的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆