Proposed Annotations Enhancements
I think these should make for a nice extension to the existing Java 5
From an Annotation, one should be able to navigate back to the programming element that it annotates.
For example, a method annotation clearly marked with a Target
of ElementType.METHOD cannot say getAnnotatedElement().getName(),
There are two problems here. The first is the lack of the
The second is the fact that an AnnotatedElement is too primitive
of an interface. You cannot actually invoke getName() on an
annotated element. I feel that there should exist a basic
ProgrammingElement implemented by or extended by all annotated
The default value for an annotated element should not be restricted
to a constant expression. Instead, the value should be a code block.
For example, let's assume that I want to annotate methods to
give them a caption. By default, the caption should be some
kind of derivation from the method name it is bound to.
@MyMethodAt(caption="The X Method")
public void method x()
public @interface MyMethodAt
public String caption()
return getAnnotatedElement().name(); // see 
As far as I know, this is currently not possible.
* Entry cross-posted on my personal weblog