RFR: 8138842: TableViewSelectionModel.selectIndices does not select index 0
John Hendrikx
jhendrikx at openjdk.org
Tue Jan 31 19:44:01 UTC 2023
On Tue, 31 Jan 2023 19:36:12 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> modules/javafx.controls/src/main/java/javafx/scene/control/TableView.java line 2645:
>>
>>> 2643:
>>> 2644: @Override public void selectIndices(int row, int... rows) {
>>> 2645: if (rows == null || rows.length == 0) {
>>
>> To get `rows` to be `null` you'd have to call this method as: `selectIndices(2, null)` -- IMHO that should result in an exception, and not be accepted to be the same as `selectIndices(2)` or `selectIndices(2, new int[0])`.
>>
>> I checked the documentation, and it does not mention that `null` is allowed here, which means it isn't.
>>
>> Also: weird method signature, but I guess if you want to enforce at least one parameter it could be done this way.
>
> 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);
-------------
PR: https://git.openjdk.org/jfx/pull/1018
More information about the openjfx-dev
mailing list