Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903607

Forward reference from pointer typedef

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      For the following header:

          int DUMMY;
          typedef void* my_ptr;

      When it is extracted with: -Djextract.decls.per.header=1 to simulate both declarations being split into different headers.

      The following Java program:

          void main() {
              System.out.println(forward_ref_h.DUMMY$LAYOUT()); // actually in forward_ref_h
              System.out.println(forward_ref_h.my_ptr); // actually in forward_ref_h_1 (secondary header class)
          }

      Will print:

          i4
          null

      The issue is that we have a forward reference from the secondary header class that is generated for `my_ptr`, back to the C_POINTER layout in the first header class generated for `DUMMY`. When we initialize the first header class, it's super class, which is the secondary header class, is initialized first. The clinit of that class points back to the C_POINTER layout in the first header class, which will appear as `null` at that point, resulting in the my_ptr layout being initialized with `null` as well.

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

              Created:
              Updated:
              Resolved: