Example in 8misc.pdf re. containing annotations

Alex Buckley alex.buckley at oracle.com
Tue Oct 1 15:55:00 PDT 2013


I was sure I'd removed all mention of @ContainedBy / @ContainerFor ! 
Thanks for spotting that, clearly it should be:

@Target(ElementType.TYPE)
@Repeatable(FooContainer.class)
@interface Foo {}

@Target(ElementType.ANNOTATION_TYPE)
@Interface FooContainer {
     Foo[] value();
}

Alex

On 10/1/2013 1:05 PM, Jesper Steen Møller wrote:
> Hi List
>
> The example of declared targets (Section 9.6) has an example, which I think is in error:
> An annotation whose type declaration indicates a target of java.lang.annotation.ElementType.TYPE can appear in at least as many locations as an annotation whose type declaration indicates a target of java.lang.annotation.ElementType.ANNOTATION_TYPE. For example, given the following declarations of repeatable and containing annotation types:
>
>         @Target(ElementType.TYPE)
>         @ContainedBy(FooContainer.class)
>         @interface Foo {}
>         @Target(ElementType.ANNOTATION_TYPE)
>         @ContainerFor(Foo.class)
>         @Interface FooContainer {
>             Foo[] value();
>         }
> Is this from an earlier version, so that @ContainedBy should be @Repeatable, and @ContainerFor should be omitted?
>
> Kind regards,
> Jesper
>


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