-
Bug
-
Resolution: Fixed
-
P4
-
8
JLS 3 used the following phrase when defining the enclosing instance of an unqualified 'super' call:
"Let O be the innermost lexically enclosing class of which S is a member, and let n be an integer such that O is the nth lexically enclosing class of C."
JLS 7 changed it to:
"Let O be the innermost lexically enclosing class of S, and let n be an integer such that O is the nth lexically enclosing class of C."
The distinction is subtle, but by speaking of membership, we allowed for the possibility that S is inherited by a lexically enclosing class of C. JLS 7 no longer accounted for this case.
Compare the error check appearing earlier, which continues to use the word "member":
JLS 7: "it is a compile-time error if S is not a member of a lexically enclosing class of C by declaration or inheritance"
JLS 8: "If S is an inner member class, but S is not a member of a lexically enclosing type declaration of C, then a compile-time error occurs"
All of these fail to directly address the possibility that S is a member of C. S cannot be *declared* a member of C (per 8.1.4), but might be inherited. Since C is the 0th lexically enclosing class of itself (8.1.3), that would imply that C == O. But I believe the intent (and actual javac behavior) is that n >= 1.
"Let O be the innermost lexically enclosing class of which S is a member, and let n be an integer such that O is the nth lexically enclosing class of C."
JLS 7 changed it to:
"Let O be the innermost lexically enclosing class of S, and let n be an integer such that O is the nth lexically enclosing class of C."
The distinction is subtle, but by speaking of membership, we allowed for the possibility that S is inherited by a lexically enclosing class of C. JLS 7 no longer accounted for this case.
Compare the error check appearing earlier, which continues to use the word "member":
JLS 7: "it is a compile-time error if S is not a member of a lexically enclosing class of C by declaration or inheritance"
JLS 8: "If S is an inner member class, but S is not a member of a lexically enclosing type declaration of C, then a compile-time error occurs"
All of these fail to directly address the possibility that S is a member of C. S cannot be *declared* a member of C (per 8.1.4), but might be inherited. Since C is the 0th lexically enclosing class of itself (8.1.3), that would imply that C == O. But I believe the intent (and actual javac behavior) is that n >= 1.
- relates to
-
JDK-7026147 8.8.7.1: Specify that type of enclosing class may be parameterized
- Open
-
JDK-6708938 Synthetic super-constructor call should never use 'this' as a qualifier
- Closed
-
JDK-8146062 No compilation error when trying to compile nested inner classes
- Closed