JFXTras to JavaFX 8 migration

Tom Eugelink tbee at tbee.org
Sat Apr 6 13:34:29 PDT 2013

I'm in the process of migrating my controls in JFXtras to JFX8. One of the issues I run in to is that my ListSpinner control gets stuck in a very long loop when it is used to spin over the years, where it does not on JFX2.2. The reason seems to be that the ObservableListWrapper, used to turn a regular List into a observable one (which is returned by FXCollections.observableList) is somehow by-passing the optimized indexOf that is implemented in my ListSpinnerIntegerList.

ListSpinnerIntegerList extends AbstractList and overrides get() and size() to get an unmodifiable list as per JavaDoc.

ListSpinnerIntegerList also overrides indexOf, because it has a very large range and instead of iterating, the index can easily be calculated from the value.

In JFX 2.2 this works correctly, in JFX 8.0 the optimized indexOf is 'never' reached, but the JavaFX thread is busy in the iteration based implementation of indexOf in AbstractList.

However, I cannot explain how it gets there and not in my optimized indexOf. The implementation of indexOf in ObservableListWrapper seems to forward it to the backing list.

So I'm expecting
call list.index() -> ObservableListWrapper.indexOf() -> backingList.indexOf() which is ListSpinnerIntegerList.indexOf()

But that does not happen. The current workaround basically by overriding indexOf re-enforces the behavior of calling the backing list.
See line 118 in https://github.com/JFXtras/jfxtras-labs/blob/8.0/src/main/java/jfxtras/labs/scene/control/ListSpinner.java

I'm suspecting I'm not seeing the correct implementation of indexOf in ObservableListWrapper.

How is indexOf implemented in ObservableListWrapper in 8.0?


More information about the openjfx-dev mailing list