This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Annotations and marker interfaces are pretty much used for the same purpose, however annotations can be used on class,method or variable whereas marker interfaces can be used only on classes , maybe the only disadvantage of marker interfaces over annotations.
Sean, my point is, couldn't they have implemented it without forcing you to use interfaces?
The link you pointed me to is a bit much for me to go over it right now, and I'm not familiar with the validation described therein.
You can engineer any situation to require marker interfaces, and it gives them a purpose, but not an advantage. I think the use of marker interfaces is pure abuse of the language.
The sheer fact that they are named separately because they are being used for a different purpose than they were originally intended, doesn't speak in favour of them.
One of these days I'll change the forum software to force anyone who wants to use "marker interface" in the subject line of a new post to read at least 10 previous topics on the subject (which are easily found through the site search).
Marker interfaces, such as Serializable, have the same function as annotations - they are used to specify certain properties (metadata) of classes, methods, fields etc.
I can understand Stephan when he says that this is abuse of the language - the main purpose of interfaces is to specify a set of methods that a class must implement. Somebody came up with a different usage - for providing metadata, and so the idea of marker interfaces was born.
The main purpose of annotations is exactly to provide metadata, so you should prefer to use annotations for that, and not marker interfaces.
Annotations are also more flexible than marker interfaces. Annotations can have parameters and can not only be applied to classes, but to methods, fields etc. as well. So, there you have a disadvantage of marker interfaces, when compared to annotations.