On Wed, 17 Dec 2025 15:24:12 GMT, Kevin Rushforth <[email protected]> wrote:

> I know why it isn't happening for our build. The warning only happens if you 
> use `--release 25` (which is the default with JDK 25). We build JavaFX with 
> `--release 24` so haven't yet hit this warning.

Yes, correct. That is what I meant with 'compiling with Java 25', but should 
have made this more clear.

> So back to the solution. We can either do what you suggest and move away from 
> a WeakHashMap (not something I'd consider without evaluating the potential 
> leak) or switch the type of the key to a record containing an int (basically 
> inventing our own Integer class that has identity).

Using an Integer within a WeakRef makes no sense, does it? I don't think this 
will prevent anything from being garbage collected. We are using the small 
Integer (int) as well, as far as I can see. And Integers between -127 and 128 
are cached as well. So I don't see how weak keys are useful for Integer in any 
case.

> The Valhalla folks probably thought of this use case, so perhaps they have a 
> suggested pattern to use?

The reasoning is probably what I wrote above. But I will have a look! More 
information (and learning) is always good!

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

PR Comment: https://git.openjdk.org/jfx/pull/2010#issuecomment-3666082063

Reply via email to