Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8254983

jextract fails to hande layout paths nested structs/union

    Details

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

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: