On Wed, 17 Dec 2025 13:43:35 GMT, Marius Hanl <[email protected]> wrote:
> When compiling JavaFX with Java 25, a new warning appears. This warning will > result in a compilation failure because warnings are treated as error > (`-Werror`). > > The following warning appears: > > >> Task :controls:compileJava > C:..\jfx\modules\javafx.controls\src\main\java\javafx\scene\control\SplitPane.java:320: > warning: [identity] use of a value-based class with an operation that > expects reliable identity > private final WeakHashMap<Integer, Double> dividerCache = new > WeakHashMap<>(); > ^ > C:..\jfx\modules\javafx.controls\src\main\java\javafx\scene\control\SplitPane.java:320: > warning: [identity] use of a value-based class with an operation that > expects reliable identity > private final WeakHashMap<Integer, Double> dividerCache = new > WeakHashMap<>(); > ^ > error: warnings found and -Werror specified > 1 error > 2 warnings > >> Task :controls:compileJava FAILED > > > The warning makes sense: We use a `WeakHashMap` with the `Integer` class. So > the `Integer` values are saved as `WeakRef` inside the `Map`. This makes no > sense and is rightfully a warning. 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. So this bug will prevent our being able to bump the minimum JDK to 25, which we plan to do per recent practice fairly early in the JavaFX 27 development cycle. 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). The Valhalla folks probably thought of this use case, so perhaps they have a suggested pattern to use? ------------- PR Comment: https://git.openjdk.org/jfx/pull/2010#issuecomment-3665852889
