On Thu, 20 Nov 2025 08:31:12 GMT, Liam Miller-Cushon <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 2649:
>>
>>> 2647: *
>>> 2648: * @param src the Java string to be written into this segment
>>> 2649: * @param dstEncoding the charset used to {@linkplain
>>> Charset#newEncoder() encode}
>>
>> I'm not sure we have a dependency on the charset being standard?
>
> We do not, thanks, fixed.
>
> Although I think the existing `allocateFrom(String, Charset)` method does
> have an undocumented dependency, because it uses `CharsetKind` to get the
> terminator char length, which only supports standard Charsets. If we add a
> fast path for UTF-16 that may need a dependency on a standard Charset (or a
> standard way to get the code unit size of a charset, if it has one).
Note sure I follow -- the method you mention says this:
* @throws IllegalArgumentException if {@code charset} is not a
* {@linkplain StandardCharsets standard charset}
What do you mean by "undocumented dependency"?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2549932198