javafxgluongluonfx

Gluon build problem - specifies unknown module javafx.graphics


My project was building fine then I wanted to bring dockable window and did https://github.com/ozkanpakdil/DockFX and used it in https://github.com/ozkanpakdil/swaggerific I could not find what made this but my github actions started failing with error below in linux and windows

[Sun Mar 17 22:08:25 UTC 2024][INFO] [SUB] Error: Resource pattern "javafx.graphics:\Qcom/sun/prism/es2/glsl/FillRoundRect_Color.frag\E"s specifies unknown module javafx.graphics
[Sun Mar 17 22:08:25 UTC 2024][INFO] [SUB] com.oracle.svm.core.util.UserError$UserException: Resource pattern "javafx.graphics:\Qcom/sun/prism/es2/glsl/FillRoundRect_Color.frag\E"s specifies unknown module javafx.graphics
[Sun Mar 17 22:08:25 UTC 2024][INFO] [SUB]  at com.oracle.svm.core.util.UserError.abort(UserError.java:72)
[Sun Mar 17 22:08:25 UTC 2024][INFO] [SUB]  at com.oracle.svm.hosted.ResourcesFeature.makeResourcePattern(ResourcesFeature.java:288)
[Sun Mar 17 22:08:25 UTC 2024][INFO] [SUB]  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)

strange thing the build is working in my linux laptop , but having same error in my windows laptop.

One important thing I changed in swaggerific was I deleted module-info.java, because in linux I was having classpath and module problems, after I delete module-info all started working. I tried to put that back in but could not solve so far, any input highly appreciated.

Edit 1: Regular graalvm jdk is compiling the package without problem for linux and windows https://github.com/ozkanpakdil/swaggerific/issues/12

Edit 2: Looks like this is related to reflection jsons https://github.com/gluonhq/gluonfx-maven-plugin/issues/478#issue-1794093498


Solution

  • The Native Image tool relies on the static analysis of an application’s reachable code at runtime. However, the analysis cannot always completely predict all usages of the Java Native Interface (JNI), Java Reflection, Dynamic Proxy objects, or class path resources. Undetected usages of these dynamic features must be provided to the native-image tool in the form of metadata (precomputed in code or as JSON configuration files).

    For that we need to use trace agent and I find out that we need to put reflect jsons for dependency libraries too, So I ran the project with trace agent and generated jsons

    java -agentlib:native-image-agent=config-output-dir=./graalcnf/ -jar target/demodockfx.jar
    

    Use the dockfx features, agent will record the jsons under graalcnf folder than move them to src/main/resources/META-INF/native-image/ like in this [commit](java -agentlib:native-image-agent=config-output-dir=./graalcnf/ -jar target/) redeploy the latest jar to maven repository, now swaggerific build without that error. Do not forget to update resource paths for the library.

    Reference: https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/#tracing-agent