[foreign-memaccess+abi] RFR: 8291639: Improve the ability to visualize a MemorySegment in human readable forms [v4]
Duncan Gittins
duncan.gittins at gmail.com
Thu Aug 4 12:14:07 UTC 2022
I would agree - it doesn't feel right to add such as specific method for
debug/textual representation of a MemorySegment when it could instead be a
more flexible utility in a separate support library class.
Currently developers can implement a reasonably useful hex format using
toArray() and HexFormat, perhaps need something like:
new
DebugFormat(segment).wantHex().wantChars().wantOctal().stream().forEach(
... ).
new DebugFormat(byte[] somebytearray, int from int
to).wantHex().wantChars().stream().forEach( ... ).
Kind regards
Duncan
On Thu, 4 Aug 2022 at 11:01, Maurizio Cimadamore <mcimadamore at openjdk.org>
wrote:
> On Thu, 4 Aug 2022 09:46:29 GMT, Maurizio Cimadamore <
> mcimadamore at openjdk.org> wrote:
>
> >> Per-Åke Minborg has updated the pull request incrementally with one
> additional commit since the last revision:
> >>
> >> Fix failing test and rename variables
> >
> > src/java.base/share/classes/java/lang/foreign/MemorySegment.java line
> 1892:
> >
> >> 1890: * </ul>
> >> 1891: * </li>
> >> 1892: * <li>Grouped layouts are enclosed in curly
> brackets.</li>
> >
> > Shouldn't it be "values that are part of a group layout" ? Also maybe
> add a linkplain to `GroupLayout`. Same for sequence layout. I also note
> that you use the "are rendered" in the above text. Maybe you can lean on it
> - e.g.
> >
> > "values in a group layout are rendered with enclosing curly braces".
>
> Possible questions: why are address values represented as toString? Or
> numbers in decimal form? What if I want hex form? This is the part that
> makes me uncomfortable about this method: in a way, you almost want it to
> generate some kind of XML or json schema - and then leave the toString
> mapping to the user - but this method is doing everything, so it has to
> make opinionated choices at every step of the way, and I can see how some
> of those choices would be good for some and bad for others.
>
> -------------
>
> PR: https://git.openjdk.org/panama-foreign/pull/695
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220804/1138c771/attachment.htm>
More information about the panama-dev
mailing list