8065262: (bf spec) CharBuffer.chars() should make it clearer that the sequence starts from the buffer position

Brian Burkhalter brian.burkhalter at oracle.com
Thu Feb 14 22:36:15 UTC 2019


https://bugs.openjdk.java.net/browse/JDK-8065262 <https://bugs.openjdk.java.net/browse/JDK-8065262>

One possibility would be to update the class level specification as

To clear this up, perhaps a sentence could merely be added to the specification of CharBuffer in X-Buffer.java.template: 

#if[char]
 *
  * <p> This class implements the {@link CharSequence} interface so that 
  * character buffers may be used wherever character sequences are accepted, for 
  * example in the regular-expression package {@link java.util.regex}. 
+ * {@code CharSequence} methods operate relative to the current position of 
+ * the buffer when they are invoked. 
  * </p>
 *
#end[char]

An alternative, given that chars() is overridden in CharBuffer, would be to copy its specification with the addition of verbiage indicating that the IntStream starts from the current position. The same problem would however remain for CharSequence.codePoints().

Thanks,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190214/a69d8971/attachment-0001.html>


More information about the nio-dev mailing list