On Mon, Nov 17, 2008 at 11:15 AM, Axel <[EMAIL PROTECTED]> wrote:
> Here's the code that seems to be doing the serialization of a byte[]
> object, from
> com.google.gwt.user.client.rpc.core.java.lang.Byte_CustomFieldSerializer:
>
>  public static void serialize(SerializationStreamWriter streamWriter,
>      Byte instance) throws SerializationException {
>    streamWriter.writeByte(instance.byteValue());
>  }

Nope.  That's the serialization code for a java.lang.Byte, which is
the wrapper type for bytes.  byte[] (an array of primitive bytes) is
serialized somewhere else, although I'm not sure exactly where.
(Maybe in a class with Array in its name?)

> and then
> com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter:
>
>  public void writeByte(byte fieldValue) {
>    append(String.valueOf(fieldValue));
>  }
>
> I take it that this creates a new String object for each byte in the
> byte[]. Furthermore, the encoding is a decimal numeric string,
> presumably prefixed with the type code used for the byte type during
> serialization which seems to be the class name ("java.lang.Byte").

The string "java.lang.Byte" should only be in the stream once and then
only if there's an instance of java.lang.Byte in the stream.  Each
reference to the string is by index.  I think, though, that a byte[]
is probably serialized as some kind of type identifier (it might be
"[" followed by the one-character shorthand for a primitive byte
followed by ";"), followed by the length of the array as a decimal
integer, followed by the elements of the array as decimal integers.

Ian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to