title: Java Seralization and Deseralization
body: <p>I have an object as follows:</p>
  
  <pre><code>    public class Records implements java.io.Serializable{
          private int cId;
          private int pId;
          private int vlaue;
          private int tag;
  
          public Records(int c, int p, int v, int t){
                  this.cId=c;
                  this.pId=p;
                  this.value=v;
                  this.tag=t;
          }
  }
  </code></pre>
  
  <p>I've collected lots of data, constructed objects as in the above class and seralized them to disk. </p>
  
  <p>One dump thing I've forgotten to include in the class file is methods to access the values for each object. For example, to access the cId value for a particular object.</p>
  
  <p>I modified the class definition to add such methods but then I could not deseralize the objects back to Records class and get this runtime error:</p>
  
  <pre><code>java.io.InvalidClassException: Records; local class incompatible: stream classdesc serialVersionUID = -1232612718276774474, local class serialVersionUID = -8244963718951538904
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1600)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
      at DeSerialise.main(DeSerialise.java:21)
  </code></pre>
  
  <p>I think I need to tell java that they are <em>the same</em> definitions and modify the serialVersionUID but not quite sure how? any idea would be welcomed!</p>