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 / First Aid / April 2005

Tip: Looking for answers? Try searching our database.

Another Java 5 problem

Thread view: 
Aleksandar Pecanov - 06 Apr 2005 20:48 GMT
Well... again a problem. This time it's the annotations.
I have two classes like this:

public @interface Tst {
}

and ...

@Tst public class Test {

   public Test() {
       super();
   }
   
   public static void main(String argz[]) {
       Test test = new Test();
       System.out.println( Tst.class.isAnnotation() );
       System.out.println( test.getClass().getAnnotations().length );
   }
   
}

When I run Test the output is:
true
0

However, according to Java 5, the Test class should be annotated with
Tst.
The second line, I suppose should be 1.

What am I doing wrong?

Thank you
Chris Smith - 06 Apr 2005 21:41 GMT
> When I run Test the output is:
> true
[quoted text clipped - 4 lines]
>
> What am I doing wrong?

Read the API docs for java.lang.annotation.Retention.  You need to
specify this meta-annotation on Tst.  It defaults to CLASS, and
annotations with a RetentionPolicy of CLASS may not be read via
reflection.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Aleksandar Pecanov - 06 Apr 2005 22:48 GMT
Ok, ok ... ignore the previous posting ... very stupid of me

> Well... again a problem. This time it's the annotations.
> I have two classes like this:
[quoted text clipped - 29 lines]
>
> Thank you


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.