-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
Given a `GroupLayout`, the elements in the group are matched with `RecordComponent`s. This can be done for arbitrary element types of arbitrary depth. As a simple example, one can extract a `Point` like so:
```
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]
```
```
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]
```
- csr for
-
JDK-8308968 Add a record mapper for mapping MemorySegments to Record instances
-
- Draft
-
- relates to
-
JDK-8291639 Improve the ability to visualize a MemorySegment in human readable forms
-
- Closed
-
- links to
-
Review openjdk/panama-foreign/833