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

(bf) CharBuffer.subSequence() does not represent specified subsequence

XMLWordPrintable

    • beta3
    • generic, sparc
    • generic, solaris_7
    • Verified

      StringCharBuffer.subSequence(int start,int end) does not represent specified subsequence of buffer, relative to the current position.


      String source = "This is the string used to test subSequence() method";
      StringCharBuffer c = (StringCharBuffer)(CharBuffer.wrap(source));
      // Set the position of c to some value.
      int position = 5;
      c.position(position);
      int start = 5;
      int end = 10;
      CharBuffer cNew = (CharBuffer)(c.subSequence(start,end));
      if(!source.substring(position+start,position+end).equals(cNew.toString())) {
       System.out.println("error");
       System.out.println("New buffer contains: "+cNew.toString());
       System.out.println("Expected: "+source.substring(position+start,position+end));
      }

      results in :
      error
      New buffer contains: is th
      Expected: e str


      ###@###.### 2001-10-04
      Since StringCharBuffer is no longer public class, this bug cannot be verified.
      Bug 4511104 has been created that addresses CharBuffer's issues. (see 4415483)

            iris Iris Clark
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: