Attribute-Oriented Programming with Java 1.5

From Peeking Inside the Box.

An interesting look at the addition of annotations to the next generation Java. Not sure what the main purpose of this metadata is, but the author discusses it in terms of debugging and instrumentation.

Annotation definitions look a lot like interface definitions, but the keyword @interface is used instead of interface and only methods are supported (though they act more like fields).

   public @interface Status {
       String value();

I can now define my method as follows:

   @Status("Connecting to database")
   public void connectToDB (String url) {

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

.Net Attributes

It's probably just that .Net has attributes, and Java can't fall behind.

The meta-programming in the article seems very clunky. Nemerle has macros for this kind of thing, although it's a bit of a work in progress. And of course you can probably do it brilliantly in Lisp.