@@ -1897,21 +1897,31 @@ public abstract sealed class $Type$Buffer
1897
1897
#if[char]
1898
1898
1899
1899
/**
1900
- * Absolute bulk <i>get</i> method.
1900
+ * Relative bulk <i>get</i> method.
1901
1901
*
1902
1902
* <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
+ * }
1906
1913
*
1907
1914
* @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()}
1910
1919
*
1911
1920
* @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()}
1915
1925
*
1916
1926
* @param dst
1917
1927
* The destination array
@@ -1924,14 +1934,16 @@ public abstract sealed class $Type$Buffer
1924
1934
* If the preconditions on the {@code srcBegin}, {@code srcEnd},
1925
1935
* and {@code dstBegin} parameters do not hold
1926
1936
*
1927
- * @implSpec This method is equivalent to
1928
- * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}.
1929
- *
1930
1937
* @since 25
1931
1938
*/
1932
1939
@Override
1933
1940
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);
1935
1947
}
1936
1948
1937
1949
/**
0 commit comments