On Sat, 4 Apr 2026 02:16:55 GMT, Charlie Schlosser <[email protected]> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/TableView.java 
>> line 1761:
>> 
>>> 1759:                         for (index++; index < minSize && 
>>> !prevState.get(index).equals(newState.get(index)); index++);
>>> 1760:                         // The positions at [from, index) in 
>>> prevState were replaced by the corresponding positions in newState.
>>> 1761:                         List<TablePosition<S, ?>> removed = 
>>> (List<TablePosition<S, ?>>) (List<?>) prevState.subList(from, index);
>> 
>> `(List<TablePosition<S, ?>>) (List<?>)`
>> 
>> generics gone wild!  it's weird that this is required to make it compile.
>> 
>> I wonder if it might be better to drop generics altogether:
>> 
>>                         List removed = prevState.subList(from, index);
>>                         var c = new 
>> NonIterableChange.GenericAddRemoveChange(from, index, removed, newState);
>>                         sm.fireCustomSelectedCellsListChangeEvent(c);
>> 
>> 
>> (we've lost type safety either way)
>
> How about one ugly double cast at the top?
> 
> 
> -        final List<TablePosition> prevState = selectionModel == null ?
> +        final List<TablePosition<S,?>> prevState = selectionModel == null ?
>                  null :
> -                new ArrayList<>(selectionModel.getSelectedCells());
> +                new 
> ArrayList<>((List<TablePosition<S,?>>)(Object)selectionModel.getSelectedCells());
> 
> 
> This pattern follows from:
> 
> 
> final ObservableList<TablePosition<S,?>> newState = 
> (ObservableList<TablePosition<S,?>>)(Object)sm.getSelectedCells();

I don't know, it's probably ok as is - the generics failed us already.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2131#discussion_r3040099986

Reply via email to