-アノテーションへのアノテーション

public class FooBarTest extends TestCase {
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Foo {
        String value();
    }
    @Foo("foo")
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Bar {
        String value();
    }
    public void testFooBar() {
        Foo foo = Bar.class.getAnnotation(Foo.class);
        assertEquals("foo", foo.value());
    }
}

普通に上記ができるから、先のアノテーションの継承っぽいつくりは特別なことしなくてもできそう。なんとなく試すまでは漠然とダメかなと思ってたけど、アノテーションも特殊なインターフェイスならしいから出来てよい話だったんだよな。Targetメタアノテーションには「ANNOTATION_TYPE」があるし。