On 18/02/2019 11:15, Andrew Dinn wrote:
:
Alan, I'll wait for your follow-up note before responding regarding the
arguments to force. I'll just note that the latest JEP draft accepts
start position and length [i.e. force(from, length)] rather than start
position and end position [i.e. force(from, to)]. I thought this would
be easier for clients to get right -- less danger of out by one errors.

The issues with the 2-arg force method that I think need discussion are:

1. long from/to vs. from/length vs int index/length. Elements in buffers, or the starting index of a region, are addressed by an int index in the existing API. We are currently discussing absolute bulk get/put methods on nio-dev right now and the methods on the table use "int length", this is mostly because they are about bulk copying in/out of byte arrays where offet+length is the norm.

2. limit vs. capacity. If I read the webrev correctly, it checks the upper bound against the buffer capacity. I don't think we have any existing methods where you can specify an index that is >= limit.

3. The javadoc doesn't specify the exception thrown when the bounds checks fail. In the webrev I see that IAE is thrown but the existing buffer methods specify IIOBE. If you agree then it means you can replace the checks with one method:
   Objects.checkFromIndexSize(index, length, limit());

I think that's it.

-Alan

Reply via email to