src/share/classes/java/nio/Heap-X-Buffer.java

Print this page

        

@@ -570,14 +570,17 @@
     public CharBuffer subSequence(int start, int end) {
         if ((start < 0)
             || (end > length())
             || (start > end))
             throw new IndexOutOfBoundsException();
-        int len = end - start;
+        int pos = position();
         return new HeapCharBuffer$RW$(hb,
-                                      -1, 0, len, len,
-                                      offset + position() + start);
+                                      -1, 
+                                      pos + start, 
+                                      pos + end,
+                                      capacity(),
+                                      offset);
     }
 
 #end[char]