On Fri, 24 Oct 2025 00:12:01 GMT, Michael Strauß <[email protected]> wrote:
>> 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.
this is still a bit confusing... "identity" where did that come from?
maybe just tell them what they need to do instead: discard the last instance
and use the one returned by `next()` instead? what do you think?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1885#discussion_r2461481444