@Target on Repeatable annotation but no @Target on the containing annotation

Jesper Steen Møller jesper at selskabet.org
Tue Oct 1 13:20:21 PDT 2013


Hi List

Consider the following example:

import java.lang.annotation.Target; 
import java.lang.annotation.ElementType;

@interface FooContainer {
  Foo[] value();
}

@java.lang.annotation.Repeatable(FooContainer.class)
@java.lang.annotation.Target({ElementType.FIELD})
@interface Foo {
}

The spec doesn't address this case as directly as it handles the others - but as I read it, then since @Foo is constrained to specific targets, and @FooContainer is not, this should be flagged as an error, right? 

-Jesper


More information about the enhanced-metadata-spec-discuss mailing list