Saturday, April 21, 2007


Annotations do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time.

They allow you to define metadata in a typesafe way and apply it to a class, method, constructor, field, or parameter.

So what can use use annotations for? Some people envision using annotations for code generation and a replacement for XDoclet. Others, like the J2EE and EJB 3.0 expert groups, see it as a replacement for deployment descriptors. Furthermore, annotations can be used with AOP.

No comments: