• Post Reply Bookmark Topic Watch Topic
  • New Topic

An interface that extends Serializable

 
Rob Bass
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am able to serializable out an interface that is extends serializable:
public interface EventSubscriber extends Serializable
but when I try restoring these classes I get a:
java.io.StreamCorruptedException
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1301)
I have been researching this issue on google but I cannot find a definitve answer, I read on a few postings that this only works if the class that implements the above interface has a no-arg constructor to initialize the class's state?
Please let me know if you havce any mor information.
Thanks,
Rob
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you have defined a constructor that isn't the no-arg default, then you must define that no-arg constructor. This is of course for the class implementing your EventSubscriber interface. If you haven't defined a constructor for that implementing class, then is there perhaps some other object that the object is using that is not serializable?
Also, perhaps you could show a little bit of code if possible? Might help in defining the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!