Lately I have been dabbling around with Java Annotations that where introduced with Java 1.5. I didn’t really know much about it before, although I could see the usefulness from having used XDoclet years ago, which however flawed it was, was actually quite useful at the time.
My impression? Well, mixed. As far as I can understand from my limited exposure, you actually have to write the annotation processing yourself for your custom annotations, which invariably leads you to use reflection in some shape or form in most cases. This to me makes annotations feel a bit like some half-baked attempt at AOP, but without really taking it even a third of the distance.
On the plus-side though, I can see the usefulness of annotations given you have the annotation processing present, or can live with writing it yourself: Java has long been infested with a need to use various properties files or xml-configuration files for things that live in the twillight land between things that need to be soft-configurable, yet form an integral part of the application logic. Hard coding this kind of stuff is definitely wrong, but having lots of xml configurations doesn’t feel right either. In this kind of scenario annotations feels like the perfect middle ground: you annotate a class with metadata. To me this feels perfect for things like validation of fields through getters, or even configuring page-flows and actions in a MVC-framework (Something Stripes kind of does).
So to sum it up, I think annotations has its place, they are definitely a useful addition to the Java language, however I cannot stop the feeling that Sun could really have done much better, there is a smell of it being a half-baked and half hearted attempt at AOP, while lacking the energy and will to go the full distance.