title: How to handle a Findbugs "Non-transient non-serializable instance field in serializable class"?
body: <p>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 on line 7.</p>
  
  <pre><code>1 public class TestClass implements Serializable {
  2
  3  private static final long serialVersionUID = 1905162041950251407L;
  4
  5  private Set&lt;Integer&gt; mySet;      // Findbugs error
  6
  7  private HashSet&lt;Integer&gt; myOtherSet;
  8
  9 }
  </code></pre>
  
  <p>That's correct because java.util.Set never implements Serializable in its hierarchy and java.util.HashSet does. 
  However it is best practice to code against interfaces instead of concrete implementations.</p>
  
  <p>How can I best handle this?</p>
  
  <p>I can add a @Suppresswarnings(justification="No bug", values="SE_BAD_FIELD") on line 3. I have quite a lot of Sets and Lists in my actual code and I'm afraid it will litter my code too much.</p>
  
  <p>Are there better ways?</p>