references to non-static types from annotations
alex.buckley at oracle.com
Wed Apr 13 18:29:01 UTC 2016
On 4/13/2016 11:12 AM, Liam Miller-Cushon wrote:
> On Wed, Apr 13, 2016 at 10:57 AM, Alex Buckley <alex.buckley at oracle.com
> <mailto:alex.buckley at oracle.com>> wrote:
> I know what you mean, but the fact that I can write @A(Test.I.class)
> today means making it consistent would be a serious source
> And I don't think it would be a significant incompatibility, for what
> it's worth. I only found a single example of this in our codebase, and
> ecj already rejects @A(I.class).
A class-valued annotation element that refers to an inner class is
relatively unusual, but there's no reason to restrict it when this is
plainly a compiler scope bug (I versus Test.I).
I should have noted earlier that an annotation is never in a static
context per se -- only a statement or expression can be in a static
context. Annotations are inherently "static" even when applied to
clearly non-static source constructs such as the declaration of an
instance variable in a top level class -- the annotation's elements are
still on the hook to refer solely to "static things" (constant
expressions, enum constants, and the special case of a class literal).
More information about the compiler-dev