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

Field VarHandle generation in --source mode is missing the PathElement.groupElement argument

    XMLWordPrintable

    Details

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

      Description

      Extracting a struct like:

      struct coordinate {
           int x;
           int y;
      };

      Using the --source option, generates the following constant for the x and y var handles:

          private static final MemoryLayout x$LAYOUT_ = C_INT;
          public static jdk.incubator.foreign.MemoryLayout x$LAYOUT() { return x$LAYOUT_; }

          private static final VarHandle x$VH_ = x$LAYOUT_.varHandle(int.class);
          public static java.lang.invoke.VarHandle x$VH() { return x$VH_; }

          private static final MemoryLayout y$LAYOUT_ = C_INT;
          public static jdk.incubator.foreign.MemoryLayout y$LAYOUT() { return y$LAYOUT_; }

          private static final VarHandle y$VH_ = y$LAYOUT_.varHandle(int.class);
          public static java.lang.invoke.VarHandle y$VH() { return y$VH_; }

      This is incorrect, as the varHandle(...) invocations are missing a PathElement.groupLayout(...) argument for the respective fields, and the receiver layout should also be the layout of the parent, not the fields itself.

      This results in the var handle for y not having the correct offset.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jvernee Jorn Vernee
              Reporter:
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: