• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding annotations from subclass or child class

 
Eric Juneau
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this question has probably been answered somewhere, but I wasn't able to come up with good search terms for it. Basically, I am trying to get the annotations for fields in a subclass in the parent class. Example:


The problem is that there are no annotations present for the fields in the superclass's validate. I know that child classes won't inherit annotations of the parent class. But shouldn't it work the other way around?
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the definition of @MyAnnotation? More specifically, what are its meta annotations (@Documented, @Inherited, @Retention, @Target, etc)?
 
Eric Juneau
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyAnnotation is defined as such:

 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the possible values of RetentionPolicy, and figure out which one you need to use with the @Retention meta annotation.
 
Eric Juneau
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added

to my annotation and that worked. Thanks.
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic