RFR: 8138842: TableViewSelectionModel.selectIndices does not select index 0
John Hendrikx
jhendrikx at openjdk.org
Tue Jan 31 19:44:02 UTC 2023
On Tue, 31 Jan 2023 19:40:06 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> I had the same thought here.
>> The signature is indeed weird, but since it is perfectly legal to invoke it with selectIndices(0, null), I think this change is absolutely correct.
>
> Well it's legal Java code, but that doesn't mean that leaving something `null` is allowed. At the very least it is undocumented behavior:
>
> /**
> * <p>This method allows for one or more selections to be set at the same time.
> * It will ignore any value that is not within the valid range (i.e. greater
> * than or equal to zero, and less than the total number of items in the
> * underlying data model). Any duplication of indices will be ignored.
> *
> * <p>If there is already one or more indices selected in this model, calling
> * this method will <b>not</b> clear these selections - to do so it is
> * necessary to first call clearSelection.
> *
> * <p>The last valid value given will become the selected index / selected
> * item.
> * @param index the first index to select
> * @param indices zero or more additional indices to select
> */
> public abstract void selectIndices(int index, int... indices);
I think it is also pretty clear the original author intended to check `rows.length == 0` and made the mistake that it would be called with `rows == null` when there are no further indices specified, which is incorrect.
-------------
PR: https://git.openjdk.org/jfx/pull/1018
More information about the openjfx-dev
mailing list