Java Annotations

Why do we use Annotations?

Annotations give information about the java program and is not part of the program itslf
They give inforamtion to the compiler for Compiler time processing, deployment time processing and runtime processing

Some of the annotations are


public class MyClass{}

public void myMethod(){}

public void run(){}

public void printWriter(){}

There are two types of annotations

Simple and Meta Annotations

Simple Annotations – provided by JDK5

* Override
* Deprecated
* Suppresswarnings

Meta Annotations – Annotations of Annotation

* Target
* Retention
* Documented
* Inherited

Target – target element for which the annotation is applicable

* @Target(ElementType.TYPE) – applied to any element of a class
* @Target(ElementType.FIELD) – applied to a field or property
* @Target(ElementType.METHOD) – applied to a method level annotation
* @Target(ElementType.PARAMETER) – applied to the parameters of a method
* @Target(ElementType.CONSTRUCTOR) – applied to constructors
* @Target(ElementType.LOCAL_VARIABLE) – applied to local variables
* @Target(ElementType.ANNOTATION_TYPE) – indicates that the declared type itself is an annotation type

Retention – how long the annotations should be retained

* RetentionPolicy.SOURCE – retained only at the source level and will be ignored by the compiler
* RetentionPolicy.CLASS – retained by the compiler at compile time, but will be ignored by the VM
* RetentionPolicy.RUNTIME – retained by the VM so they can be read only at run-time

Documented – should be documented in by the javadoc tool

Inherited -annotations of the parent class is inherited to the subclass

2 thoughts on “Java Annotations

  1. Kely

    I am really inetersted in ADF Integration with BPM. Does it mean I can create an ADF Application to modify decision tables defined in BPM. A techincal how-to from you would be really helpful.

  2. Bob

    Hi, How can I return to a view after a Task Flow Return Activity?For eaxlpme:”After commit, the user is redirected to another view activity…” But I can`t put a Control Flow Case from a Return to a view…I’m waiting to hear from you Andrejus.Thanks, Take Care! Regards.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s