I'll have to disagree :-) Serialization is not a way of mutating objects and
Externalizable is thought to be just an efficient Serialization.
readExternal() is not a public method anyway. Obviously, if you want you can
use it to mutate the object, but if you like you can mutate even perfectly
final and immutable objects in Java (using some trickery). I think
Serialization is just alternative way of creating objects and it is
perfectly ok to serialize immutable objects e.g. String is immutable and
Serializable. I would go ahead and make Protocol Buffer classes serializable
;-)

Regards,
Jarek

On Fri, Feb 12, 2010 at 9:47 PM, Kenton Varda <ken...@google.com> wrote:

> Message objects are immutable.  Unfortunately, readExternal() -- specified
> by the Externalizable interface -- is a mutating method.  Implementing it
> would destroy the immutability guarantee, possibly introducing bugs or even
> security problems.  Is there a way around this?  I admit I'm no expert on
> Java serialization (as you might guess, I don't use it! :) ).
>
> On Fri, Feb 12, 2010 at 2:32 AM, yahro <jarek.od...@gmail.com> wrote:
>
>> Hi,
>>
>> Is there something preventing Protocol Buffer Java classes from being
>> serializable e.g. using java.io.Externalizable? I would like to use
>> Protocol Buffer classes to store data in caches, data stores etc.
>> Currently I have to write awkward custom serializers while it seems,
>> that it would be enough to add  add two methods, implement
>> java.io.Externalizable interface and classes would be efficiently
>> serializable. Am I missing something?
>>
>> Best regards,
>> Jarek
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To post to this group, send email to proto...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/protobuf?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to