Bug 277113 - serialVersionUID should be rebuild/invalidated on class' members change
Summary: serialVersionUID should be rebuild/invalidated on class' members change
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-20 07:00 EDT by Evgeniy Karyakin CLA
Modified: 2009-10-05 10:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeniy Karyakin CLA 2009-05-20 07:00:26 EDT
Build ID: M20090211-1700

Steps To Reproduce:
1. Create new serializable class.
2. Generate serialVersionUID field as java.io.Serializable and IDE suggests.
3. Do any of the following in this class:
3.1. Create new method.
3.2. Create new field.
3.3. Change any existing method's signature (name or argument(s) type(s))
4. serialVersionUID now became invalid although IDE don't warn you.


More information:
Don't know if recalculation of serialVersionUID should be done as soon any relevant class changes made, or on file save event, or periodically in the background (sudden error appearing "from nowhere" will be confusing for user). For me it's uncomfortable to always remember that I should manually recalculate that fields. I think it's IDE job, and essential one, 'cause without it it would be hard to fix unexplainable deserialization errors during later runtime.
Comment 1 Olivier Thomann CLA 2009-06-08 11:53:56 EDT
It depends what you want to do.
You might not want to change the serialVersionUID if you want to keep backward compatibility with existing persisted instances of this class.
Comment 2 Evgeniy Karyakin CLA 2009-06-08 12:27:28 EDT
Agree.
Then IDE may have a warning on serialVersionUID field just like it has it on Serializable class which has no serialVersionUID field at all. And make it possible to switch this warning off just like "Serializable class without serialVersionUID: Error/Warning/Ignore" Java compiler option.
Plus there will be a little use of keeping backward compatibility when you change class' elements old clients depend on, they will break anyway.