RFR: 8240844: Remove dependency on java.desktop from javafx.base
Kevin Rushforth
kcr at openjdk.org
Mon Nov 3 17:21:46 UTC 2025
On Sun, 2 Nov 2025 19:40:04 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
> This PR makes the `java.desktop` requirement static for `javafx.base` and `javafx.graphics`.
> With this changes, a JavaFX app without `Swing` and the `WebView` will be much smaller (results below).
>
> Consequences:
> - `java.desktop` need to be loaded (required) when using anything from the `javafx.beans.property.adapter` package (the property classes from `java.beans.XXX` are used here)
> - `java.desktop` need to be loaded (required) when using printing, that is e.g. `PrinterJob.createPrinterJob().showPrintDialog(..)`
>
> Results:
> - Removing `java.desktop` gives a huge size boost! I benchmarked the following values when using `jlink` with: [`zip-6`, `--no-man-pages`, `--no-header-files`, `--strip-debug`, `--strip-java-debug-attributes`] to build an own runtime
>
> Tried on a real application (here called `myapp`) with JDK-25 on Windows 11 that has dependencies to: [`javafx-base`, `javafx-graphics`, `javafx-fxml`, `javafx-controls`]
>
> ---
>
> `master`
>
> `70.009.288 Bytes`
>
>
> myapp
> java.base at 25
> java.datatransfer at 25
> java.desktop at 25
> java.prefs at 25
> java.scripting at 25
> java.xml at 25
> javafx.base at 26-internal
> javafx.controls at 26-internal
> javafx.fxml at 26-internal
> javafx.graphics at 26-internal
> jdk.localedata at 25
> jdk.unsupported at 25
>
>
> -------------------------------------
>
> `This PR`
>
> `57.266.538 Bytes`
>
>
> myapp
> java.base at 25
> java.scripting at 25
> java.xml at 25
> javafx.base at 26-internal
> javafx.controls at 26-internal
> javafx.fxml at 26-internal
> javafx.graphics at 26-internal
> jdk.localedata at 25
> jdk.unsupported at 25
>
>
> ---
>
> `This PR` + https://github.com/openjdk/jfx/pull/1957
>
> `57.249.459 Bytes`
>
>
> myapp
> java.base at 25
> java.scripting at 25
> java.xml at 25
> javafx.base at 26-internal
> javafx.controls at 26-internal
> javafx.fxml at 26-internal
> javafx.graphics at 26-internal
> jdk.localedata at 25
>
>
> ---
>
> So we save around 13MB. If building a native package, e.g. an `.msi` installer, this will be even higher.
>
> This change however probably need some discussion, if we want to go that direction + add a note in the release notes, that if one of the two things mentioned above are needed, an requirement to `java.desktop` is needed (in case of a modular project).
Three quick comments before I review.
1. This will need a CSR
2. Removing the direct dependency on `java.desktop` from `javafx.base`, making it a `requires static`, seems reasonable, as I wrote in the description of the enhancement request. This will need testing.
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.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1958#issuecomment-3481656301
More information about the openjfx-dev
mailing list