On Tue, 15 Oct 2024 03:18:09 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
> While implementing [JDK-8339517](https://bugs.openjdk.org/browse/JDK-8339517) > to eliminate native access warnings by passing "--enable-native-access" for > the three JavaFX modules with native code (javafx.graphics, javafx.media, and > javafx.web), it was found that the Swing interop code in javafx.swing calls > a JNI method defined in one of the native graphics libraries (prism-common) > directly > > This means that even after > [JDK-8339517](https://bugs.openjdk.org/browse/JDK-8339517) is fixed, we still > get native access warnings when running any test that uses SwingNode. > > This fixes the native access warning by making javafx.graphics module call > the native JNI and Swing-interop calls the static utility method in > javafx.graphics, in this case defined in PlatformImpl > > All test.javafx.embed.swing SwingNode tests are running ok without any native > warning This is generally good, but I have a suggested change in the class to use for the native method. modules/javafx.graphics/src/main/java/com/sun/javafx/application/PlatformImpl.java line 1071: > 1069: long handle, Runnable > closeWindow) { > 1070: _overrideNativeWindowHandle(lwFrameWrapperClass, frame, handle, > closeWindow); > 1071: } `PlatformImpl` is in a package / subsystem that doesn't have any native methods, and I'd prefer to keep it that way. I recommend moving these methods to glass, probably `com.sun.glass.ui.Application`, since that will be a simple matter to cut / paste the methods from here to there. modules/javafx.graphics/src/main/native-prism/SwingInterop.c line 31: > 29: * Class com_sun_javafx_application_PlatformImpl > 30: * Method: overrideNativeWindowHandle > 31: * Signature > (Ljava/lang/Class;JLjava/lang/Runnable)Ljdk.swing.interop.LightweightFrameWrapper; The signature should be changed to match the actual method. You can copy / paste from the generated header file. Also, I recommend including the generated header file in this file (after the include of `jni.h`) ------------- PR Review: https://git.openjdk.org/jfx/pull/1600#pullrequestreview-2370019002 PR Review Comment: https://git.openjdk.org/jfx/pull/1600#discussion_r1801581385 PR Review Comment: https://git.openjdk.org/jfx/pull/1600#discussion_r1801583717