[foreign-memaccess] RFR: 8252504: Add a method to MemoryLayout which returns a offset-computing method handle
Jorn Vernee
jvernee at openjdk.java.net
Thu Nov 19 15:58:30 UTC 2020
This PR adds two new methods: `bitOffsetHandle` and `byteOffsetHandle` to `MemoryLayout`, that can be used to create method handles that can compute the effective offset of a layout element given a set of additional `long` indexes.
I also cleaned up a leftover in the javadoc of bitOffset and byteOffset where an API note was stating that `sequenceElement()` layout path elements would be interpreted as `sequenceElement(0)`, but they were actually being rejected outright (as they should).
I also added some tests to cover the corner case where an UnsupportedOperationException was being thrown. (some of the churn in the tests is from introducing static imports. I hope it's not too noisy).
-------------
Commit messages:
- Add positive byteOffsetHandle test, and test that tests a bit offset that is not a multiple of 8
- Polish impl
- Remove unused imports
- Added more tests, touched up javadoc
- WIP - javadoc
- WIP
Changes: https://git.openjdk.java.net/panama-foreign/pull/396/files
Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=396&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8252504
Stats: 275 lines in 5 files changed: 216 ins; 7 del; 52 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/396.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/396/head:pull/396
PR: https://git.openjdk.java.net/panama-foreign/pull/396
More information about the panama-dev
mailing list