Behavior of getAnnotationsByType for @FooContainer({})

Alex Buckley alex.buckley at oracle.com
Thu Oct 10 10:47:14 PDT 2013


// Moving question to the enhanced-metadata-spec-discuss list.

I need to know the definitions of Foo and FooContainer, plus the actual 
method call you're making. I assume it's 
B.class.getAnnotationsByType(SOMETHING) but I don't know what the 
SOMETHING is.

Your code is similar to Example 1.2-4 in 
http://cr.openjdk.java.net/~abuckley/8misc.pdf - please identify how 
your setup differs from the setup there.

Alex

On 10/10/2013 2:51 AM, Andreas Lundblad wrote:
> Joel, Joe, Alex
>
> As far as I can tell, the behavior of getAnnotationsByType is not
> clearly defined for the following case
>
>    @Foo class A {}
>    @FooContainer({}) class B extends A {}
>
> Should it be interpreted as
>
> 1) Since no @Foos are directly or indirectly present on B, @Foo should
> be inherited from A
>
> or
>
> 2) The explicit (empty) list of @Foos prevent any other @Foos from being
> inherited.
>
> Unless I've overlooked something and there is a good reason to define it
> as alternative 1, I would prefer alternative 2, as it seems strange to
> let the semantics depend on the length of the list.
>
> best regards,
> Andreas Lundblad


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