From Effective Java 2/e by Joshua Bloch
A marker interface is an interface that contains no method declarations, but merely designates (or “marks”) a class that implements the interface as having some property. For example, consider the Serializable interface.
Advantages Marker interfaces
- Marker interfaces define a type that is implemented by instances of the marked class; marker annotations do not.
- Marker interfaces can be targeted more precisely.
Advantages of Marker annotations
- It is possible to add more information to an annotation type after it is already in use
- Marker annotations are part of the larger annotation facility
When to use?
- You must use an annotation if the marker applies to any program element other than a class or interface
- If you want to define a type that does not have any new methods associated with it, a marker interface is the way to go.
- If you want to mark program elements other than classes and interfaces, to allow for the possibility of adding more information to the marker in the future, or to fit the marker into a framework that already makes heavy use of annotation types, then a marker annotation is the correct choice.