Community
Participate
Working Groups
The following example should not compile: @interface ann { Class foo(); } @ann(foo=Inner.class) class Outer { public static class Inner { } } The reference to Inner.class in the annotation member value is not in scope. According to the JLS section 6.3: The scope of a declaration of a member m declared in or inherited by a class type C is the entire body of C, including any nested type declarations. This implies that Inner is only in scope within the body of Outer. It should only work if the type name is qualified as Outer.Inner.
Using latest I get: ---------- 1. ERROR in C:\tests_sources\X.java (at line 6) @ann(foo=Inner.class) ^^^^^ Inner cannot be resolved to a type ---------- 1 problem (1 error)
I have confirmed this using the head revision.
dup
closed as dup *** This bug has been marked as a duplicate of 86291 ***
Note that method annotations are still seeing method scope.