Name: rm29839 Date: 11/21/97 One of the good things about using the Externalizable interface over the Serializable interface is that with the former it is possible to control the layout of the data stream that represents the stored object. An Externalizable class should therefore be able to handle data streams written from previous versions of itself. Many people documenting Externalizable say that this is possible. In fact, however, it does not seem to be. This is because the Externalizable classes have the same header added to the front of them as Serializable ones. This header is created by the ObjectStreamClass for all Serializable (therefore also Externalizable) objects. This means that when I write my version number out from my Externalizable class I am not doing anything useful. Because if I ever change my class (insofaras I add/delete public fields or methods) I will not be able to read the streams from the older version of the object because the hash code based on the fields etc,. will have changed. I will be able to read only the streams created by the new version of the class. What I would like is for there to be a new interface. People wanting the kind of control I describe could then implement this interface as well as the Externalizable interface, or else instead of it. If this interface were called Versionizable. An object that was Versionizable would have no version number written out in the header at all. Versionizable could extend Externalizable. But a header would still be written to hold the class name and so the readObject system would still work with it. Also, from Bug ID 4054452, you could also have another interface that resulted in no header being written to the object stream at all. I'm not sure how you would read such an object back in, but there you are. I am reporting this because it has stopped me from using the Externalizable interface and I have had to implement my own way of doing the same thing. I may be missing something here but I not sure. Thanks. (Review ID: 20440) ======================================================================
|