• Post Reply Bookmark Topic Watch Topic
  • New Topic

Implementing serializable interface for reference class  RSS feed

 
ashok sashrith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using a class "CustomValidate.java" in my application. As it is one of the ResultClass (Struts), I have implemented the Serializable interface in the "CustomValidate.java". But still it throws java.io.Serialization exception?

I read from the net that all the class referred inside the Serializable class also needs to implement the Serializable interface to make the object Serializable.

My question is; The "CustomValidate.java" referring two (only following two lines) such external class in a method like the following:

Keys.FirstName (accessing a constant value from Keys.java)
Util.format(FirstName) (Calling a method which is in Util.java)

Does this classes "Keys.java" and "Util.java" also needs to implement the Serializable interface? Please suggest.

Thanks in advance.

Ashok
[ February 22, 2006: Message edited by: ashok sashrith ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, neither of these cases should be a problem. You should get a Serialization error only if you have a member variable of a non-serializable type, or a member variable of a type which itself contains a reference to a nonserializable type, and so on. For example, you might have a member of type ArrayList (which is serializable) holding a bunch of Socket objects (which are not.)

Maybe you can show the code for this class?
 
ashok sashrith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest and here is the code for the same.



Hope it helps. Thanks in advance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!