title: Why not serialize abstract classes in Java?
body: <p>I have read that generally abstract classes should not be made Serializable in Java. The subclasses should be serializable (with custom read, write methods if required, for eg. when abstract classes have fields).</p>
  
  <p>What is the reason behind this? Why is it considered bad design?</p>
  
  <p><strong>Update1:</strong> I have an abstract class with some fields and three subclasses. As of now, I am using the following approach. </p>
  
  <p>I have made all the subclasses serializable with custom read, write methods. In the abstract class I have the following methods. </p>
  
  <pre><code>void writeFields(ObjectOutputStream out)throws IOException { .... }
  
  void readFields(ObjectInputStream in) throws IOException, ClassNotFoundException{ ... }
  </code></pre>
  
  <p>In the custom read, write methods in the subclasses I call these methods to (de) serialize the fields in the abstract class. Is this approach correct? Or is there a different better approach?</p>
  
  <p><strong>Update 2:</strong> I took Tom's advice and made my abstract class Serializable. (I want all subclasses to be Serializable and I have data in the abstract class) This is an aside, but just to complete the story I am using <a href="http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-3.html" rel="noreferrer">reflection to change final fields as advised by Jeremy Manson.</a></p>