Hi,

This is a continuation of the discussion that stemmed from changing
bidirectional bindings to use invalidation listeners instead of change
listeners [1].

The relevant issue in JBS is [2].

I have looked at removing the eager evaluation when attaching an
invalidation listener. I found that tests, for example, the
method 
BooleanPropertyBaseTest#testAddingListenerWillAlwaysReceiveInvalidationEvent
(only lines 428-432 are relevant) set the following requirement:

1. Start with a property in an invalid state.
2. Attach an invalidation listener.
3. Set a value which is different than the current one.
Result: an invalidation event must be sent.

This means that attaching an invalidation listener must validate the
property, which is (at least currently) only possible by evaluating the
value.

This is in contrast to the comment in the JBS that invalidation listeners
should not generally force eager evaluation. It is also in contrast to this
line in the class doc of ObservableValue:
"Implementations in this library mark themselves as invalid when the first
invalidation event occurs. They do not generate any more invalidation
events until their value is recomputed and valid again."

So, either the requirement set by the tests is wrong, or invalidation
listeners really do need to behave according to the test and the docs
missed a practical requirement, or my analysis is wrong.

There are more tests that fail, but the ones I looked at rely on the same
concept. For
example, Node_LocalToParentTransform_Test#shouldBeNotifiedWhenNodeTransforms()
tests the Node#LazyTransformProperty property. Interestingly, this one is
initialized with an invalid state, while Simple___Property are initialized
as valid.

Thoughts?

[1]
http://mail.openjdk.java.net/pipermail/openjfx-dev/2021-August/031778.html

[2] https://bugs.openjdk.java.net/browse/JDK-8208750

Reply via email to