Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8179109

8.4.1: Error for receiver parameter of an inner class in a static context

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 10
    • Component/s: specification
    • Labels:

      Description

      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.**

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abuckley Alex Buckley
                Reporter:
                dlsmith Dan Smith
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: