They just tell the compiler that the objects of the classes implementing the interfaces with no defined methods need to be treated differently. Example java.io.Serializable, java.lang.Cloneable, java.util.EventListener etc. Marker interfaces are also known as �tag� interfaces since they tag all the derived classes into a category based on their purpose.
Thank you All. Would like to know what exactly does the approach of JVM/Compiler towards the MarkerInterfaceImplementer class will change the implementer class' compilation or execution. What will the JVM/ Compiler do by knowing this? What is really achieved by letting the JVM/Compiler know about this behaviour of the implemented class?
By special behavior it means that,for example say, Serializable, JVM will know that the class implementing Serializable, the state of the object of the class can be saved.
By saving the state we mean that the JVM can write the state of object(that is defined by the value of the instance variables) to a file or the serialized object can be shipped to an another place, say over the wire to another machine and can be de-serialized.
This property of an object being serialized comes when the user tells the JVM that the class which he/she is writing is Serializable.And when the user serializes the object, rest of the work is done by the JVM internally,as it is pre declared that the Object being serialized is of sreializable type.It gets the special treatment of Serialization.
Joined: Oct 13, 2005
But (I think the FAQ points this out) now that annotations are available, people will no longer create new marker interfaces. Marker interfaces are also sometimes called tagging interfaces.