RFR: 8345186: Incorrect @throws doc for MemorySegment::getString

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Dec 3 14:19:39 UTC 2024


On Mon, 2 Dec 2024 14:08:14 GMT, Per Minborg <pminborg at 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 1318:

> 1316:      *         largest string supported by the platform
> 1317:      * @throws IndexOutOfBoundsException if {@code offset < 0}
> 1318:      * @throws IndexOutOfBoundsException if no string terminator (e.g. {@code '\0'}) is

Please re-add:


For instance, this is 1 for  {@link StandardCharsets#US_ASCII} and 2 for {@link StandardCharsets#UTF_16}


At the end, as that might clarify things.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22488#discussion_r1867804478


More information about the core-libs-dev mailing list