[foreign-memaccess] RFR: 8256466: MemoryLayout factories do not guard against null layouts
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Nov 19 17:17:27 UTC 2020
After starting some of the work to improve NPE handling on foreign-abi, I realized that what I was doing was indeed mechanical, and very amenable to a single, centralized test which sends null into all reference-accepting API methods.
The new test, `TestNull` takes care of this task; it is much easier to maintain, as, moving forward, we only need to add new classes to the tests, or add methods to the exclude list.
For each method featuring at least one reference type, the test creates some default values for the non-reference parameters, and then a bunch of replacements for the reference parameter. The replacement could simply be `null`, but in the case of arrays and collections more complex replacements are provided (e.g. arrays and collections with null elements).
Both replacements and default values can be easily added by tweaking some of the test static initializers. An exclusion list is also provided for those APIs which are deliberately null-friendly.
This patch also reverts the test changes from yesterday's PR, and also some of the null-related tests which has been added in the past.
-------------
Commit messages:
- Add combinatorial test to check handling of nulls in reference-accepting APIs
Changes: https://git.openjdk.java.net/panama-foreign/pull/397/files
Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=397&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8256466
Stats: 554 lines in 14 files changed: 226 ins; 327 del; 1 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/397.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/397/head:pull/397
PR: https://git.openjdk.java.net/panama-foreign/pull/397
More information about the panama-dev
mailing list