RFR: 8358255: Factor out boilerplate code of EventHandler properties in Scene and Window

John Hendrikx jhendrikx at openjdk.org
Tue Jun 3 16:47:04 UTC 2025


On Tue, 3 Jun 2025 16:32:21 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> I've tried to do something similar for controls by replacing a lot of the anonymous classes with concrete ones. I can't find the issue/discussion right now, but Kevin measured a non-negligible increase in memory usage. I assume it's because constant folding is doable for the constants in the methods of the anonymous class, but not for the final fields in the concrete property (because they are not really final when considering reflection).
> 
> Because an application doesn't have a lot of windows and scenes, it's possible that these changes won't have detrimental effects, but I suggest measuring.

I think that's not really needed; we'd be crippling any FX improvements if the criteria is that we can't use more memory than before?  The better question is, is having less classes (improving the **common** case), and less code an acceptable trade-off versus the case where you have hundreds or thousands of scenes and windows?  I think it is.  These classes weigh-in at thousands of bytes already (and far more once their peer is created); we're not doing anyone any favors by being overly cautious here.

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

PR Comment: https://git.openjdk.org/jfx/pull/1819#issuecomment-2936263900


More information about the openjfx-dev mailing list