|
| 1 | +--- |
| 2 | +title: "JavaFX 24 Highlights" |
| 3 | +section: "highlights" |
| 4 | +styleclass: "content" |
| 5 | +--- |
| 6 | +# JavaFX 24 Highlights |
| 7 | + |
| 8 | +JavaFX version 24 has been released. We've tailored down some of the most exciting parts of the release in this document. |
| 9 | + |
| 10 | +## Important Changes |
| 11 | + |
| 12 | +### JavaFX 24 Requires JDK 22 or Later |
| 13 | + |
| 14 | +JavaFX 24 is compiled with `--release 22` and thus requires JDK 22 or later in order to run. If you attempt to run with an older JDK, the Java launcher will exit with an error message indicating that the `javafx.base` module cannot be read. |
| 15 | + |
| 16 | +See [JDK-8340003](https://bugs.openjdk.org/browse/JDK-8340003) for more information. |
| 17 | + |
| 18 | +### JavaFX Applications Must Use `--enable-native-access` |
| 19 | + |
| 20 | +Running a JavaFX application on JDK 24 will produce a warning from each of the three JavaFX modules that rely on native access, due to the changes specified in [JEP 472](https://openjdk.org/jeps/472). Each warning will include the following message: |
| 21 | + |
| 22 | +``` |
| 23 | +WARNING: Restricted methods will be blocked in a future release unless native access is enabled |
| 24 | +``` |
| 25 | + |
| 26 | +In order to suppress the warning now, and to be able to run your application at all in a subsequent version of the JDK, you need to explicitly enable native access for all modules that need it. This is done by passing `--enable-native-access=<list-of-modules>` to `java` on the command line, listing the modules that you grant native access. This list of modules includes `javafx.graphics` and, optionally, `javafx.media` and `javafx.web`, if your application uses those modules. |
| 27 | + |
| 28 | +For example: |
| 29 | + |
| 30 | +``` |
| 31 | +java --enable-native-access=javafx.graphics,javafx.media,javafx.web |
| 32 | +``` |
| 33 | + |
| 34 | +See [JDK-8347744](https://bugs.openjdk.org/browse/JDK-8347744) for more information. |
| 35 | + |
| 36 | +### The `jdk.jsobject` Module is Now Included with JavaFX |
| 37 | + |
| 38 | +The `jdk.jsobject` module, which is used by JavaFX WebView applications, is now included with JavaFX, replacing the JDK module of the same name. The `jdk.jsobject` module is deprecated as of JDK 24, and will be removed in a future release of the JDK. |
| 39 | + |
| 40 | +To facilitate the transition, `jdk.jsobject` is now an upgradable module in the JDK. This means that the version of `jdk.jsobject` delivered with JavaFX can be used in place of the one in the JDK to avoid the compiler warning. This can be done as follows: |
| 41 | + |
| 42 | +Go through [JavaFX 24 release notes](https://github.com/openjdk/jfx/blob/jfx24/doc-files/release-notes-24.md) or [JDK-8337280](https://bugs.openjdk.org/browse/JDK-8337280) for more information. |
| 43 | + |
| 44 | +### Pluggable Image Loading via `javax.imageio` |
| 45 | + |
| 46 | +JavaFX 24 supports the Java Image I/O API, allowing applications to use third-party image loaders in addition to the built-in image loaders. |
| 47 | +This includes the ability to use variable-density image loaders for formats like SVG. When an image is loaded using a variable-density image loader, JavaFX rasterizes the image with the screen's DPI scaling. |
| 48 | + |
| 49 | +Applications that want to use this feature can use existing open-source Image I/O extension libraries, or register a custom Image I/O service provider instance with the `IIORegistry` class. |
| 50 | +Refer to the Java [Image I/O documentation](https://docs.oracle.com/en/java/javase/23/docs/api/java.desktop/javax/imageio/package-summary.html) for more information. |
| 51 | + |
| 52 | +See [JDK-8306707](https://bugs.openjdk.org/browse/JDK-8306707) for more information. |
| 53 | + |
| 54 | +### `ScrollPane` Consumes Navigation Keys Only When It Has Direct Focus |
| 55 | + |
| 56 | +`ScrollPane` now only responds to key events when it is the active focus owner. This ensures that custom controls and other UI elements work correctly inside a `ScrollPane`, providing a more consistent and intuitive navigation experience. |
| 57 | + |
| 58 | +Applications that prefer the previous behavior, where `ScrollPane` always reacts to arrow keys and other navigational inputs, can manually restore it by adding an event handler. See [this note](https://github.com/openjdk/jfx/blob/jfx24/doc-files/notes/24/JDK-8340852-ScrollPane.md) for an example of how to do this. |
| 59 | + |
| 60 | +See [JDK-8340852](https://bugs.openjdk.org/browse/JDK-8340852) for more information. |
| 61 | + |
| 62 | +## Removed Features and Options |
| 63 | + |
| 64 | +### JavaFX No Longer Supports Running With a Security Manager |
| 65 | + |
| 66 | +The Java Security Manager has been permanently disabled in JDK 24 via [JEP 486](https://openjdk.org/jeps/486). |
| 67 | + |
| 68 | +Likewise, as of JavaFX 24, it is no longer possible to run JavaFX applications with a security manager enabled. This is true even if you run your application on an older JDK that still supports the security manager. |
| 69 | + |
| 70 | +The following exception will be thrown when the JavaFX runtime is initialized with the Security Manager enabled: |
| 71 | + |
| 72 | +> NOTE: UnsupportedOperationException: JavaFX does not support running with the Security Manager |
| 73 | +
|
| 74 | +See [JDK-8341090](https://bugs.openjdk.org/browse/JDK-8341090) for more information. |
| 75 | + |
| 76 | +## Known Issues |
| 77 | + |
| 78 | +### JavaFX Warning Printed for Use of Terminally Deprecated Methods in `sun.misc.Unsafe` |
| 79 | + |
| 80 | +Running a JavaFX application on JDK 24 will produce a warning the first time any UI Control or complex shape is rendered: |
| 81 | + |
| 82 | +``` |
| 83 | +WARNING: A terminally deprecated method in sun.misc.Unsafe has been called |
| 84 | +... |
| 85 | +WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release |
| 86 | +``` |
| 87 | + |
| 88 | +To disable this warning, pass `--sun-misc-unsafe-memory-access=allow` to `java` on the command line. For example: |
| 89 | + |
| 90 | +``` |
| 91 | +java --sun-misc-unsafe-memory-access=allow |
| 92 | +``` |
| 93 | + |
| 94 | +This will be fixed in a subsequent version of JavaFX, after which time this flag will no longer be needed. |
| 95 | + |
| 96 | +See [JDK-8345121](https://bugs.openjdk.org/browse/JDK-8345121) for more information. |
| 97 | + |
| 98 | +Exciting features: |
| 99 | +- New APIs: |
| 100 | + - InputMap is now public API as an Incubator |
| 101 | + - Focus traversal API is now public for use in custom controls |
| 102 | + |
| 103 | +- New Features: |
| 104 | + - A new RichTextArea Control is now in Incubator |
| 105 | + - Support "@1x" image naming convention as fallback |
| 106 | + - Support pluggable image loading via javax.imageio |
| 107 | + |
| 108 | +Improvements: |
| 109 | +- Tree-structural pseudo-classes are now supported in JavaFX CSS |
| 110 | + |
| 111 | +The community came together to fix 57 bugs in the last 6 months. Following are major bug-fixes that went into JavaFX 24: |
| 112 | + |
| 113 | +- Fix for application window not always activated on macOS 15 |
| 114 | +- Fix for css transition not started when initial value was not specified |
| 115 | +- Fix for infinite loop occurs while resolving lookups |
| 116 | +- Fix for IOOBE when adding data to a Series of a BarChart that already contains data |
| 117 | + |
| 118 | +Finally, these are some dependency upgrades in JavaFX 24: |
| 119 | +- Update libFFI to 3.4.6 |
| 120 | +- Update Glib to 2.82.4 |
| 121 | +- Update GStreamer to 1.24.10 |
| 122 | +- Update WebKit to 619.1 |
| 123 | +- Update libxslt to 1.1.42 |
| 124 | + |
| 125 | +A more comprehensive list of all the changes in JavaFX 24 can be found on [Github](https://github.com/openjdk/jfx/blob/jfx24/doc-files/release-notes-24.md). |
| 126 | + |
| 127 | +Kudos go to the fine people at [Gluon](https://gluonhq.com) who took care of the bulk of the work on JavaFX 24. Do check their [JavaFX Long Term Support](https://gluonhq.com/services/javafx-support/) services. |
0 commit comments