[foreign-jextract] RFR: 8239490: jextract throws "No matching declaration found for bitfield" because wrong bitfield content is found
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri Feb 28 12:46:33 UTC 2020
This patch fixes an issue wit bitfields handling; the issue is that we are using a map to keep track of which layouts are associated with bitfield contents. Unfortunately, most of the times, bitfield contents is associated with "shared" layouts, such as int layouts - so we end up overwriting the map, associating different contents to the same underlying layout and this causes downstream issues in the code that needs to access this information.
A more robust solution is to use layout annotations to do this - these are not exposed in a public API, but we already have some reflective hacks in order to use them from within jextract. I've added one more hack to add a single annotation to a layout. Longer term, we plan to make this part of the layout API public, so that no more hacks will be required (as we have other use cases for public metadata on layouts).
I've also added a test to verify that bitfields are correctly parsed. While writing the test, I've realized that our testing framework, while decent, can probably be streamlined more, I'll start thinking about ways on how to do that as a separate change, so that we can write these kind of tests more quickly (which hopefully will lead us to write more of them).
-------------
Commits:
- 7a9dccb2: * Fix bitfield support to use layout annotations
Changes: https://git.openjdk.java.net/panama-foreign/pull/36/files
Webrev: https://webrevs.openjdk.java.net/panama-foreign/36/webrev.00
Issue: https://bugs.openjdk.java.net/browse/JDK-8239490
Stats: 104 lines in 8 files changed: 97 ins; 3 del; 4 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/36.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/36/head:pull/36
PR: https://git.openjdk.java.net/panama-foreign/pull/36
More information about the panama-dev
mailing list