Hi all, I have a interface that I like to use with RMI, and one of the parameters to a method (i.e. methodX) in this interface is an Object. But since Object doesn't implement the Serializable interface, I'm getting java.io.NotSerializableException exception. And I can't really change the type of the paramter, because I'll be passing different objects to this method (methodX) such as String, as well as objects I created. Does anyone know of a solution around this problem? Any suggestions would be appreciated! thanks.
Well, can't you simply let the parameter type be Serializable instead of Object?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: May 13, 2002
No because the method takes different objects as arguments, such as String, and String is derived from Object... not Serializable. And Serializable is an emtpy interface, so its not the best interface to use as argument. :roll:
No because the method takes different objects as arguments, such as String, and String is derived from Object... not Serializable.
String implements Serializable, so Ilja's suggestion will work. And Serializable is an emtpy interface, so its not the best interface to use as argument. If you want to enforce that an argument must be serializable, then using the Serializable interface as an argument type makes perfect sence. [ June 06, 2002: Message edited by: Brent Worden ]
I often wonder why they didn't make java.lang.Object serializable ??? that would make life alot simpler imo! The things you don't want to be serializble (if nescessary) can still be made 'transient'
Joined: May 13, 2002
Sorry for the causing some confusion regarding my question, and I do agreed that I could make the interface accepts "Serializable" as an argument, and everything would be fine, but I do want to limit the argument to a certain type, not just any serializable objects. And I believe there's a page on sun's site about why they chose to leave out Serializable from Objects, so prolly find the best explanation of such there
Joined: May 05, 2000
If object was Serializable then every object would be Serializable!