On Wed, 28 Sep 2022 09:51:08 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> To remove an index, I guess we need to first do setSelection where we will >> already throw IOOBE so I guess that's why this method does not mention or >> handle it explicitly > >> To remove an index, I guess we need to first do setSelection where we will >> already throw IOOBE so I guess that's why this method does not mention or >> handle it explicitly > > It's not required by the implementation. > > > selectionModel.setSelectionInterval(0, 1); > selectionModel.removeIndexInterval(Integer.MIN_VALUE, -1); > > > works … that is the call to `removeIndexInterval` throws the > `IndexOutOfBoundsException` because it tries to copy the bits in the removed > interval. If `rmMinIndex` is negative, the implementation may throw IOOBE > before doing other work as an optimisation or rely on it being thrown from > the code below as it does now. > > Other methods specify the behaviour for negative parameters, this method > would benefit from it too. I suggest amending `setSelectionInterval` to throw IOOBE if `Integer.MAX_VALUE` is passed. Then I suggest amending `removeIndexInterval` to throw IOOBE if a negative value is passed or an index is `Integer.MAX_VALUE`. Explicit handling of negative values could be an optimisation made in addition to handling `MAX_VALUE`. In both cases, the spec needs to be updated, and therefore the CSR will be required. ------------- PR: https://git.openjdk.org/jdk/pull/10409