RFR: 8290310: ChangeListener events are incorrect or misleading when a nested change occurs [v3]

John Hendrikx jhendrikx at openjdk.org
Sun Apr 16 07:37:58 UTC 2023


On Sun, 16 Apr 2023 04:13:22 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> John Hendrikx has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Improve generics on ObservableValueBase
>>  - Improve generics
>
> modules/javafx.base/src/main/java/javafx/beans/property/ObjectPropertyBase.java line 91:
> 
>> 89:     @Override
>> 90:     public void addListener(InvalidationListener listener) {
>> 91:         LISTENER_MANAGER.addListener((ObjectPropertyBase<Object>) this, listener);
> 
> I think the unchecked casts here can be removed if `ListenerManagerBase` is declared as `ListenerManagerBase<T, I extends ObservableValue<? extends T>>`, and `OldValueCachingListenerManager` accordingly. Then the `LISTENER_MANAGER` instance can be parameterized as `OldValueCachingListenerManager<Object, ObjectPropertyBase<?>>`.

Thanks, I gave up on that one a bit, I was looking for a better solution, but never got the generics quite the way I wanted them there, but your change works. I was primarily aiming to keep the casts as much out of the inner loops as possible.

 I still need to do one cast at this line, but it is a huge improvement:

    @Override
    public void addListener(ChangeListener<? super T> listener) {
        LISTENER_MANAGER.addListener(this, (ChangeListener<Object>) listener);
    }

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1081#discussion_r1167753159


More information about the openjfx-dev mailing list