RFR: 8240844: Remove dependency on java.desktop from javafx.base
Kevin Rushforth
kcr at openjdk.org
Mon Nov 3 21:43:02 UTC 2025
On Mon, 3 Nov 2025 17:51:12 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
> > 3. Removing the direct dependency on `java.desktop` from `javafx.graphics`, making it a `requires static` will almost certainly not be accepted as long as the implementation depends on it. I'll add more details when I review.
>
> I agree, this change has the biggest 'risk'. Still, I would like to bring this up for discussion, as there is a huge benefit (much higher than I thought). I have already considered discussing this on the mailing list, but I would like to know first whether this change might be out of question, as we would not need to discuss it in that case.
While I might not quite go as far as to say "out of the question", it is unlikely that such a proposal would be accepted. This would be an incompatible change, which we very rarely do, especially for features that are still useful (and even then, not without notice, such as deprecating API for removal, followed by later removal). Applications that use JavaFX Printing APIs would stop working in some cases, unpredictably so, since it would work as long as any other module required java.desktop, but would fail at runtime if not (with a confusing error message). The recently-added ImageIO support added to images would also behave differently. Whereas today loading a ".tiff" file will just work (by falling back to the ImageIO TIFF loader shipped with java.desktop), it would fail to load (gracefully, but it would fail nonetheless).
The difference between the `javafx.graphics` usage and the `javafx.base` usage, is that the `javafx.graphics` usage of `java.desktop` for printing is incidental, and is an implementation detail as far as the app is concerns: There is nothing in the API docs that suggests the use of the Java2D printing API. So we would effectively have to tell application developers -- via API docs, a CSR, and a release note (at least) -- "if you want to use these APIs, your application now has to add a dependency on `java.desktop` because we no longer do". That will be a hard sell.
So, feel free to raise it on the mailing list. In the mean time, either move this to Draft or revert the change in javafx.graphics.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1958#issuecomment-3482703068
More information about the openjfx-dev
mailing list