harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [classlib][swing] Serialization of Swing classes
Date Sat, 11 Nov 2006 22:11:53 GMT
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.

Regards,
Tim

-- 

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

Mime
View raw message