[foreign-memaccess] RFR: 8256466: MemoryLayout factories do not guard against null layouts

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Nov 18 20:47:12 UTC 2020


On Wed, 18 Nov 2020 19:35:06 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayout.java line 454:
>> 
>>> 452:     private static <Z> Z computePathOp(LayoutPath path, Function<LayoutPath, Z> finalizer,
>>> 453:                                        Set<LayoutPath.PathElementImpl.PathKind> badKinds, PathElement... elements) {
>>> 454:         for (PathElement e : elements) {
>> 
>> What if `elements` itself is `null`? Doesn't seem to be covered currently in either impl or doc.
>
> e.g. a case like 
> MemoryLayouts.BITS_8_BE.map(UnaryOperator.identity(), null);

You are right, I got confused between `null` and zero-element array (which we do support with varargs call).

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/395


More information about the panama-dev mailing list