On Sun, Feb 14, 2010 at 4:36 AM, Jaroslaw Odzga <[email protected]>wrote:

> 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.


Since Externalizable is an interface, all its methods are necessarily
public.


> 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'm pretty sure that's not true.  Effective Java, for example, suggests
using immutable classes as a security measure, which would be a terrible
suggestion if they were not really immutable.


> 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
> ;-)
>

As it turns out, someone inside Google is working on this now, so if it is
reasonably possible it should be in the next release.


>
> Regards,
> Jarek
>
>
> On Fri, Feb 12, 2010 at 9:47 PM, Kenton Varda <[email protected]> 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 <[email protected]> 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<protobuf%[email protected]>
>>> .
>>> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to