[foreign-memaccess] RFR: 8256466: MemoryLayout factories do not guard against null layouts
Jorn Vernee
jvernee at openjdk.java.net
Fri Nov 20 14:01:09 UTC 2020
On Thu, 19 Nov 2020 17:11:49 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> 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.
LGTM! Very cool.
-------------
Marked as reviewed by jvernee (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/397
More information about the panama-dev
mailing list