RFR: 8325805: Compiler Implementation for Flexible Constructor Bodies (Second Preview)

Archie Cobbs acobbs at openjdk.org
Fri Mar 22 18:36:54 UTC 2024


This patch changes the compiler to allow constructors to make assignments to fields prior to the `super()` invocation, i.e., in the pre-construction context.  This is part of the work associated with [JDK-8325803 - Flexible Constructor Bodies (Second Preview)](https://bugs.openjdk.org/browse/JDK-8325803).

This patch is based the relevant bits from @vicente-romero-oracle's commit [1b99b5cf](https://github.com/openjdk/valhalla/commit/1b99b5cfd9a5d484b9e7bdfc284daad9ad6535bf) to the valhalla repo.

-------------

Commit messages:
 - Fix cut & paste of bug ID and summary.
 - Avoid possible unwanted side effects from method Symbol.flags().
 - Add a few more test cases.
 - Fix bug where early assignments in lambda's were being allowed.
 - Add some more allowed assignment test cases.
 - Add test case for early assignment within a lambda.
 - Add comment.
 - Fix early ref logic by handling assign vs. reference separately.
 - Add some more test cases and modify the logic a bit.
 - Consolidate new logic into isAllowedEarlyReference() method.
 - ... and 4 more: https://git.openjdk.org/jdk/compare/d32ce657...4d2d3e83

Changes: https://git.openjdk.org/jdk/pull/18088/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18088&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8325805
  Stats: 418 lines in 11 files changed: 375 ins; 37 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/18088.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18088/head:pull/18088

PR: https://git.openjdk.org/jdk/pull/18088


More information about the compiler-dev mailing list