harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivanov, Alexey A" <alexey.a.iva...@intel.com>
Subject RE: [classlib][swing] Serialization of Swing classes
Date Mon, 13 Nov 2006 09:32:40 GMT
>-----Original Message-----
>From: Tim Ellison [mailto:t.p.ellison@gmail.com]
>Sent: Sunday, November 12, 2006 1:12 AM
>To: harmony-dev@incubator.apache.org
>Subject: Re: [classlib][swing] Serialization of Swing classes
>
>Nathan Beyer wrote:
>> Runtime optimization - I'm not positive of this, nor do I completely
>> understand the actual affect, but wouldn't explicit
'serialVersionUID'
>> fields mean that when those classes are actually serialized, a UID
>> wouldn't need to be generated at runtime, correct? Now, I'll be the
>> first to admit, this is a micro optimization, so it doesn't carry to
>> much weight. However, I am curious about the details of the reality
>> behind this thought, so if anyone knows, please post.
>
>Take a look at the effect of "java.io.ObjectStreamClass#lookup(Class)"
>for types that have a SUID field and those that don't.
>
>The actual work is done in
>ObjectStreamClass#computeSerialVersionUID(Class, Field[]), which scans
>the fields looking for a serialVersionUID field first, and computing it
>if not found using some non-trivial algorithm.
>
>The lookup result is cached, so any saving will be only on the first
>time the class is seen.  Whether the computation is noticeable will
>depend upon the set of classes of objects being serialized as well as
>the presence (or absence) of the SUID field.

Actually I don't mind having SUIDs declared in classes. Though IMHO
without declaring this field, we communicate to developers serialized
form of this class is not guaranteed to deserialize correctly. OTOH
having looked through the methods Tim pointed, I can say that if classes
declare SUID and one tries to serialize an object, there'll be no time
spent to compute SUID during execution thus improving performance a
little.

Therefore I'm inclined to declare SUID rather than using
@SuppressWarning("serial"). However it may be worth to add a comment
similar to that in the JavaDoc. What do you think?


Regards,
Alexey.

>
>Regards,
>Tim
>
>--
>
>Tim Ellison (t.p.ellison@gmail.com)
>IBM Java technology centre, UK. 

--
Alexey A. Ivanov
Intel Enterprise Solutions Software Division

Mime
View raw message