-
Bug
-
Resolution: Fixed
-
P4
-
8, 9
Some inner classes can occur in static contexts (8.4.1)—e.g., a local class declared in a static method. But these inner classes have no immediately enclosing instance, so shouldn't have a receiver parameter.
Proposed rule:
A receiver parameter may appear only in the FormalParameterList of an instance method or ~~an inner class's constructor~~ **a constructor of an inner class, where the inner class is not declared in a static context**; otherwise, a compile-time error occurs.
Or, if that's too much of a mouthful:
A receiver parameter may appear only in the FormalParameterList of an instance method or an inner class's constructor; otherwise, a compile-time error occurs.
**If a receiver parameter appears in the FormalParameterList of an inner class's constructor, but that class is declared in a static context, a compile-time error occurs.**
Proposed rule:
A receiver parameter may appear only in the FormalParameterList of an instance method or ~~an inner class's constructor~~ **a constructor of an inner class, where the inner class is not declared in a static context**; otherwise, a compile-time error occurs.
Or, if that's too much of a mouthful:
A receiver parameter may appear only in the FormalParameterList of an instance method or an inner class's constructor; otherwise, a compile-time error occurs.
**If a receiver parameter appears in the FormalParameterList of an inner class's constructor, but that class is declared in a static context, a compile-time error occurs.**
- relates to
-
JDK-8162501 getAnnotatedReceiverType of a local class constructor returns null
-
- In Progress
-