[type-annos-observers] error: enclosing static nested class cannot be annotated ??

Werner Dietl wdietl at gmail.com
Mon Oct 7 08:44:26 PDT 2013


Hi Srikanth,

I pushed an update to checking of these rules yesterday.
Your attached example now passes, as you expected.
If you instead try:

@Illegal Y.YY.Z z2 = null;

you now get:

error: scoping construct cannot be annotated with type-use annotation: @Illegal
                @Illegal Y.YY.Z z2 = null;

I think this corresponds to what a recent update to the JSR 308 spec prescribes.

Comments welcome.
cu, WMD.



On Mon, Oct 7, 2013 at 2:46 AM, Srikanth S Adayapalam
<srikanth_sankaran at in.ibm.com> wrote:
> Hello !
>
>
> I see that 8b108 rejects the following code.
> I am trying to trace this behavior back to the
> spec - with not clear cut success. Could you
> help clarify the behavior ?
>
> Thanks!
> Srikanth.
>
>
>
> // --
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Target;
>
> @Target(ElementType.TYPE_USE)
> @interface Illegal {
> }
> class Y {
>         static class YY {
>                 class Z {
>                         Z() {}
>                 }
>         }
> }
> class X {
>         Y.YY.Z foo2() {
>                 Y. at Illegal YY.Z z = null;  // illegal ???
>                 return z;
>         }
> }



-- 
http://www.google.com/profiles/wdietl


More information about the type-annotations-spec-experts mailing list