Details
-
Sub-task
-
Status: Open
-
P4
-
Resolution: Unresolved
-
None
-
None
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.
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
- csr for
-
JDK-8302041 Permit additional statements before this/super in constructors
-
- Finalized
-
- duplicates
-
JDK-8302038 compiler implementation for statements before super()
-
- Closed
-
-
JDK-8193760 allow code in a constructor before the call to the super constructor
-
- Resolved
-
- relates to
-
JDK-8300786 Statements before super()
-
- Submitted
-