RFR: 8240844: Remove dependency on java.desktop from javafx.base
Marius Hanl
mhanl at openjdk.org
Sun Nov 2 19:45:49 UTC 2025
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).
-------------
Commit messages:
- 8240844: Remove dependency on java.desktop from javafx.base
Changes: https://git.openjdk.org/jfx/pull/1958/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1958&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8240844
Stats: 6 lines in 2 files changed: 2 ins; 1 del; 3 mod
Patch: https://git.openjdk.org/jfx/pull/1958.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1958/head:pull/1958
PR: https://git.openjdk.org/jfx/pull/1958
More information about the openjfx-dev
mailing list