On Fri, 3 Apr 2026 21:57:29 GMT, Andy Goryachev <[email protected]> wrote:

>> Charlie Schlosser has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   fix typo in comments
>
> 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();

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

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

Reply via email to