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

(bf) buffer created by CharBuffer.subSequence() has different values for cap,lim

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_7

      Description

      Specification for CharBuffer.subSequence(int start, int end) says "new buffer's capacity will be that of this buffer, its position will be position() + start, and its limit will be position() + end."

      But in actual new buffer's capacity, limit and position values are different from what spec says.
       
      String source = "This is the string used to test subSequence() method";
      CharBuffer c = CharBuffer.wrap(source.toCharArray());
      int position = 5;
      int start = 5;
      int end = 10;
      c.position(position);
      CharBuffer cNew = (CharBuffer)(c.subSequence(start,end));
      int pos = c.position()+start;
      int lim = c.position()+end;
      System.out.println("position: "+cNew.position()+" Expected: "+pos);
      System.out.println("limit: "+cNew.limit()+" Expected: "+lim);
      System.out.println("capacity: "+cNew.capacity()+" Expected: "+c.capacity());

      results in
      position: 0 Expected: 10
      limit: 5 Expected: 15
      capacity: 5 Expected: 52

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iris Iris Clark
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: