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 ([EMAIL PROTECTED])
IBM Java technology centre, UK.

Reply via email to