问题描述
虽然这个类不打算设置为可序列化,但我收到了这个不寻常的警告!如果你遇到这种奇怪的警告,有人会告诉我吗?!
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父类是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的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!