Passing non-serializable Objects?
2 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, January 16, 2002 01:33 PM

I just cant believe that there should be no possibility to pass an object of type Area with RMI. Can anyone tell me how i am able to pass an instance of for example:

class myObject {
String Message;
Area oArea;
Color oColor;

Thank you very much!

Re: Passing non-serializable Objects?

Posted By:   Sean_Ruff  
Posted On:   Friday, February 22, 2002 10:57 AM

You could implement the Serializable interface and implement the readObject and writeObject methods to handle your explicitly Area object.

class myObject implements Serializable {
String Message;
transient Area area;
Color oColor;

private synchronized void writeObject(java.io.ObjectOutputStream stream) throws java.
io.IOException {
stream.defaultWriteObject( );

private synchronized void readObject(java.io.ObjectOutputStream stream) throws java.
io.IOException {
area = new Area((Rectangle)stream.readObject());


The default methods will attempt to handle all member variables not marked transient. Then you have to read read/write the Area object as a Rectangle object.

Hope this helps.

Re: Passing non-serializable Objects?

Posted By:   Edward_Harned  
Posted On:   Thursday, January 17, 2002 07:34 AM

Class myObject implements java.io.Serializable
About | Sitemap | Contact