Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

What is a Java Annotation?

Thread view: 
marcwentink@hotmail.com - 30 May 2006 09:45 GMT
Probably a very stupid newbee question, but what is meant with
annotation?

See:

http://blogs.sun.com/roller/page/dannycoward?entry=the_10_things_you_need

7 Pluggable Annotation ...

Bablefish translate it into Dutch, my native language as annotatie.
<Dutch>Ja daar schiet ik wat mee op zeg!</Dutch>
Robert Klemme - 30 May 2006 09:53 GMT
> Probably a very stupid newbee question, but what is meant with
> annotation?
[quoted text clipped - 7 lines]
> Bablefish translate it into Dutch, my native language as annotatie.
> <Dutch>Ja daar schiet ik wat mee op zeg!</Dutch>

http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html

    robert
Thomas Weidenfeller - 30 May 2006 10:35 GMT
> Probably a very stupid newbee question, but what is meant with
> annotation

A generic mechanism to add meta data to the source code. Tools, like the
compiler, but also additional tools, can then do some magic tricks if
they find an annotation in the code.

Depending on the type of annotation, the meta data is removed when
compiling, or is compiled into the class file. If you do the later, you
can check the meta data during runtime, an do even more magic tricks
while the program runs.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Chris Uppal - 30 May 2006 11:04 GMT
> Depending on the type of annotation, the meta data is removed when
> compiling, or is compiled into the class file.

Nitpick: the metadata is always added to the classfile (or it wouldn't be a lot
of use ;-)  The distinction is between whether the /JVM/ discards the metadata
as it loads the class, or retains it for runtime use by the application.

   -- chris
Dale King - 30 May 2006 14:29 GMT
>> Depending on the type of annotation, the meta data is removed when
>> compiling, or is compiled into the class file.
>
> Nitpick: the metadata is always added to the classfile (or it wouldn't be a lot
> of use ;-)  The distinction is between whether the /JVM/ discards the metadata
> as it loads the class, or retains it for runtime use by the application.

Nit-nitpick:

Annotations are not necessarily added to the class file. There are 3
RetentionPolicy values defined that specify how long annotations are to
be retained: SOURCE, CLASS, RUNTIME.

The SOURCE value is used for things that are only significant to the
compiler. For example, the Override and SuppressWarnings annotations are
source only annotations.

With the annotation processing API coming in JSE 6 (JSR 269) there will
probably be many more uses for source only annotations.
Signature

 Dale King

Chris Uppal - 30 May 2006 14:55 GMT
> Annotations are not necessarily added to the class file. There are 3
> RetentionPolicy values defined that specify how long annotations are to
> be retained: SOURCE, CLASS, RUNTIME.

I'd completely forgotten about SOURCE.  Thanks for the correction.

   -- chris
Mike Schilling - 30 May 2006 16:37 GMT
>> Annotations are not necessarily added to the class file. There are 3
>> RetentionPolicy values defined that specify how long annotations are to
>> be retained: SOURCE, CLASS, RUNTIME.
>
> I'd completely forgotten about SOURCE.  Thanks for the correction.

Presumably if Java were being designed from scratch today Javadoc would be
SOURCE.
Chris Uppal - 31 May 2006 11:11 GMT
> Presumably if Java were being designed from scratch today Javadoc would be
> SOURCE.

Quite possibly.  An even more interesting possibility (IMO) would be to give it
CLASS status.

Classfile format is a high-level programming language anyway, so why not ship
the API documentation along with the "code" ?

   -- chris
Mike Schilling - 31 May 2006 15:25 GMT
>> Presumably if Java were being designed from scratch today Javadoc would
>> be
[quoted text clipped - 7 lines]
> ship
> the API documentation along with the "code" ?

In some cases, security via obfuscation.
Chris Uppal - 31 May 2006 15:58 GMT
[me:]
> > Classfile format is a high-level programming language anyway, so why not
> > ship
> > the API documentation along with the "code" ?
>
> In some cases, security via obfuscation.

Well, there's nothing to say that the info couldn't be stripped out, or never
added in the first place (cf. debugging info).

But it was just an idle thought ;-)

   -- chris
marcwentink@hotmail.com - 30 May 2006 14:36 GMT
And I thank you for all the answers :-)
You're all very kinf


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.