July 02, 2004

Annotations in J2SE 5.0

LtU links to an article by Don Shwarz which explains the new annotation syntax in J2SE 5.0 (the release formerly known as "J2SE 1.5") and gives some examples of how they might be used. While I can see the immediate benefit of annotations to help with code generation and instrumentation, and I can even see where this could make some very clever tool integration easy, I have reservations. I think this has the potential to encourage ugly, unmaintainable code dependent on the spelling of a weakly typed attribute. I'm concerned that this is just a response to pressure from the .NET camp by adopting one of the slimiest mutants lurking in the MS can of worms. Annotations solve a problem which could have been solved better by adding a little syntactic sugar to truly support bean attributes. Why not just remove the need for all of that verbose getX/setX stuff with a "writable" keyword to be used in the variable declaration. The compiler could even generate default accessors and mutators if they aren't otherwise declared in the class for compatibilities sake.
All in all, I think this addition to the language is useful, but ripe for abuse. For instance, I'm certain this will encourage even more java<->XML nastiness. ;)

Attribute-Oriented Programming with Java 1.5 | Lambda the Ultimate

(disclaimer: I work for Sun, but my opinions don't even remotely represent those of Sun Microsystems Inc.)

Posted by bill at July 2, 2004 07:53 AM
Comments