An old version of a Java app, running under v1.3.1 JRE, serialized a
class which was a descendent of javax.swing.table.AbstractTableModel.
I wish to deserialize this class under a v1.4 JRE. As the manual
warned, this is not possible as AbstractTableModel is not
deserializable across major versions.
Upon closer examination, the class in question doesn't really have to
descend from AbstractTableModel (and it shouldn't have in the first
place!). Merely deserializing the extra fields will be enough to get
stuff working in the later version. ie
class MyChildClass extends AbstractTableModel {
public Integer theDataIWantToUseAgain;
public int getRowCount() { ... }
... // a.t.m. methods overriden.
}
... it would be fine to deserialize this as
class MyOrphanedChildClass {
public Integer theDataIWantToUseAgain;
}
How can I subclass ObjectInputStream / implement readObject / use a
3rd party piece of code to do this?
There is no question of re-serializing this class: it is best to think
that the entire old version of the app has been lost apart from the
relevant classes involved in this serialization. The only code
changes can be on de-serialization side of the the problem, running
under JRE 1.4
Overriding ObjectInputStream.resolveClass() to return a correct
version of AbstractTableModel fails, because the ObjectStreamClass
which represents my serialized class performs a serialVersionUID check
on the serialized class, which throws an exception.
I cannot use a new kludged version of ObjectStreamClass because it is
private to the java.io package
I don't mind ugly hacks (this doesn't have to be a general solution!);
this must be possible in some way I believe. |