Information on writeObject, or custom serialization
does anyone have any good information on writeObject, or custom serialization?
I can't seem to find much using gooogle:(
F4te: custom serialization is good, writeObject is evil
do you know of anything which would explain the pros and cons of both and give some examples?
src.zip is bundled with the SDK
one look at the implementation of ObjectOuputStream will make it all clear
k thx
horrible hackjob with amazing overhead would describe it pretty good
it sends giant class signatures noone is interested in, does clumsy caching of object instances.. implementation is an awkward mix of reflection and native hacks
due to the caching ObjectOuputStream is unusable for streaming
only good part is that it has a native hack for instantating objects without invoking any constructors on deserialization
but that's it, rest is worthless
chuck
good grief
hmm, i'm pretty glad you explained that to me ![]()
what would you say is the best way to do custom serialization then?
depends on what you are doing.. but generally serializable classes should have methods for seralizing themselves
rather than trying to make a clone by copying fields with reflection
so implement the writeObject method?
not necessarily _the_ writeObject method
what do you mean?
like make your own writeObject method that doesn't write to an ObjectOuputStream
ah ok
instead it can write to a plain OutputStream or even append directly to a buffer
cool, i'll give it a bash ![]()
thanks