On Thu, 19 Dec 2024 09:48:23 GMT, Per Minborg <[email protected]> wrote:
> This PR proposes to improve the current `MemorySegment.toString()` method
> from:
>
> `MemorySegment{ address: 0x60000264c540, byteSize: 8 }`
>
> to
>
> `MemorySegment{ native, address: 0x60000264c540, byteSize: 8, confined, not
> alive, read-only, mapped }`
>
> Tests passes tier1-tier3
I'm not sure if all this information is useful to have in the toString output.
I'll note that all of this information is publicly accessible through the
MermorySegment interface aswell, so could be printed with additional print
statements. Except for confined-ness, which is exposed through `isAccessibleBy`
instead, since confined-ness is not a property of memory segments, but of
arenas (and I don't think we should expose it directly like this).
Subjectively, I think the things that are reasonable to expose in the toString
output are the things that are already exposed today: the heap base,
address/offset, and size. I would find it reasonable to add
`isAlive=true/false` to that, but it's not a property of the MS itself, but of
the scope that it is attached to, so I'm not sure. But, read-only, and mapped
are things I don't think are relevant often enough to include.
If you want a complete overview of the properties of the object, I think what
you really want is a debugger :)
-------------
PR Review: https://git.openjdk.org/jdk/pull/22826#pullrequestreview-2515753797