O'Reilly logo

Java 5.0 Tiger: A Developer's Notebook by David Flanagan, Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Annotations

One of the more popular terms being tossed around in programming these days is metadata. Metadata is simply information about information. It resides somewhere in the spectrum between Java source code, which is raw information for a compiler, and JavadocJavadoc, which is pure documentation. Metadata typically makes statements about source code that is interpreted at some point, usually by a code or data analysis tool.

Your first thought might be, “Well, Javadoc takes care of that, right?” Consider this—how many ways are there to say, “This variable should not be null.” In Javadoc, you might say “non-null,” you might say “This variable shouldn’t be null,” you might say “Don’t assign null to this.” All are valid in terms of documentation, but there is no consistency among them. There isn’t any tool that could analyze and account for all the variances in how you might state this simple condition. Annotations, new to Tiger, seek to solve that problem by providing a well-defined metadata mechanism.

In a nutshell, annotations are modifiers that can be applied to package and type declarations, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required