|
In computer programming, a Java annotation is a way of adding metadata to Java source code that can also be available to the programmer at run-time. Many times it is used as an alternative to XML technology. Computer programming (often shortened to programming or coding) is the process of writing, testing, and maintaining the source code of computer programs. ...
Metadata is data about data. ...
Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ...
In computer science, runtime describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). ...
The Extensible Markup Language (XML) is a general-purpose markup language. ...
Java annotations can be added to program elements such as classes, methods, fields, parameters, local variables, and packages. Unlike tags added to Java documentation and processed with tools such as XDoclet, Java annotations are completely accessible to the programmer while the software is running using reflection. XDoclet is an open-source code generation library which enables Attribute-Oriented Programming for Java via insertion of special Javadoc tags. ...
In computer science, reflection is the process by which a computer program of the appropriate type can be modified in the process of being executed, in a manner that depends on abstract features of its code and its runtime behavior. ...
History Java annotations were introduced to the Java Community Process as JSR-175 in 2002 and approved in September 2004. Annotations became available with the JDK version 1.5. The feature was added to the Java language through the specification. The Java Community Process or JCP, established in 1995, is a formalized process which allows interested parties to be involved in the definition of future versions and features of the Java platform. ...
The Java Development Kit (JDK) is a Sun product aimed at Java developers. ...
Processing When Java source code is compiled, the Java compiler stores annotation metadata in the class files. Later, the JVM or other programs can look for the metadata to determine how to interact with the program elements or change their behavior. A Java virtual machine or JVM is a virtual machine that runs Java byte code. ...
Syntax Declaring an annotation is a variation on tags that have been added to comment sections in the past. Annotations take the form of an interface declaration with an @ preceding it and optionally marked with meta-annotations, as shown below: @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) In the above example both Retention and Target are examples of annotations..
Impact and Perception Pros - Declarative programming
- Annotations allow the programmer to declare in their source code how the software should behave. It is an example of how declarative programming constructs can be added to an object oriented language.
Cons - Performance
- Adding metadata to a run time causes additional memory overhead.
- Standards lack
- There are few standards that dictate what metadata tags should be used.
See also Java is an object-oriented programming language developed primarily by James Gosling and colleagues at Sun Microsystems. ...
Model-Driven Architecture (MDAâ¢) is a software design approach that its sponsor, the Object Management Group (OMG)[1], officially launched in 2001. ...
A Java Virtual Machine (JVM) is a set of computer software programs and data structures which implements a specific virtual machine model. ...
Visual overview of the Common Language Infrastructure (CLI) The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft . ...
References External links |