title: ObjectStream: is there a way to read serialized object as properties map?
body: <p>Is there any standard way or any utility library to read/navigate through serialized (via ObjectOutputStream) object's properties?</p>
  
  <p>The problem I'm trying to solve is to upgrade data which was serialized using ObjectOutputStream (legacy) and stored in database. In my case some internal fields were drastically changed and renamed. I cannot read object back using ObjectInputStream, as values of changed fields would be lost (set to null).</p>
  
  <p>In particular there may be need to upgrade it again in future, so it would be better if I could replace old data stored this way with XML serialization. But the general way to accomplish this task would require to iterate through properties (their names, types and values). I wasn't able to find a standard way to read such metadata from serialized data (for example, <em>jackson</em> library could read JSON as an object or as a map of properties and maps, which you can easily manipulate).</p>
  
  <p>Is there any low-level library to work with data, serialized with ObjectOutputStream? Resulting output looks like it contains information about serialized field names and their types. As a last resort I could sort out the format, but I've thought that someone could have done this already, yet I wasn't able to find any libraries myself.</p>
  
  <p>For example, I had a class</p>
  
  <pre><code>public class TestCase implements Serializable
  {
      int id;
      double doubleValue;
      String stringValue;
  
      public TestCase(int id, double doubleValue, String stringValue)
      {
          this.id = id;
          this.doubleValue = doubleValue;
          this.stringValue = stringValue;
      }
  }
  </code></pre>
  
  <p>which was changed to</p>
  
  <pre><code>public class TestCase implements Serializable
  {
      ComplexId id;
      double doubleValue;
      String stringValue;
  
      public TestCase(ComplexId id, double doubleValue, String stringValue)
      {
          this.id = id;
          this.doubleValue = doubleValue;
          this.stringValue = stringValue;
      }
  }
  
  class ComplexId implements Serializable
  {
      int staticId;
      String uuid;
  
      public ComplexId(int staticId, String uuid)
      {
          this.staticId = staticId;
          this.uuid = uuid;
      }
  }
  </code></pre>
  
  <p>It is not a problem to upgrade the value itself, I just don't know how to peek it and put back a new one (with a new type) without custom implementation of serialization/deserialization protocol (that's a last resort for me).</p>