title: Unit Testing serializability for all classes in java project
body: <p>I've thousands of classes in our java project. Some of them implements serializable interface.  Now here's a problem.  It's possible someone can go in a class, add new variable that is neither transient nor serializable. Code compiles fine however process would blow up at runtime.</p>
  
  <p>To illustrate this</p>
  
  <pre class="lang-java prettyprint-override"><code>class Foo implements Serializable {  .... // all good }
  
  class Foo implements Serializable 
  {  
      // OOps, executorService is not serializable.  It's not declared as transient either 
  
      private ExecutorService executorService = ..
  }
  </code></pre>
  
  <p>I'm thinking about writing a unit test that would go thru all classes and ensure "true serializability".   I've read some discussions about serialing specific objects. i understand that process but it requires </p>
  
  <p>1) creating an object.<br>
   2) serializing and then<br>
   3) deserializing.</p>
  
  <p>Is there more efficient and practical approach. perhaps to use reflection. Go thru all classes, if class has serializable then all attributes must be serializable or have transient keyword.. </p>
  
  <p>Thoughts ?</p>