RFR: 7903608: Cyclic initialization leads to NPE in header class with global variable [v3]
Jorn Vernee
jvernee at openjdk.org
Thu Dec 14 15:26:39 UTC 2023
On Thu, 14 Dec 2023 15:23:34 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.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Drop spurious changes
Marked as reviewed by jvernee (Committer).
-------------
PR Review: https://git.openjdk.org/jextract/pull/160#pullrequestreview-1782064387
More information about the jextract-dev
mailing list