Has JDK 1.4 and 1.5 changed the encoding of String objects when
performing serialization? I seem to remember that it used to be a
serialized String occupied ((numChar * 2) + 16) bytes. Hence a four
char String was serialized as 24 bytes to disk (or memory, or
whatever). I find that with JDK 1.4 that four char String is serialized
to 11 bytes and the formula now seems to be (numChar + 7).
Has this changed, or is my memory just bad (could be). If this has
changed, did Sun document this somewhere?
--
garskof
dsjoblom@abo.fi - 07 Aug 2006 19:12 GMT
> Has JDK 1.4 and 1.5 changed the encoding of String objects when
> performing serialization? I seem to remember that it used to be a
[quoted text clipped - 5 lines]
> Has this changed, or is my memory just bad (could be). If this has
> changed, did Sun document this somewhere?
You probably remember correctly. The first figure for 1.4 sounds like
the correct amount of bytes for a serialized object wihout any special
tricks. It seems that in 1.5, strings are written with a special one
byte marker to indicate that the object is a string, the string length
(16 or 32 bits, depending on marker) + the characters encoded in utf8.
Regards,
Daniel Sjöblom