RFR: 8240844: Remove dependency on java.desktop from javafx.base

Nir Lisker nlisker at openjdk.org
Tue Nov 4 12:33:52 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).

There was a discussion on this on the mailing list: https://mail.openjdk.org/pipermail/openjfx-dev/2023-November/043731.html.

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

PR Comment: https://git.openjdk.org/jfx/pull/1958#issuecomment-3485752164


More information about the openjfx-dev mailing list