<s>
In	O
the	O
Java	B-Language
computer	I-Language
programming	I-Language
language	I-Language
,	O
an	O
annotation	O
is	O
a	O
form	O
of	O
syntactic	O
metadata	O
that	O
can	O
be	O
added	O
to	O
Java	B-Language
source	I-Language
code	I-Language
.	O
</s>
<s>
Classes	O
,	O
methods	B-Language
,	O
variables	O
,	O
parameters	O
and	O
Java	B-Language
packages	I-Language
may	O
be	O
annotated	O
.	O
</s>
<s>
Like	O
Javadoc	B-Language
tags	O
,	O
Java	B-Language
annotations	I-Language
can	O
be	O
read	O
from	O
source	O
files	O
.	O
</s>
<s>
Unlike	O
Javadoc	B-Language
tags	O
,	O
Java	B-Language
annotations	I-Language
can	O
also	O
be	O
embedded	O
in	O
and	O
read	O
from	O
Java	B-Language
class	I-Language
files	I-Language
generated	O
by	O
the	O
Java	B-Language
compiler	I-Language
.	O
</s>
<s>
This	O
allows	O
annotations	O
to	O
be	O
retained	O
by	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
at	O
run-time	B-Library
and	O
read	O
via	O
reflection	B-Language
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
create	O
meta-annotations	O
out	O
of	O
the	O
existing	O
ones	O
in	O
Java	B-Language
.	O
</s>
<s>
The	O
Java	B-Device
platform	I-Device
has	O
various	O
ad-hoc	O
annotation	O
mechanisms	O
—	O
for	O
example	O
,	O
the	O
transient	O
modifier	O
,	O
or	O
the	O
@Deprecated	O
javadoc	B-Language
tag	O
.	O
</s>
<s>
The	O
Java	B-Language
Specification	I-Language
Request	I-Language
JSR-175	O
introduced	O
the	O
general-purpose	O
annotation	O
(	O
also	O
known	O
as	O
metadata	O
)	O
facility	O
to	O
the	O
Java	B-Language
Community	I-Language
Process	I-Language
in	O
2002	O
;	O
it	O
gained	O
approval	O
in	O
September	O
2004	O
.	O
</s>
<s>
Annotations	O
became	O
available	O
in	O
the	O
language	O
itself	O
beginning	O
with	O
version	O
1.5	O
of	O
the	O
Java	B-Language
Development	I-Language
Kit	I-Language
(	O
JDK	B-Language
)	O
.	O
</s>
<s>
The	O
apt	O
tool	O
provided	O
a	O
provisional	O
interface	O
for	O
compile-time	B-Application
annotation	O
processing	O
in	O
JDK	B-Language
version	O
1.5	O
;	O
JSR-269	O
formalized	O
this	O
,	O
and	O
it	O
became	O
integrated	O
into	O
the	O
javac	B-General_Concept
compiler	O
in	O
version	O
1.6	O
.	O
</s>
<s>
Java	B-Language
defines	O
a	O
set	O
of	O
annotations	O
that	O
are	O
built	O
into	O
the	O
language	O
.	O
</s>
<s>
Of	O
the	O
seven	O
standard	O
annotations	O
,	O
three	O
are	O
part	O
of	O
java.lang	O
,	O
and	O
the	O
remaining	O
four	O
are	O
imported	O
from	O
java.lang.annotation	O
.	O
</s>
<s>
Annotations	O
applied	O
to	O
Java	B-Language
code	I-Language
:	O
</s>
<s>
@Override	B-Language
-	O
Checks	O
that	O
the	O
method	O
is	O
an	O
override	B-Language
.	O
</s>
<s>
Causes	O
a	O
compilation	B-Error_Name
error	I-Error_Name
if	O
the	O
method	O
is	O
not	O
found	O
in	O
one	O
of	O
the	O
parent	O
classes	O
or	O
implemented	O
interfaces	B-Language
.	O
</s>
<s>
@SuppressWarnings	O
-	O
Instructs	O
the	O
compiler	O
to	O
suppress	O
the	O
compile	B-Application
time	I-Application
warnings	O
specified	O
in	O
the	O
annotation	O
parameters	O
.	O
</s>
<s>
@Retention	O
-	O
Specifies	O
how	O
the	O
marked	O
annotation	O
is	O
stored	O
,	O
whether	O
in	O
code	O
only	O
,	O
compiled	O
into	O
the	O
class	O
,	O
or	O
available	O
at	B-Library
runtime	I-Library
through	O
reflection	B-Language
.	O
</s>
<s>
@Target	O
-	O
Marks	O
another	O
annotation	O
to	O
restrict	O
what	O
kind	O
of	O
Java	B-Language
elements	O
the	O
annotation	O
may	O
be	O
applied	O
to	O
.	O
</s>
<s>
Since	O
Java	B-Language
7	O
,	O
three	O
additional	O
annotations	O
have	O
been	O
added	O
to	O
the	O
language	O
.	O
</s>
<s>
@SafeVarargs	O
-	O
Suppress	O
warnings	O
for	O
all	O
callers	O
of	O
a	O
method	O
or	O
constructor	O
with	O
a	O
generics	B-Language
varargs	B-Language
parameter	O
,	O
since	O
Java	B-Language
7	O
.	O
</s>
<s>
@FunctionalInterface	O
-	O
Specifies	O
that	O
the	O
type	O
declaration	O
is	O
intended	O
to	O
be	O
a	O
functional	B-General_Concept
interface	I-General_Concept
,	O
since	O
Java	B-Language
8	O
.	O
</s>
<s>
@Repeatable	O
-	O
Specifies	O
that	O
the	O
annotation	O
can	O
be	O
applied	O
more	O
than	O
once	O
to	O
the	O
same	O
declaration	O
,	O
since	O
Java	B-Language
8	O
.	O
</s>
<s>
This	O
example	O
demonstrates	O
the	O
use	O
of	O
the	O
@Override	B-Language
annotation	O
.	O
</s>
<s>
It	O
instructs	O
the	O
compiler	O
to	O
check	O
parent	O
classes	O
for	O
matching	O
methods	B-Language
.	O
</s>
<s>
In	O
this	O
case	O
,	O
an	O
error	O
is	O
generated	O
because	O
the	O
gettype( )	O
method	O
of	O
class	O
Cat	O
does	O
n't	O
in	O
fact	O
override	B-Language
getType( )	O
of	O
class	O
Animal	O
like	O
is	O
desired	O
,	O
because	O
of	O
the	O
mismatching	O
case	O
.	O
</s>
<s>
If	O
the	O
@Override	B-Language
annotation	O
were	O
absent	O
,	O
a	O
new	O
method	O
of	O
name	O
gettype( )	O
would	O
be	O
created	O
in	O
class	O
Cat	O
.	O
</s>
<s>
Annotations	O
may	O
include	O
a	O
set	O
of	O
key-value	O
pairs	O
,	O
which	O
are	O
modeled	O
as	O
methods	B-Language
of	O
the	O
annotation	O
type	O
.	O
</s>
<s>
Return	O
types	O
are	O
restricted	O
to	O
primitives	O
,	O
String	O
,	O
Class	O
,	O
enums	B-Language
,	O
annotations	O
,	O
and	O
arrays	O
of	O
the	O
preceding	O
types	O
.	O
</s>
<s>
Methods	B-Language
can	O
have	O
default	B-General_Concept
values	I-General_Concept
.	O
</s>
<s>
The	O
compiler	O
reserves	O
a	O
set	O
of	O
special	O
annotations	O
(	O
including	O
@Deprecated	O
,	O
@Override	B-Language
and	O
@SuppressWarnings	O
)	O
for	O
syntactic	O
purposes	O
.	O
</s>
<s>
Annotations	O
are	O
often	O
used	O
by	O
frameworks	B-Architecture
as	O
a	O
way	O
of	O
conveniently	O
applying	O
behaviours	O
to	O
user-defined	O
classes	O
and	O
methods	B-Language
that	O
must	O
otherwise	O
be	O
declared	O
in	O
an	O
external	O
source	O
(	O
such	O
as	O
an	O
XML	O
configuration	O
file	O
)	O
or	O
programmatically	O
(	O
with	O
API	O
calls	O
)	O
.	O
</s>
<s>
The	O
following	O
,	O
for	O
example	O
,	O
is	O
an	O
annotated	O
JPA	B-Language
data	O
class	O
:	O
</s>
<s>
The	O
annotations	O
are	O
not	O
method	B-Language
calls	I-Language
and	O
will	O
not	O
,	O
by	O
themselves	O
,	O
do	O
anything	O
.	O
</s>
<s>
Rather	O
,	O
the	O
class	O
object	O
is	O
passed	O
to	O
the	O
JPA	B-Language
implementation	O
at	O
run-time	B-Library
,	O
which	O
then	O
extracts	O
the	O
annotations	O
to	O
generate	O
an	O
object	B-General_Concept
–	I-General_Concept
relational	I-General_Concept
mapping	I-General_Concept
.	O
</s>
<s>
When	O
Java	B-Language
source	I-Language
code	I-Language
is	O
compiled	O
,	O
annotations	O
can	O
be	O
processed	O
by	O
compiler	O
plug-ins	O
called	O
annotation	O
processors	O
.	O
</s>
<s>
Processors	O
can	O
produce	O
informational	O
messages	O
or	O
create	O
additional	O
Java	B-Language
source	O
files	O
or	O
resources	O
,	O
which	O
in	O
turn	O
may	O
be	O
compiled	O
and	O
processed	O
.	O
</s>
<s>
(	O
Code	O
modifications	O
may	O
be	O
implemented	O
using	O
methods	B-Language
beyond	O
the	O
Java	B-Language
Language	I-Language
Specification	I-Language
.	O
)	O
</s>
<s>
The	O
Java	B-Language
compiler	I-Language
conditionally	O
stores	O
annotation	O
metadata	O
in	O
the	O
class	B-Language
files	I-Language
,	O
if	O
the	O
annotation	O
has	O
a	O
RetentionPolicy	O
of	O
CLASS	O
or	O
RUNTIME	B-Library
.	O
</s>
<s>
Later	O
,	O
the	O
JVM	B-Language
or	O
other	O
programs	O
can	O
look	O
for	O
the	O
metadata	O
to	O
determine	O
how	O
to	O
interact	O
with	O
the	O
program	O
elements	O
or	O
change	O
their	O
behavior	O
.	O
</s>
<s>
In	O
addition	O
to	O
processing	O
an	O
annotation	O
using	O
an	O
annotation	O
processor	O
,	O
a	O
Java	B-Language
programmer	O
can	O
write	O
his	O
own	O
code	O
that	O
uses	O
reflections	O
to	O
process	O
the	O
annotation	O
.	O
</s>
<s>
Java	B-Language
SE	I-Language
5	O
supports	O
a	O
new	O
interface	O
that	O
is	O
defined	O
in	O
the	O
java.lang.reflect	O
package	O
.	O
</s>
<s>
This	O
package	O
contains	O
the	O
interface	O
called	O
AnnotatedElement	O
that	O
is	O
implemented	O
by	O
the	O
Java	B-Language
reflection	B-Language
classes	O
including	O
Class	O
,	O
Constructor	O
,	O
Field	O
,	O
Method	O
,	O
and	O
Package	O
.	O
</s>
<s>
The	O
implementations	O
of	O
this	O
interface	O
are	O
used	O
to	O
represent	O
an	O
annotated	O
element	O
of	O
the	O
program	O
currently	O
running	O
in	O
the	O
Java	B-Language
Virtual	I-Language
Machine	I-Language
.	O
</s>
<s>
The	O
AnnotatedElement	O
interface	O
provides	O
access	O
to	O
annotations	O
having	O
RUNTIME	B-Library
retention	O
.	O
</s>
<s>
This	O
access	O
is	O
provided	O
by	O
the	O
getAnnotation	O
,	O
getAnnotations	O
,	O
and	O
isAnnotationPresent	O
methods	B-Language
.	O
</s>
<s>
Because	O
annotation	O
types	O
are	O
compiled	O
and	O
stored	O
in	O
byte	O
code	O
files	O
just	O
like	O
classes	O
,	O
the	O
annotations	O
returned	O
by	O
these	O
methods	B-Language
can	O
be	O
queried	O
just	O
like	O
any	O
regular	O
Java	B-Language
object	O
.	O
</s>
