@@ -1897,21 +1897,31 @@ public abstract sealed class $Type$Buffer
18971897#if[char]
18981898
18991899 /**
1900- * Absolute bulk <i>get</i> method.
1900+ * Relative bulk <i>get</i> method.
19011901 *
19021902 * <p> This method transfers {@code srcEnd-srcBegin} characters from this
1903- * buffer into the given array, starting at index {@code srcBegin} in this
1904- * buffer and at offset {@code dstBegin} in the array. The position of this
1905- * buffer is unchanged.
1903+ * buffer into the given array, starting at index
1904+ * {@code position() + srcBegin} in this buffer and at offset
1905+ * {@code dstBegin} in the array. The position of this buffer is unchanged.
1906+ *
1907+ * <p> An invocation of this method behaves exactly the same was as the
1908+ * invocation
1909+ *
1910+ * {@snippet lang=java :
1911+ * get(position() + srcBegin, dst, dstBegin, srcEnd - srcBegin)
1912+ * }
19061913 *
19071914 * @param srcBegin
1908- * The index in this buffer from which the first character will be
1909- * read; must be non-negative and less than {@code limit()}
1915+ * The index in this buffer, relative to the current position,
1916+ * of the first character to
1917+ * read; must be non-negative and less than
1918+ * {@code limit() - position()}
19101919 *
19111920 * @param srcEnd
1912- * The index in this buffer directly before the last character to
1913- * read; must be non-negative and less or equal than {@code limit()}
1914- * and must be greater or equal than {@code srcBegin}
1921+ * The index in this buffer, relative to the current position,
1922+ * after the last character to read;
1923+ * must be greater than or equal to {@code srcBegin} and less than
1924+ * or equal to {@code limit() - position()}
19151925 *
19161926 * @param dst
19171927 * The destination array
@@ -1924,14 +1934,16 @@ public abstract sealed class $Type$Buffer
19241934 * If the preconditions on the {@code srcBegin}, {@code srcEnd},
19251935 * and {@code dstBegin} parameters do not hold
19261936 *
1927- * @implSpec This method is equivalent to
1928- * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}.
1929- *
19301937 * @since 25
19311938 */
19321939 @Override
19331940 public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
1934- get(srcBegin, dst, dstBegin, srcEnd - srcBegin);
1941+ // Check [srcBegin,srcEnd) is a subset of [0,limit()-position)
1942+ int pos = position();
1943+ int lim = limit();
1944+ Objects.checkFromToIndex(srcBegin, srcEnd, lim - pos);
1945+
1946+ get(pos + srcBegin, dst, dstBegin, srcEnd - srcBegin);
19351947 }
19361948
19371949 /**
0 commit comments