• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serializable marker interface  RSS feed

 
deepakagarwal agarwal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i create a interface that can be implemented just like serilaizable interface.
I don't wan either to implement Serializable interface or extend any class.
by my interface.
Marker interface doesnotconatins any method declaration.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is not very clear (is your space-bar broken?!), but I suspect it does not belong in Advanced forum.

Are you just asking how to create a marker interface? If so, that's just a question of creating an interface with no members.

Identifying whether an object supports a marker interface is a trivial application of "instanceof" operator.

It sounds as if you want to duplicate the serialisation mechanism - why? The serialisation mechanism has, I believe, a few "magic" hooks into the JVM, which you'd struggle to replicate in your own code. Most of it is just pure Java, though, and you can look at it in the JDK source.

If you want to do something like serialisation, but with more control, you could read up on Externalizable interface. This is part of the serialisation mechanism, but more of the implementation is up to you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!