This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
i was reading an article today and it said it is important to give serialVersionUID variable to your class which we think will be required to serialize. My question are given below
1.) what will be the problem we will face if we do not give serialVersionUID in our serialized java class (i know java will create one for us if we dont give but what is the actual significance)
2.) I got to know that serialVersionUID should be unique in our class and there is a serialVer utility from java which create a unique number for every class. now my question is i give every serialized class the same serialVersionUID, what problems we will face during serialization and de-serialization process.
serialVersionUID is used by Java Serialization mechanism to detect if the target object was modified during serialization/deserialization process. If you will try to cast deserialized object to it's original type and JVM will see, that serialVersionUID differs in class definition and in inctance variable of an object, it will cast InvalidClassExceptions.
The problem with autogenerated serialVersionUID is that it is being generated on the base of some iformation about the class that JVM has and may differ from one version of JVM to another, so you can have collisions serializing your objects on one system and trying to deserialize them on other.
Not necessarily. I've never had that warning when compiling from the command line. In Eclipse I do get that warning, but you can turn it off if you want. I believe the default is off, but I can't remember.