[foreign-memaccess+abi] RFR: 8292038: Split factories to create sequence layouts

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Aug 10 09:21:49 UTC 2022


On Wed, 10 Aug 2022 08:00:02 GMT, Per Minborg <duke at openjdk.org> wrote:

> This PR splits the `MemoryLayout::sequence` method into two separate overloads:
> 
> 1. Explicit `elementCount`
> 2. Inferred `elementCount`

Looks good, I think it makes the code easier to read.

src/java.base/share/classes/java/lang/foreign/MemoryLayout.java line 688:

> 686:      * <blockquote><pre>{@code
> 687:      * maxElementCount = Long.MAX_VALUE / elementLayout.bitSize();
> 688:      * }</pre></blockquote>

Perhaps, now that we have another separate factory, it would be better to explain this method like we do in other cases - e.g. "this is equivalent to the following code" and the show a snippet which calls the other factory with the Long.MAX_VALUE calculation.

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

PR: https://git.openjdk.org/panama-foreign/pull/704


More information about the panama-dev mailing list