[foreign-memaccess+abi] RFR: 8291639: Improve the ability to visualize a MemorySegment in human readable forms [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri May 26 20:55:17 UTC 2023


On Fri, 26 May 2023 19:30:43 GMT, Glavo <duke at openjdk.org> wrote:

> 
> I don't want to map a `struct Point *` to `Point[]`. What I want is:
> 
This PR doesn't map a `struct Point*` to `Point[]`. This PR allows (_if you want and/or find it useful_) to view the bytes of a memory segment as components of a record class.

You keep bringing up the topic of having a deeper connection between structs and records, using this for dereference and for linking. And we keep looking at extremely simplistic struct declaration. What if the struct contains an array? Or a union? Those are the bits where the mapping becomes not as clearly defined as you make it to be. Should we add the API points you describe only for the case of a simple struct with X and Y fields? And, what if a developer realizes that some other kind of mapping, not involving records, might be more useful? How would that scenario be plugged into the API (which would, at that point be already biased towards records?).

I'm not trying to minimize your suggestions - but I think if you think through all the consequences of what you are proposing, you end up pulling in a fairly general custom serialization/deserialization strategy for segments, which, arguably, is exactly what we'd like the core API **not** to do.

(Your example is not clear as you use ValueLayout.OfRecord<X> (as you need generics for what you want to do) but then use a `structLayout` on the other side)

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

PR Comment: https://git.openjdk.org/panama-foreign/pull/833#issuecomment-1564936653


More information about the panama-dev mailing list