On Mon, 2 Dec 2024 14:50:16 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> This PR proposes to correct errors in the `MemorySegment::getString` >> documentation. >> >> There is a test in >> https://github.com/openjdk/jdk/pull/22451/files#diff-13a3535a65f1e0664e98bd2584196eb9d9a0ada951fd2dabfac8a484263235d8R271 >> that actually tests an Exception with the correct message is thrown if no >> null terminator can be found. > > src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 1280: > >> 1278: * largest string supported by the platform >> 1279: * @throws IndexOutOfBoundsException if {@code offset < 0} >> 1280: * @throws IndexOutOfBoundsException if no {@code '\0'} terminator >> is present in > > Maybe we should say "string terminator" instead of `\0`. Because the > specified byte sequence of the string terminator is charset specific. So > maybe: > >> if no string terminator (e.g. `\0`) is present ... The size of the string >> terminator depends on the selected charset (... follow with text from the >> previous javadoc ... ) (probably we should only expand on the charset digression in the `getString` method which takes a charset ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22488#discussion_r1865990500