-
Bug
-
Resolution: Fixed
-
P2
-
21
Consider the following code:
CharSequence csq = java.nio.CharBuffer.wrap(new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g'});
// CharBuffer::allocate spec
// Throws:
// BufferOverflowException – If there is insufficient space in this buffer
// IndexOutOfBoundsException – If start or end are negative, start is greater than end, or end is greater than csq.length()
System.out.println("csq.length() = " + csq.length());
int capacity = 1;
java.nio.CharBuffer.allocate(capacity).append(csq, 0, 4);
The expectations are to get java.nio.BufferOverflowException which is the case for JDK21 b18, however for b19 IOOBE is thrown:
jshell> java.nio.CharBuffer.allocate(1)
...> .append(java.nio.CharBuffer.wrap(new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g'}), 0, 4);
...>
| Exception java.lang.IndexOutOfBoundsException: Range [0, 0 + 4) out of bounds for length 1
| at Preconditions.outOfBounds (Preconditions.java:100)
| at Preconditions.outOfBoundsCheckFromIndexSize (Preconditions.java:118)
| at Preconditions.checkFromIndexSize (Preconditions.java:397)
| at Objects.checkFromIndexSize (Objects.java:437)
| at CharBuffer.put (CharBuffer.java:1088)
| at HeapCharBuffer.put (HeapCharBuffer.java:260)
| at CharBuffer.append (CharBuffer.java:2050)
| at HeapCharBuffer.append (HeapCharBuffer.java:329)
| at (#5:2)
CharSequence csq = java.nio.CharBuffer.wrap(new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g'});
// CharBuffer::allocate spec
// Throws:
// BufferOverflowException – If there is insufficient space in this buffer
// IndexOutOfBoundsException – If start or end are negative, start is greater than end, or end is greater than csq.length()
System.out.println("csq.length() = " + csq.length());
int capacity = 1;
java.nio.CharBuffer.allocate(capacity).append(csq, 0, 4);
The expectations are to get java.nio.BufferOverflowException which is the case for JDK21 b18, however for b19 IOOBE is thrown:
jshell> java.nio.CharBuffer.allocate(1)
...> .append(java.nio.CharBuffer.wrap(new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g'}), 0, 4);
...>
| Exception java.lang.IndexOutOfBoundsException: Range [0, 0 + 4) out of bounds for length 1
| at Preconditions.outOfBounds (Preconditions.java:100)
| at Preconditions.outOfBoundsCheckFromIndexSize (Preconditions.java:118)
| at Preconditions.checkFromIndexSize (Preconditions.java:397)
| at Objects.checkFromIndexSize (Objects.java:437)
| at CharBuffer.put (CharBuffer.java:1088)
| at HeapCharBuffer.put (HeapCharBuffer.java:260)
| at CharBuffer.append (CharBuffer.java:2050)
| at HeapCharBuffer.append (HeapCharBuffer.java:329)
| at (#5:2)
- relates to
-
JDK-8306959 (bf) CharBuffer.append(CharSequence,int,int) throws BufferOverflowException where IndexOutOfBoundsException expected
-
- Resolved
-
-
JDK-8306374 (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int])
-
- Resolved
-
-
JDK-8305811 (bf) Improve performance of CharBuffer::append(CharSequence[,int,int])
-
- Resolved
-