The spec for the following overriding method
https://docs.oracle.com/javase/8/docs/api/java/nio/CharBuffer.html#chars--
says (as the overridden method)
----------------------------
"Returns a stream of int zero-extending the char values from this sequence.
Returns: an IntStream of char values from this sequence "
----------------------------
The resulting stream is different for buffer instances produced differently:
Consider the following code:
System.err.println(CharBuffer.allocate(1).put("A").chars().iterator().hasNext());
System.err.println(CharBuffer.wrap("A").chars().iterator().next());
The output will be
false
65
Having the current specification of CharBuffer.chars()
and not knowing the whole background of a typical CharBuffer behavior
stream instance returned by the method might not be perfectly expected.
https://docs.oracle.com/javase/8/docs/api/java/nio/CharBuffer.html#chars--
says (as the overridden method)
----------------------------
"Returns a stream of int zero-extending the char values from this sequence.
Returns: an IntStream of char values from this sequence "
----------------------------
The resulting stream is different for buffer instances produced differently:
Consider the following code:
System.err.println(CharBuffer.allocate(1).put("A").chars().iterator().hasNext());
System.err.println(CharBuffer.wrap("A").chars().iterator().next());
The output will be
false
65
Having the current specification of CharBuffer.chars()
and not knowing the whole background of a typical CharBuffer behavior
stream instance returned by the method might not be perfectly expected.
- csr for
-
JDK-8219118 (bf spec) CharBuffer.chars() should make it clearer that the sequence starts from the buffer position
-
- Closed
-
- relates to
-
JDK-8014854 (bf) CharBuffer.chars too slow with default implementation
-
- Closed
-
- links to