• Post Reply Bookmark Topic Watch Topic
  • New Topic

class file required for deserialization?

 
Gopi Chella
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a JVM to be able to deserialize an object, it must be able to find the bytecode for the class. If the JVM can't find a class during the deserialization of an object, it throws a ClassNotFoundException.


Is that above statement is true ? if so, if i write the state of an object into a file then if i try to deserialize the same on some other system( ex: Home destktop to office Laptop) then what will happen ?

should i have the classfile of the object on remote system(here Office Laptop) which i am going to deserialize ? bit confusing
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gopi, this statement is very true. Not only you will require the same class also it should have the same package version name(serial id). If you happen to have one project where you serialize or cache or send it through network and some other project wants to read this object it should have the same class to deserialize it. You can skip transient fields. try this. Good luck.
 
Gopi Chella
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!