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

8.4.1: Clarify that a receiver parameter need not be followed by formal parameters

    XMLWordPrintable

    Details

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

      Description

      The JLS8 grammar does not permit a method's FormalParameterList to consist solely of a 'this' receiver parameter, despite examples showing such a method. The grammar demands that a ReceiverParameter is followed by (at least) a LastFormalParameter. It is clearly desirable to add a third alternative to FormalParameterList:

      FormalParameterList:
        ReceiverParameter /* 1 recv, 0 formals */
        FormalParameters , LastFormalParameter /* 1 recv, 1+ formals OR 0 recv, 1+ formals */
        LastFormalParameter /* 0 recv, 1 formal */

      (No changes needed to ReceiverParameter or FormalParameters or LastFormalParameter.)

      The clause "A receiver parameter may appear only in the FormalParameters of an instance method or an inner class's constructor; otherwise, a compile-time error occurs." must mention FormalParameterList rather than FormalParameters.

        Attachments

          Activity

            People

            Assignee:
            abuckley Alex Buckley
            Reporter:
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: