On Thu, 28 May 2026 21:17:37 GMT, Maurizio Cimadamore <[email protected]> wrote:
> This PR tidies up the DA/DU logic for strict field initialization. > The main idea is to revisit the changes around `forEachInitializer`, so that > the method now accepts a predicate. > Four predicates are defined: > * one that selects all static initializers > * one that selects early instance initializers > * one that selects late instance initializers > * one that selects all instance initializers > > Then all calls to `forEachInitializer` are rewired to use the correct > predicate. The resulting code is a bit more declarative and easier to follow. > > The main change is that the call to `forEachInitializer` with early instance > predicate is moved from `visitApply` to `visitMethod`. > In other words, to follow the spec correctly, DA/DU state for early > initializers must be processed _before_ the first statement in a constructor > body that contains a super call. > > This reveals issues in the tests which have been fixed. I have also added a > new test that should pass, but was rejected. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: 6a7073f7 Author: Maurizio Cimadamore <[email protected]> URL: https://git.openjdk.org/valhalla/commit/6a7073f7c600a6785462cba9fffddb934327d402 Stats: 113 lines in 2 files changed: 46 ins; 33 del; 34 mod 8385600: [lworld] DA/DU issues with strict fields Reviewed-by: vromero ------------- PR: https://git.openjdk.org/valhalla/pull/2484
