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

'super' qualified method references or invocations cannot occur in a static context

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • tools
    • None
    • behavioral
    • minimal
    • Some illegal programs which were being accepted by javac in error till now, will stop compiling post this change
    • Other
    • Implementation

      Summary

      Javac's is not issuing an error if 'super' qualified method references or invocations occur in a static context and thus it needs to be synced with the spec.

      Problem

      Javac is not in sync with sections §15.12.3 and §15.13 of the JLS 16 specification. In particular javac is not issuing an error if 'super' qualified method references or invocations occur in a static context even when the specs mandates a compiler error to be issue in these cases.

      Solution

      Synchronize javac with sections §15.12.3 and §15.13 of the JLS 16 specification.

      Specification

      Of interest for this CSR is section §15.12.3 of the JLS 16 specification, titled: "Compile-Time Step 3: Is the Chosen Method Appropriate?" in particular where it reads:

      • If the form is super . [TypeArguments] Identifier, then:
          – It is a compile-time error if the compile-time declaration is abstract .
          – It is a compile-time error if the method invocation occurs in a static context.
      • If the form is TypeName . super . [TypeArguments] Identifier, then:
          – It is a compile-time error if the compile-time declaration is abstract .
          – It is a compile-time error if the method invocation occurs in a static context.

      Also of interest for this CSR is section §15.13 of the JLS 16 specification, in particular:

      If a method reference expression has the form super :: [TypeArguments] Identifier
      or TypeName . super :: [TypeArguments] Identifier, it is a compile-time error if
      the expression occurs in a static context (§8.1.3).

            vromero Vicente Arturo Romero Zaldivar
            xliu Xin Liu
            Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: