title: Preventing Java serialization setting default values
body: <p>I have a serialized object MyObject that contains integer foo. I set a value 10 to integer foo and save the object to a file using writeObject().</p>
  
  <p>I add integer bar to object MyObject. I set a value 15 to integer bar and then load the old serialized file using readObject().</p>
  
  <p>The old serializable file doesn't contain integer bar so integer bar will get value 0. I want to keep the value 15 in bar if the old serializable file doesn't contain variable bar.</p>
  
  <p>Should I override readObject() or how could I prevent readObject() from setting "default values" to unknown objects?</p>
  
  <p>I want to do this because in the constructor I'm setting my own default values and would like to use my own default values to control versioning.</p>