references to non-static types from annotations

Liam Miller-Cushon cushon at google.com
Wed Apr 13 23:35:04 UTC 2016


Thanks for the explanation.

Would anyone be willing to file the bug? I'd still like to contribute a fix.

On Wed, Apr 13, 2016 at 11:29 AM, Alex Buckley <alex.buckley at oracle.com>
wrote:

> 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
>>     incompatibility.
>>
>> 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).
>
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160413/f37ec479/attachment.html>


More information about the compiler-dev mailing list