[foreign] RFR 8217781: Filter child cursors when doing recursive offset lookup

Jorn Vernee jbvernee at xs4all.nl
Fri Jan 25 12:26:18 UTC 2019


Hi,

Based on JDK-8217664 [1], I have found the following bug with this 
layout:

```
struct Foo {
     struct {
         union {
             int x;
         } Bar;
     };
};
```

To find the offset of the anonymous struct in Foo, we have to find the 
offset of it's first field. But, the current code is looking for the 
first child _cursor_ of the anonymous struct, which is the union 
declaration, and not the field 'Bar'. This again tries to look up the 
first field of 'Bar' which is 'x', so we end up looking up the field 'x' 
in Foo, which throws an error.

The fix is simple, we just have to filter for anonymous struct/union and 
FieldDecl child cursors when doing a recursive offset lookup. I've also 
added an exception message to the recursive lookup, which helped debug 
this.

Please review the following.

Bug: https://bugs.openjdk.java.net/browse/JDK-8217781
Webrev: 
http://cr.openjdk.java.net/~jvernee/panama/webrevs/8217781/webrev.00/

Thanks,
Jorn

[1] : https://bugs.openjdk.java.net/browse/JDK-8217664


More information about the panama-dev mailing list