RFR: 8138842: TableViewSelectionModel.selectIndices does not select index 0

Andy Goryachev angorya at openjdk.org
Tue Jan 31 19:39:00 UTC 2023


On Tue, 31 Jan 2023 19:31:46 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> In `selectIndices` method, zero length array is not considered while ignoring row number given as parameter.
>> 
>> Updated the code to consider both null and zero length array in the condition before ignoring the row value given as parameter.
>> 
>> Added unit test to validate the fix
>
> 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.

-------------

PR: https://git.openjdk.org/jfx/pull/1018


More information about the openjfx-dev mailing list