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.
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.