Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8219118

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 13
    • core-libs
    • None
    • behavioral
    • minimal
    • Update to javadoc supporting existing behavior so no compatibility risk.
    • Java API
    • SE

      Summary

      Clarify the java.nio.CharBuffer specification to state that all implemented java.lang.CharSequence methods operate relative to the current buffer position.

      Problem

      CharBuffer implements a couple of CharSequence methods, chars() and codePoints(), but does not document that they operate with respect to the current buffer position as it does for the other overridden CharSequence methods.

      Solution

      Add a sentence to the class level specification clarifying that all implemented CharSequence methods operate with respect to the current buffer position.

      Specification

      --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template
      +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template
      @@ -209,6 +209,8 @@
        * <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}.
      + * The methods defined by {@code CharSequence} operate relative to the current
      + * position of the buffer when they are invoked.
        * </p>
        *
       #end[char]

            bpb Brian Burkhalter
            dbessono Dmitry Bessonov
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: