serialization with rmi

Hi!
1. If i try to move an object that is not serializable through the net, the only thing i get is exception about this?
2. If i want to move an object by value and not by remote reference, i have not to declare it as inplements Remote. Is it the only way to do so?
Thank you!
rzvika3Asked:
Who is Participating?
 
jerchConnect With a Mentor Commented:
An object that is passed as value in rmi should implements Serializable.  Hence, the attributes of the object also need to implement Serializable.

Hope this helps.

Jerson
0
 
rzvika3Author Commented:
and question 2?
0
 
jerchCommented:
Yes, if you want an object to passed as value simply do not implement the Remote interface instead implement the Serializable interface.  This is required by the RMI specification.  All return value and arguments must implement Serializable if its passed by value.

Always take note that transient and static fields are not passed by value instead it is reinitialize to its default value.

For example, you have an object with a static int fields that contains 5.  If you passed the object to the client or server.  The value it will receive is the default value or the initial value.  


0
All Courses

From novice to tech pro — start learning today.