[External] : Re: MemorySegment APIs for reading and writing strings with known lengths

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Nov 7 16:39:56 UTC 2025


Hi,
here's a document that outlines a more general strategy to read and 
write strings from/to memory segments:

https://cr.openjdk.org/~mcimadamore/panama/strings_ffm.html

As outlined in this thread, the enabling primitive for the writing side 
is a factory that allows to view a Java string as a read-only heap 
memory segment.

We believe the proposed strategy should provide better usability, while 
at the same time leaving room for the implementation to "cut corners", 
to make performance as good as possible.

Let us know what you think.

Cheers
Maurizio

On 05/11/2025 12:45, Liam Miller-Cushon wrote:
> Thanks Maurizio, considering all of this holistically makes sense. I 
> look forward to hearing your thoughts on it once you've had time to 
> consider the options :)
>
> On Tue, Nov 4, 2025 at 11:21 PM Maurizio Cimadamore 
> <maurizio.cimadamore at oracle.com> wrote:
>
>
>     On 04/11/2025 15:23, Jorn Vernee wrote:
>>>     Do you have thoughts on the best way to proceed here? Do you
>>>     think it makes sense to do incrementally, or would you prefer to
>>>     see all of these related changes happen together under a single
>>>     issue?
>>>
>>     I don't have a preference. Since you've already started a PR for
>>     enhancing getString, maybe you can focus on that for now, and
>>     we'll file followup issues for the others. Splitting things up
>>     might be nice since there's probably some benchmarking work
>>     involved for each. I think the copy and allocateFrom overload can
>>     be done in one patch though.
>>
>     I think I sort of do have a preference :-)
>
>     My feeling is that we're dealing with 2-3 different APIs that are
>     all tightly interconnected. We have some ideas on how to solve
>     some (I think getString with explicit length seems the most
>     settled), but we're still playing with other ideas for the others
>     (like copy, or memory segment views). And we also have to think
>     about relationship with SegmentAllocator.
>
>     For this reason, I'd prefer to think about it more holistically
>     and think about all the related APIs at once.
>
>     Once we get a consensus on how to proceed we can decide whether to
>     pursue them all in a single PR, or split them into separate PRs.
>
>     But it would be unfortunate, I think, if the first PR would later
>     reveal to be a dead end for the other use cases.
>
>     I plan to think about this some more (but I need some more time).
>
>     Cheers
>     Maurizio
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20251107/70b4db14/attachment.htm>


More information about the panama-dev mailing list