[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Help with Serialization

Posted on 2007-11-23
6
Medium Priority
?
225 Views
Last Modified: 2010-03-30
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
Comment
Question by:amacfarl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 20338848
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
 
LVL 2

Author Comment

by:amacfarl
ID: 20339001
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
 
LVL 26

Expert Comment

by:ksivananth
ID: 20339025
>>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
Technology Partners: 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!

 
LVL 86

Expert Comment

by:CEHJ
ID: 20339026
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
 
LVL 4

Accepted Solution

by:
pellep earned 1500 total points
ID: 20339143
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
 
LVL 92

Expert Comment

by:objects
ID: 20340827
manage your serialVersionUID as pellep has mentioned above
http://www.javapractices.com/Topic45.cjp

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question