| Author |
Finding annotations from subclass or child class
|
Eric Juneau
Greenhorn
Joined: Jul 13, 2009
Posts: 28
|
|
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
Joined: Oct 27, 2005
Posts: 19232
|
|
|
What's the definition of @MyAnnotation? More specifically, what are its meta annotations (@Documented, @Inherited, @Retention, @Target, etc)?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Eric Juneau
Greenhorn
Joined: Jul 13, 2009
Posts: 28
|
|
MyAnnotation is defined as such:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
Check out the possible values of RetentionPolicy, and figure out which one you need to use with the @Retention meta annotation.
|
 |
Eric Juneau
Greenhorn
Joined: Jul 13, 2009
Posts: 28
|
|
I added
to my annotation and that worked. Thanks.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
You're welcome
|
 |
 |
|
|
subject: Finding annotations from subclass or child class
|
|
|