Consider the class below. If I run Findbugs against it it will give me an error (\"Non-transient non-serializable instance field in serializable class\") on line 5 but not o
I know this is an old question that's already answered but just so others know is that you can set the Set
field as transient if you have no interest in serializing that particular field which will fix your FindBugs error.
public class TestClass implements Serializable {
private static final long serialVersionUID = 1905162041950251407L;
private transient Set mySet;
}
I prefer this method instead of forcing users of your API to cast to your concrete type, unless it's just internal, then Michael Borgwardt's answer makes more sense.