I also agree, +1 for defining SUIDs externally.

Thanks,

2006/11/14, Stepan Mishura <[EMAIL PROTECTED]>:
On 11/13/06, Ivanov, Alexey A  wrote:
>
> >-----Original Message-----
> >From: Tim Ellison
> >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?


+1

--
Alexei Zakharov,
Intel Enterprise Solutions Software Division

Reply via email to