Sahik Sahil
Sahik Sahil

Reputation: 23

Non-transient non-serializable instance field in a non serializable class?

I have a class without extending Serializable or Externalizable interface but still I am getting the bug while using FindBugs in netbeans. Can anyone suggest me how how to resolve this?

This is my class

public class Analyzer extends javax.swing.JPanel implements ItemListener, KeyListener{

public AnalyzerVariable [] objAnalyzerVar = new AnalyzerVariable [3];
public AnalyzerVariable objAnalyzerDataTypeInfo;

}

Bug from FindBug : class Analyzer defines a non-transient non-serializable instance field objAnalyzerVar and also same for objAnalyzerDataTypeInfo;

Upvotes: 2

Views: 5953

Answers (1)

Kishore
Kishore

Reputation: 839

public class Analyzer extends javax.swing.JPanel implements ItemListener, KeyListener{...

Analyser is a sub-class javax.swing.JPanel. Since javax.swing.JPanel is a Serializable class, Analyser is also Serializable. So Findbugs is giving showing that as a bug.

More on javax.swing.JPanel- javadoc.

Upvotes: 2

Related Questions