Skip to main content

Like class literal, there must be field, method and annotation literals

No replies
Joined: 2004-11-25

Just like we have 'class literal', for example MyBean.class is a way to get the class name without creating an instance, there must be literals for other elements of the language. For example :

Field Literal : MyBean.myField.field
Method Literat : MyBean.myMethod.method
Annotation Literal :

There may be more of these :

Actually I need this : In Bean-Validation, there is an annotation named Size

public class Customer {
private String customerName;

I need this information in my JSF tags.
In Expression Language, I must be able to write

I know, there will be a solution in JSF for Bean Validations, but this feature may be useful everywhere.

In my opinion, Annotations are very useful, but in order to create new ones, we must use apt, javax.annotation.processing API or Reflection API. If we had a way to directly access the annotations in the way above, it would be very easy to write new annotations and use the existing ones directly.

Annotations carry information, so we need to access them easily. In this current form, data in annotations are only available for API writers.