RFR: 8367439: Bulk change notifications for ObservableSet and ObservableMap [v3]
Michael Strauß
mstrauss at openjdk.org
Fri Oct 24 00:14:22 UTC 2025
On Thu, 23 Oct 2025 21:51:05 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Michael Strauß has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:
>>
>> - Merge branch 'master' into feature/bulk-listeners
>> - remove unused variable
>> - Don't repeatedly call backingSet.size()
>> - Separate code paths for Change/IterableChange
>> - Use MapListenerHelper in PlatformPreferences to support bulk change notifications
>> - Factor out IterableSetChange/IterableMapChange implementations
>> - add tests, documentation
>> - Implementation of bulk change listeners for ObservableSet and ObservableMap
>
> modules/javafx.base/src/main/java/javafx/collections/MapChangeListener.java line 110:
>
>> 108: * reported with subsequent listener invocations.
>> 109: * <p>
>> 110: * After this method has been called, the current {@code Change} instance is no longer valid and
>
> The language might be a bit confusing (it is to me, at least, where you say it might be the same instance but it is no longer valid? how is that even possible?).
>
> Perhaps it could be rephrased to something like 'the Change instance returned by this method might be a different and must be used in subsequent operations' or something to that effect.
Yes, I see that this can be confusing. What I want to bring across is that:
1. You are not allowed to retain a reference to the "last" change instance and expect it to give you correct information after `next()` has been called.
2. You are not allowed to assume, just because the next change instance is the same object as the previous instance, that we're dealing with the same change.
How about this version:
* Callers must not make any assumptions about the identity of the {@code Change} instance
* returned by this method; even if the returned instance is the same as the current instance,
* it must be treated as a distinct logical change. Callers must also not retain a reference
* to a previous {@code Change} instance and expect it to be valid after this method has been
* called. Calling any method on an earlier change may result in undefined behavior.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1885#discussion_r2458069192
More information about the openjfx-dev
mailing list