[foreign-memaccess+abi] RFR: 8303879: Add MemoryLayout.withoutName() [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Mar 9 10:48:18 UTC 2023


On Thu, 9 Mar 2023 10:43:44 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR proposes to add a method `MemoryLayout::withoutName` which allows `MemoryLayout` instances to be checked for functional equivalence (i.e. "everything except the name is the same"). This might be useful for reuse, caching etc. of MemoryLayouts and constructs that consists/depends on one or more `MemoryLayout` instance.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rename method name

Looks good - nice beefing up of the test

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

> 206:      * but with no name.
> 207:      * <p>
> 208:      * Nameless layouts can be checked for equality to see if they are otherwise equal.

Suggestion:

     * This can be useful to compare two layouts that have different names, but are otherwise equal.

src/java.base/share/classes/java/lang/foreign/ValueLayout.java line 516:

> 514: 
> 515:     /**
> 516:      * A nameless unaligned value layout constant whose size is the same as that of a Java {@code short}

I would avoid saying "nameless" here - names are optional - if we don't say anything, it implies that users shouldn't make any assumption on the name being there.

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

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


More information about the panama-dev mailing list