Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes @interface inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "@interface inheritance" Watch "@interface inheritance" New topic
Author

@interface inheritance

Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Why isn't it possible to extend custom annotations... ?

the following example does not compile:
@interface Base {}
@interface Derived extends Base {}
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

The specification doesn't allow it.
JLS3 wrote:
No extends clause is permitted. (Annotation types implicitly extend annotation.Annotation.)

Maybe the rationale behind this can be found somewhere in the discussions leading up to the specification in JSR175.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
wood burning stoves
 
subject: @interface inheritance