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

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

    Details

    • Subcomponent:
    • Resolved In Build:
      b09

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: