Article ID | Journal | Published Year | Pages | File Type |
---|---|---|---|---|
418348 | Computer Languages, Systems & Structures | 2014 | 17 Pages |
•A finer grained annotation model for Java that supports annotations on expressions and statement blocks.•An extension to the standard annotation model to support annotation׳s members of any time that can be evaluated at run-time.•Several case studies included an extension of AspectJ that supports the new annotation model.
The ability to annotate code and, in general, the capability to attach arbitrary meta-data to portions of a program are features that have become more and more common in programming languages.Annotations in Java make it possible to attach custom, structured meta-data to declarations of classes, fields and methods. However, the mechanism has some limits: annotations can only decorate declarations and their instantiation can only be resolved statically.With this work, we propose an extension to Java (named @Java) with a richer annotation model, supporting code block and expression annotations, as well as dynamically evaluated members. In other words, in our model, the granularity of annotations extends to the statement and expression level and annotations may hold the result of runtime-evaluated expressions.Our extension to the Java annotation model is twofold: (i) we introduced block and expression annotations and (ii) we allow every annotation to hold dynamically evaluated values. Our implementation also provides an extended reflection API to support inspection and retrieval of our enhanced annotations.