• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

Help with Serialization

Hi,

I am using Serialization to develop an application.  I am aware that if you change the application, there are issues with it.

How does one overcome this in the development phase.   I.e. As I am currently developing the application it is being changed. For example - the first part of the application that I am developing is for loading and saving the pick lists.  This will be used for all other components of the applications.  So if I create all the pick lists I worry that I will have to recreate them all again as I will not be able to load it.

Any help tips?
0
amacfarl
Asked:
amacfarl
1 Solution
 
ksivananthCommented:
if the class is not modified, you won't have any issue. If you expect the class to be modified in future why don't you extract and store the data in XML?
0
 
amacfarlAuthor Commented:
what happens if the attributes are not modified but the methods are?
what happens if the class is not modified, but sub classes are?
0
 
ksivananthCommented:
>>what happens if the attributes are not modified but the methods are?

I think, there will be issues...

>>what happens if the class is not modified, but sub classes are?

No issues, as long as you ser and deser into same class.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CEHJCommented:
You should use a build tool such as Ant to automate the building and deploying ot the app so you can keep careful control of the binaries
0
 
pellepCommented:
Serialization compatability at runtime is determined by the serialVersionUid. It's a field in the class that, if you don't declare it explicitly, gets generated by the compiler for you if you implement Serializable. The significance of the field is central. If you attempt to deserialize an instance of a class and the serialVersionUids doesn't match on the deserialized form and the class definition, you will get an InvalidClassException thrown at you.

Different compilers have different strategies regarding the computation of this field. Some may modify it any time you change the class, some are smarter and will only modify it if you make changes that affect serialization, like changing the name or type of a field in the class.

To control this yourself, declare the servialVersionUid explicitly in the class you are serializing, like

private static final long serialVersionUID = 7526472295622776147L;

Don't modify it unless you are releasing a new version of the class that you know won't be able to deserialize and older version (for instance changing names or types of fields). Take care when you override this though, since you're essentially telling the JRE that "don't worry about version compatability, I know what I'm doing".
0
 
objectsCommented:
manage your serialVersionUID as pellep has mentioned above
http://www.javapractices.com/Topic45.cjp

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now