Results 1 to 8 of 8
  1. #1
    cld71 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Default Reading an annotaion that is ElementType.LOCAL_VARIABLE

    I have been trying read a ElementType.LOCAL_VARIABLE annotation using reflect package.
    Here is my annotation:
    @Target(value={ElementType.TYPE,ElementType.LOCAL_ VARIABLE})
    @Retention(value=RetentionPolicy.RUNTIME)
    public @interface TestAnnotation{
    String theName();
    }

    Here is my program to try read the annotation:
    public class TestTheAnnotation{
    public static void main(String[] args){
    @TestAnnotation(theName="My_LastName,My_FirstName" )
    Integer id=new Integer(1);
    System.out.println(">> "+id.getClass().getAnnotations().length);
    System.out.println(">> "+id.getClass().getDeclaredAnnotations().lengt h);
    }
    }

    The methods getAnnotations, and getDeclaredAnnotations only return the annotations declared for the object, but I want the annotation declared for the local variable.
    Is there any way to do this?

    Thanks.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

  3. #3
    cld71 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default

    Nope.

    db

  5. #5
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    If they are not the same system what is wrong with posting in multiple forums? Do you spend your days looking at other forums to see if people post the same questions?!

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default

    Yup.

    db

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by d3n1s View Post
    If they are not the same system what is wrong with posting in multiple forums?
    There's nothing wrong with cross-posting per se, but we don't appreciate cross-posts without notification. To see why this is important, please read this link: BeForthrightWhenCrossPostingToOtherSites. Thank you in advance for reading the link and responding in an understanding manner.

  8. #8
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    Makes perfect sense in that case! Thanks for not just answering a one word answer lol :)

Similar Threads

  1. Reading log
    By Darth Blue Ray in forum New To Java
    Replies: 1
    Last Post: 03-15-2011, 09:35 PM
  2. Reading doc file
    By siva_vs_siva in forum New To Java
    Replies: 1
    Last Post: 09-03-2010, 11:20 AM
  3. reading from a .txt
    By Flamespewer in forum New To Java
    Replies: 1
    Last Post: 09-14-2009, 08:35 AM
  4. Replies: 5
    Last Post: 08-21-2009, 11:03 AM
  5. Reading Keyboard
    By ushigley in forum New To Java
    Replies: 4
    Last Post: 08-20-2008, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •