Note that the FAQ entry Wouter linked to states that
you should not create any new marker interfaces; it's what annotations are used for nowadays.
Jesper wrote:The most well-known are java.io.Serializable and java.lang.Cloneable. You can use these on your own classes to indicate that it should be possible to serialize or clone objects of your class.
I agree, yet these two, especially Cloneable, are also a major reason why so many people get confused over the whole issue of marker interfaces.
Cloneable is about allowing access to the
clone method, which is a really weird design: the interface should have had the
clone method in it (thus not being an actual marker interface).
Jesper wrote:(The readObject and writeObject) methods are not defined in any interface anywhere. They are special methods that the JVM recognizes. This doesn't really have anything to do with how marker interfaces work; it's just the way how serialization is built-in into Java.
Yeah, and it's a bad design IMO. Serialization customization should arguably have been left to the
Externalizable interface.