[foreign-memaccess+abi] Withdrawn: 8308967: Add a record mapper for mapping MemorySegments to Record instances

duke duke at openjdk.org
Tue Jan 2 06:33:05 UTC 2024


On Fri, 26 May 2023 12:31:31 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes to add a "Record Mapper" that allows `MemorySegment` instances to be projected onto `Record` types given `GroupLayout` instances.
> 
> Here is a simple example of how to use the mapper:
> 
> 
>     private static final GroupLayout POINT_LAYOUT = MemoryLayout.structLayout(
>             JAVA_INT.withName("x"),
>             JAVA_INT.withName("y"));
> 
>     MemorySegment segment =  MemorySegment.ofArray(new int[]{3, 4});
> 
>     Point point = POINT_LAYOUT.recordMapper(Point.class)
>           .apply(segment); // Point[x=3, y=4]
> 
> 
> I think the implementation can be improved later, for example by de-duplicating handling of arrays and maybe add recursive "un-pealing" of multidimensional arrays.

This pull request has been closed without being integrated.

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

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


More information about the panama-dev mailing list