title: Java: how to ensure serializable collections
body: <p>In Java, the Collection-interfaces do not extend Serializable for several good reasons. In addition, most common implementations of these interfaces implement Serializable.</p>
  
  <p>So objects which implement one of the Collection-interfaces are serializable if the implementation itself is serializable (which is usually the case) <strong>and</strong> if the objects in the collection are all serializable.</p>
  
  <p>But how can I ensure that these two conditions are met? I don't want to run into a runtime-error since the compiler could check these conditions. I'm thinking about some obvious interface like (showcase for the List-interface):</p>
  
  <pre><code>public interface SerializableList&lt;T extends Serializable&gt; extends Serializable, List&lt;T&gt; {}
  </code></pre>
  
  <p>I'm wondering if no one else is facing this problem and came up with this easy solution. Up to now I wasn't able to find any solution or even discussion on this, which makes me doubt on my idea. </p>