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
Use a concrete Serializable set for your internal representation, but make any public interfaces use the Set interface.
public class TestClass implements Serializable {
private static final long serialVersionUID = 1905162041950251407L;
private HashSet mySet;
public TestClass(Set s) {
super();
setMySet(s);
}
public void setMySet(Set s) {
mySet = (s == null) ? new HashSet<>() : new HashSet<>(s);
}
}