Add getChars to CharSequence (original) (raw)

Martin Buchholz martinrb at google.com
Sun May 19 20:33:19 UTC 2013


On Thu, May 9, 2013 at 5:38 AM, Alan Bateman <Alan.Bateman at oracle.com>wrote:

On 08/05/2013 23:05, Martin Buchholz wrote:

Alan (et al): Ping.

I've looked through the webrev. The scary part is subsequenceRaw where the offsets including the position. I don't see anything obviously wrong and the tests should catch any issues. I don't see any issue conditionally generating the isDirect/order methods although it should been harmless.

Yes, it's scary, but it's much scarier to me carrying around relative positions than absolute because position() can change at any time if there is a data race. So after bounds checking we must work with absolute positions, or at least must when working with Unsafe.


Existing code is a little schizoid about checking for the possibility of limit() < position(), as can happen with a data race. Sometimes checked; sometimes not. Sometimes assert()ed. Sometimes adjusted. Probably the right thing is to check and throw ConcurrentModificationException if detected. But not in this changeset.

    int pos = this.position();
    int lim = this.limit();
    assert (pos <= lim);
    int rem = (pos <= lim ? lim - pos : 0);


More information about the core-libs-dev mailing list