Wednesday, October 24, 2007

Serialization and ClassLoading

Do we need the Class in the classpath to Serialize an instance of the class? Not really, even if the Class is not accessible, we can get the Class by Object.getClass() method and get required information.
However if the Class referring (using) other classes which are not in classpath. then it will break.
It break when it try to get the SerialVersionUID which internally trying to getDeclaredFields
It would have better if we could have avoid this dependency.
You can download a sample program demonstrating the same here
http://rejeev.googlepages.com/source_code_Serialization.zip

No comments: