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

Print this page

        

@@ -194,14 +194,16 @@
         pos = (pos <= lim ? pos : lim);
         int len = lim - pos;
 
         if ((start < 0) || (end > len) || (start > end))
             throw new IndexOutOfBoundsException();
-        int sublen = end - start;
-        int off = offset + ((pos + start) << $LG_BYTES_PER_VALUE$);
-        assert (off >= 0);
-        return new ByteBufferAsCharBuffer$RW$$BO$(bb, -1, 0, sublen, sublen, off);
+        return new ByteBufferAsCharBuffer$RW$$BO$(bb, 
+                                                  -1, 
+                                                  pos + start,
+                                                  pos + end,
+                                                  capacity(),
+                                                  offset);
     }
 
 #end[char]