[foreign-jextract] RFR: 8254983: jextract fails to hande layout paths nested structs/union#

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Oct 19 16:43:33 UTC 2020


This patch fixes an issue with jextract code generation. More specifically, when multiple structs with same name are
found in an header (this is possible if the structs are at different level of nesting e.g. `Foo.Bar` vs.
`Foo.Baz.Bar`), jextract erroneously uses the struct simple name to qualifiy the various fields associated with the
struct (such as the layout field). Because of this, there are cases where, when generating a var handle for a struct
field, we erroneously pick up the layout corresponding to a different struct, which then causes an error at runtime.

The fix is to always disambiguate struct names when in nested context, so that `Foo.Bar` and `Foo.Baz.Bar` lead to
different constant names.

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

Commit messages:
 - Fix issue with nested structs clashing with outer structs with same name

Changes: https://git.openjdk.java.net/panama-foreign/pull/384/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=384&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8254983
  Stats: 105 lines in 6 files changed: 91 ins; 5 del; 9 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/384.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/384/head:pull/384

PR: https://git.openjdk.java.net/panama-foreign/pull/384


More information about the panama-dev mailing list