Clarification of TYPE Target type and anonymous classes
Alex Buckley
alex.buckley at oracle.com
Wed Mar 19 19:42:57 UTC 2014
This is very similar to the question that Jan asked in his mail "Queries
about JDK-8035890" on 3/13/14, except that he had added
ElementType.TYPE_USE to the @Target. The case where the @Target is
solely ElementType.TYPE was discussed in
http://mail.openjdk.java.net/pipermail/type-annotations-spec-experts/2013-August/000127.html.
The test is correct as is.
Alex
On 3/18/2014 12:01 PM, Eric McCorkle wrote:
> The regression test suite contains the following test, which is expected
> to fail compilation:
>
> import java.lang.annotation.*;
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.TYPE)
> @interface X {}
> interface Foo {}
> class TypeOnAnonClass { void m() { new @X Foo() {}; } }
>
>
> I believe this is incorrect, as the annotation @X should end up as a
> class annotation on the anonymous class. Please clarify what should
> happen here.
>
> Thanks,
> Eric
>
More information about the type-annotations-dev
mailing list