Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

load the object class  RSS feed

 
John Lu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i'm new to RMI. why do we have to load the class of object after moving this object from one JVM to another?
thanks advance.
John
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't actually required to do this. But, if the transdfer of the object is going to be meaningful, you probably want to.
What's happening is your object is getting sent across the wire in serialized form. Deserialization with no additional help presents the receiving side with a java.lang.Object-refereneable thing off the wire, so to speak.
To cast the object back to its original class, it stands to reason the receiving JVM must load the defining class to perform the cast. So you could say:
Object obj = Naming.lookup("rmi://juniper:1099/SpeakToMe");
in which case you have the concrete implementation you expect, but no way to invoke the behavior normally associated with it. Serialized objects don't store the class file, so the receiving JVM must have it available to load and perform:
MessageThing mt = (MessageThing)Naming.lookup("...");
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!