jextract fails to hande layout paths nested structs/union

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • None
    • Affects Version/s: repo-panama
    • Component/s: tools

      Given this header:

      typedef struct PARAMS {

          union {

              struct {

                  int flags1;

                  union {

                      struct {
                          int flags3;
                      } Struct2;

                  } DUMMYUNION1;

              } Struct1;

              struct {
                  int flags2;
              } Struct2;

          } DUMMYUNION2;

      } PARAMS;



      This is the struct layout:

      static final MemoryLayout PARAMS$struct$LAYOUT_ = MemoryLayout.ofStruct(
              MemoryLayout.ofUnion(
                  MemoryLayout.ofStruct(
                      C_INT.withName("flags1"),
                      MemoryLayout.ofUnion(
                          MemoryLayout.ofStruct(
                              C_INT.withName("flags3")
                          ).withName("Struct2")
                      ).withName("DUMMYUNION1")
                  ).withName("Struct1"),
                  MemoryLayout.ofStruct(
                      C_INT.withName("flags2")
                  ).withName("Struct2")
              ).withName("DUMMYUNION2")
          ).withName("PARAMS");
          static final jdk.incubator.foreign.MemoryLayout PARAMS$struct$LAYOUT() { return PARAMS$struct$LAYOUT_; }


      And this is the layout for the "flags2" field:

          static final VarHandle Struct2$flags2$VH_ = Struct2$struct$LAYOUT_.varHandle(int.class, MemoryLayout.PathElement.groupElement("flags2"));


      This configuration results in a runtime error as the layout path from "PARAMS" to "flags2" is not specified correctly.

            Assignee:
            Sundararajan Athijegannathan
            Reporter:
            Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: