Review request for 6795561

Alan Bateman Alan.Bateman at Sun.COM
Tue Mar 24 08:47:58 UTC 2009


6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new 
buffer

Iris, you might want to review this one. 
CharBuffer#subSequence(start,end) is specified to return a char buffer 
that has a position of position() + start, a limit of position() + end, 
and a capacity of capacity(). For buffers created via 
CharBuffer#allocate or char buffer views we've always generated code 
that return a CharBuffer with a position of 0 and a limit and capacity 
that is the length of the subsequence. To my knowledge this hasn't been 
noticed, probably because it required casting the result to a char 
buffer. In jdk7 this method has been updated to take advantage of 
covariant returns so it's more likely to be noticed now. Furthermore, 
your old adversary StringCharBuffer (used when wrapping a char sequence) 
has been returning a buffer with the incorrect capacity since 6546113 
[1], leading to the IOOBE in the bug report. We should have caught this 
but didn't. To that end, I've added coverage to the unit test.

The webrev is here:
  http://cr.openjdk.java.net/~alanb/6795561/webrev.00/

Thanks,
Alan.

[1] http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c73cb47fe250



More information about the core-libs-dev mailing list