Saturday, March 24, 2012

Serialization Update 2

Hi,

Well, the serialization fiasco has mostly been figured out.

It turns out that yes, my serializer does work.  Moreover, it works perfectly, and everything would be good . . . except that the deserializer does not.  As it happens, Java's deserialization is, put simply, broken.  There's nothing for it.  In real life (C++) I'd use a copy constructor, and that would be the end of it, but Java apparently can't handle that.

Unfortunately, the deserializer doesn't, and can't work, unless the GWT designers had thought of it, which they didn't.  We'd be stuck, except Joe Collard put into words what I was coming to the realization was necessary (on same post by Nialls mentioned previously, here): "see if you can write a wrapper that contains all of the things you will want saved".

Essentially, the idea boils down to: write your own serializer.  It's bloody messy, but Java's (de)serialization is broken and reflection isn't supported by GWT.  So, we have to go with it.

No private/protected fields can, of course, be serialized.  Hopefully this shouldn't be an issue.  It appears to have worked for Joe's group, so hopefully it will work for ours.

Ian

No comments:

Post a Comment