Integrated: 7903608: Cyclic initialization leads to NPE in header class with global variable

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Dec 14 15:35:14 UTC 2023


On Thu, 14 Dec 2023 10:57:07 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR fixes some new static initialization cycles that have been made possible by (a) the removal of constant classes and (b) the fact that we refer to struct layouts by name.
> 
> The fix consists in two parts:
> 
> * First, we make sure that whenever the header class needs to reference another layout, we do so behind a holder class idiom (this patch only touches globals, as all other cases are already using the holder idiom)
> 
> * Secondly, we invert the inheritance order of header classes (this is only relevant when using header file splitting). In the current order, symbols that are found "later" in the header files, are added in classes that are "higher up" in the inheritance chain. This leads to issues, as you can have e.g. a primitive typedef depending on a previous primitive typedef, which is in reality defined in a subclass (which leads to a cycle).
> 
> Since I was there, I decided to simplify the logic for global variables, and make it more uniform with the rest: now we only emit an accessor for the global segment and a layout. We no longer emit a var handle accessor - developers have all they need to get one. Global vars setters/getters have also been simplified to just use memory segment accessors.

This pull request has now been integrated.

Changeset: 864acb5c
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/jextract/commit/864acb5cdec5743875ffc9ce6fc2e31b2d9851ec
Stats:     332 lines in 14 files changed: 256 ins; 24 del; 52 mod

7903608: Cyclic initialization leads to NPE in header class with global variable

Reviewed-by: jvernee

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

PR: https://git.openjdk.org/jextract/pull/160


More information about the jextract-dev mailing list