34

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 {

Regards

Sam
  • 2,702
  • 5
  • 31
  • 45

3 Answers3

54

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

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).

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

Community
  • 1
  • 1
7

If you know your application never serializes things, add -Xlint:-serial to command line arguments of javac. For example,

javac -Xlint -Xlint:-serial *****

This way you will have all warnings except "serial".

VasiliNovikov
  • 9,681
  • 4
  • 44
  • 62
7

JFrame implements Serializable, so all extending classes also implement Serializable.

Here's a tutorial about Serializable and serialVersionUID, but to really understand the topic you should read Chapter 11 of Effective Java (2nd Ed) by Joshua Bloch

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588