-
Bug
-
Resolution: Fixed
-
P4
-
14
JLS14 9.7.4 gives the following example:
-----
@Target(ElementType.TYPE_USE)
@interface Foo {}
class Test {
class A {
static class B {}
}
@Foo A.B x; // Illegal
}
-----
However, it is a compile-time error for class B to be declared static in the first place, per 8.5.1: "The static keyword may modify the declaration of a member type C within the body of a non-inner class or interface T." (A is an inner class above.)
The example can easily be fixed by making A into a top level class. Then, it is non-inner, so class B can be declared static.
The final example in 9.7.4, involving classes Test, E, F, and G, is too complicated and should be removed. (It involves a hypothetical whereby an illegal nest of classes is assumed to be legal for the purpose of noting a technicality in the definition of "admissible". This adds confusion faster than it adds clarity.)
-----
@Target(ElementType.TYPE_USE)
@interface Foo {}
class Test {
class A {
static class B {}
}
@Foo A.B x; // Illegal
}
-----
However, it is a compile-time error for class B to be declared static in the first place, per 8.5.1: "The static keyword may modify the declaration of a member type C within the body of a non-inner class or interface T." (A is an inner class above.)
The example can easily be fixed by making A into a top level class. Then, it is non-inner, so class B can be declared static.
The final example in 9.7.4, involving classes Test, E, F, and G, is too complicated and should be removed. (It involves a hypothetical whereby an illegal nest of classes is assumed to be legal for the purpose of noting a technicality in the definition of "admissible". This adds confusion faster than it adds clarity.)