diff --git a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java index cd38bd19227..024dfacb71b 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java +++ b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java @@ -1277,9 +1277,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * @throws IllegalArgumentException if the size of the string is greater than the * largest string supported by the platform * @throws IndexOutOfBoundsException if {@code offset < 0} - * @throws IndexOutOfBoundsException if {@code offset > byteSize() - (B + 1)}, where - * {@code B} is the size, in bytes, of the string encoded using UTF-8 charset - * {@code str.getBytes(StandardCharsets.UTF_8).length}) + * @throws IndexOutOfBoundsException if no string terminator (e.g. {@code '\0'}) is + * present in this segment between the given {@code offset} and the end of + * this segment. * @throws IllegalStateException if the {@linkplain #scope() scope} associated with * this segment is not {@linkplain Scope#isAlive() alive} * @throws WrongThreadException if this method is called from a thread {@code T}, @@ -1315,14 +1315,11 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * @throws IllegalArgumentException if the size of the string is greater than the * largest string supported by the platform * @throws IndexOutOfBoundsException if {@code offset < 0} - * @throws IndexOutOfBoundsException if {@code offset > byteSize() - (B + N)}, where: - *