Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8300786 JEP 447: Statements before super(...) (Preview)
  3. JDK-8194743

Compiler implementation for Statements before super()

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Fixed
    • P4
    • 22
    • None
    • tools
    • None
    • b26

    Backports

      Description

        Currently it is not permitted to precede the `this()` or `super()` call in a constructor invocation with statements. This often causes distorted control flow and challenges in refactoring.

        We would amend JLS 8.8.7 as follows:

        - Production is amended to:

            ConstructorBody:
                { [ BlockStatements ] [ ExplicitConstructorInvocation ] [ BlockStatements ] }
         
        - Restriction about first statement is relaxed to apply to the explicit ctor invocation, wherever it resides.

        - s/begin with/include/

        - Add note (somewhere) that in the first BlockStatement, `this` is DU, and in the second, `this` is DA.

        - Clarify that a return statement may only be used in the second BlockStatements.


        Attachments

          Issue Links

            Activity

              People

                acobbs Archie Cobbs
                briangoetz Brian Goetz
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: