5071718: (bf) Add ByteBuffer.slice(int offset, int length)

Brian Burkhalter brian.burkhalter at oracle.com
Mon Feb 25 15:32:55 UTC 2019


Hi Alan, Roger,

> On Feb 25, 2019, at 6:48 AM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> 
> Is it intentional to prevent being able to create a zero length slice
> at index == limit?
> 
> Buffer: 618: and 628 with regards to the IOOBE
> 
> index must be non-negative and less than  limit()
> 
> I think that forces application code to do some unnecessary workarounds
> at a boundary condition.
> 
> The relative slice() method does not restrict the case where position() == limit().

Good point. I will change it accordingly.

> On 02/23/2019 01:15 PM, Alan Bateman wrote:
>> On 22/02/2019 23:34, Brian Burkhalter wrote:
>>> Please review the proposed fix [1] for issue [2] the CSR of which is [3]. The fix changes the existing package scope slice(int,int) method to be slice(index,length) instead of slice(position,limit) and modifies alignedSlice() accordingly. Overrides are added as needed for heap, direct, view, and StringChar buffers.
>>> 
>>> I suggest perhaps addressing the specification content first so that the CSR can move forward.
>>> 
>> I think this looks okay. The usefulness will be mostly ByteBuffer but I think okay to have it defined by each of the buffer classes. The "Additional operations" section in Buffer's javadoc will need a small update to mention the 2-arg slice.

I was wondering about adding some doc there. Will update.

Thanks,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190225/5c904c04/attachment.html>


More information about the nio-dev mailing list