RFR: 8294809: ListenerHelper for managing and disconnecting listeners [v9]

Andy Goryachev angorya at openjdk.org
Tue Nov 15 18:20:14 UTC 2022


On Tue, 15 Nov 2022 06:17:21 GMT, Ajit Ghaisas <aghaisas at openjdk.org> wrote:

>> Right, there is no way the accessor can be null, since it is initialized at class load time in the static initializer, We do this in many other places (e.g., Node.java).
>
> The `accessor` cannot be null **only if** it is used from *Skins.
> In the current form, as we provide a no-argument public constructor, it is possible to create an object of `ListenerHelper` without calling setAccessor. Many unit tests added as part of this PR create such `ListenerHelper` objects.

The `accessor` is used **only** if used from *Skins, meaning to get it from a Skin, one needs to invoke `get(SkinBase)` method, and it's magically not a null there!

It is perfectly fine to create an instance of ListenerHelper using the constructor.  The `accessor` will be null, of course, but it's ok because it will never be used until one calls `get(SkinBase)` ... and see above.

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

PR: https://git.openjdk.org/jfx/pull/908


More information about the openjfx-dev mailing list