On Sun, 2 Nov 2025 19:40:04 GMT, Marius Hanl <[email protected]> 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@25
> java.datatransfer@25
> java.desktop@25
> java.prefs@25
> java.scripting@25
> java.xml@25
> javafx.base@26-internal
> javafx.controls@26-internal
> javafx.fxml@26-internal
> javafx.graphics@26-internal
> jdk.localedata@25
> jdk.unsupported@25
> 
> 
> -------------------------------------
> 
> `This PR`
> 
> `57.266.538 Bytes`
> 
> 
> myapp
> java.base@25
> java.scripting@25
> java.xml@25
> javafx.base@26-internal
> javafx.controls@26-internal
> javafx.fxml@26-internal
> javafx.graphics@26-internal
> jdk.localedata@25
> jdk.unsupported@25
> 
> 
> ---
> 
> `This PR` + https://github.com/openjdk/jfx/pull/1957
> 
> `57.249.459 Bytes`
> 
> 
> myapp
> java.base@25
> java.scripting@25
> java.xml@25
> javafx.base@26-internal
> javafx.controls@26-internal
> javafx.fxml@26-internal
> javafx.graphics@26-internal
> jdk.localedata@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).

Changes requested by kcr (Lead).

modules/javafx.graphics/src/main/java/module-info.java line 43:

> 41:  */
> 42: module javafx.graphics {
> 43:     requires java.desktop;

As commented on in general comments, this is an incompatible change. A general 
discussion on the mailing list is needed to determine whether we want to 
consider this.

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

PR Review: https://git.openjdk.org/jfx/pull/1958#pullrequestreview-3413029573
PR Review Comment: https://git.openjdk.org/jfx/pull/1958#discussion_r2487927810

Reply via email to