On Fri, 14 Aug 2026 13:10:27 GMT, Alan Bateman <[email protected]> wrote:

>> I think that is already true of `uncheckedGetBytesOrThrow` at least for 
>> latin1 strings, does this seem significantly worse?
>> 
>> Once `Vector` is no longer incubating it'd be possible to have this just 
>> return `ByteVector`.
>> 
>> In the shorter term I think this could use `MemorySegment`. There's 
>> discussion in the thread about why `MemorySegment` isn't the right choice 
>> for a public API (it leaks the mutable backing array to critical downcalls, 
>> and also through `heapBase`). But for an internal-only method in JLA maybe 
>> it's better than the values array.
>
> There is on going effort to make direct access more auditable, and naming is 
> critical. The naming and warning in uncheckedGetBytesOrThrow was part of that 
> effort. We have to be very careful. So I think the high level comment is to 
> explore all other directions/options before proposing another back door into 
> string internals.

Understood, thanks!

I went ahead and updated this to use a read-only `MemorySegment` instead of 
exposing the `values` array, which still wouldn't be safe for a public API like 
I mentioned but is less dangerous for internal use. None of the naming or 
documentation here is intended to be a final proposal, just a prototype for 
discussion of the potential Vector APIs.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32373#discussion_r3784232141

Reply via email to