gluonhq / gluonfx-gradle-plugin

Plugin that simplifies using Gluon Client for Java/JavaFX gradle projects
BSD 3-Clause "New" or "Revised" License
99 stars 20 forks source link

Preferences API not supported #48

Open dlemmermann opened 4 years ago

dlemmermann commented 4 years ago

Just noticed this error when my app tried to use the java.util preferences API. So I think this is not supported, yet.

Omega :: host triplet = x86_64-macos-macos Omega :: target triplet = x86_64-macos-macos [Tue Sep 24 14:24:18 CEST 2019][INFO] [SUB] ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] Undefined symbols for architecture x86_64: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] "_Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode", referenced from: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] _svm_cglobaldata_base in FlexGanttFXMobile.o [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] "_Java_java_util_prefs_MacOSXPreferencesFileaddKeyToNode", referenced from: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] svm_cglobaldata_base in FlexGanttFXMobile.o [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] "_Java_java_util_prefs_MacOSXPreferencesFile_addNode", referenced from: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] _svm_version_info in FlexGanttFXMobile.o [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] "_Java_java_util_prefs_MacOSXPreferencesFilegetKeyFromNode", referenced from: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] svm_cglobaldata_base in FlexGanttFXMobile.o [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] "_Java_java_util_prefs_MacOSXPreferencesFile_synchronize", referenced from: [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] ___svm_version_info in FlexGanttFXMobile.o [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] ld: symbol(s) not found for architecture x86_64 [Tue Sep 24 14:24:19 CEST 2019][INFO] [SUB] clang: error: linker command failed with exit code 1 (use -v to see invocation) java.lang.RuntimeException: Error linking at com.gluonhq.omega.target.MacosTargetProcess.link(MacosTargetProcess.java:501) at com.gluonhq.omega.Omega.nativeLink(Omega.java:86) at com.gluonhq.NativeLinkMojo.execute(NativeLinkMojo.java:54) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:192) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

mipastgt commented 4 years ago

This looks very similar to my previous report: https://github.com/gluonhq/client-maven-plugin/issues/45 Maybe it is related.

xzel23 commented 4 years ago

I have also opened an issue in graal for this. https://github.com/oracle/graal/issues/2051

xzel23 commented 4 years ago

@dlemmermann Have you found a workaround?

So far, I have found out that the concrete classes seem to be there. But the missing methods are declared native, thus not included in the jar/class files. If you look at the command issued in the client:link phase, you can see that all the static JDK libs from ~/.gluon/omega/javaStaticSdk/$javaStaticSdkVersion/$target-libs-$javaStaticSdkVersio are passed to the linker - with the exception of -lprefs. If I add -lprefs manually just before -ljvm the message about _Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode etc are gone. But now _JVM_ArrayCopy is missing.

I will dig some further and report back if I find a workaround.

@johanvos How can I tell the plugin to also link against libprefs.o in the config section of pom.xml?

mipastgt commented 4 years ago

@xzel23 I don't know whether this is relevant for this issue but the client-gradle-plugin has not been updated for quite a while now. Active development seems to happen only for the client-maven-plugin. Have you tried that?

xzel23 commented 4 years ago

@mipastgt I have the same issue with the maven plugin.

johanvos commented 4 years ago

Right, we currently don't link the libprefs.a library with Gluon Substrate. I created an issue for this at https://github.com/gluonhq/substrate/issues/237 and it should be fixed shortly. There is an undocumented way to add native libraries in any of the jars that are part of your project, where those libraries will then be used by the linker, but for the libprefs.a (note we use static libs) this should go in by default (or at least when the Java Preference API is detected to be used).

xzel23 commented 4 years ago

@johanvos that's great news. In the meantime, I have cloned and patched both substrate and the maven plugin. The errors about_Java_java_util_prefs_MacOSXPreferences* are all gone, but I now get the following error, so it seems something more has to be done:

Linking failed. Details from linking below:
Command was: gcc /Users/axel/Development/app/editor/target/client/x86_64-darwin/gvm/editor/AppDelegate.o /Users/axel/Development/app/editor/target/client/x86_64-darwin/gvm/editor/launcher.o /Users/axel/Development/app/editor/target/client/x86_64-darwin/gvm/tmp/SVM-1578165342392/editor.editor.o -ljava -lnio -lzip -lnet -lprefs -ljvm -lstrictmath -lz -ldl -lj2pkcs11 -lsunec -lextnet -lstdc++ -Wl,-force_load,/Users/axel/.gluon/substrate/javafxStaticSdk/14-ea+gvm4/darwin-x86_64/sdk/lib/libprism_es2.a -Wl,-force_load,/Users/axel/.gluon/substrate/javafxStaticSdk/14-ea+gvm4/darwin-x86_64/sdk/lib/libglass.a -Wl,-force_load,/Users/axel/.gluon/substrate/javafxStaticSdk/14-ea+gvm4/darwin-x86_64/sdk/lib/libjavafx_font.a -Wl,-force_load,/Users/axel/.gluon/substrate/javafxStaticSdk/14-ea+gvm4/darwin-x86_64/sdk/lib/libjavafx_iio.a -lffi -lpthread -lz -ldl -lstrictmath -llibchelper -ljava -lnio -lzip -lprefs -ljvm -lobjc -Wl,-framework,Foundation -Wl,-framework,AppKit -Wl,-framework,ApplicationServices -Wl,-framework,OpenGL -Wl,-framework,QuartzCore -Wl,-framework,Security -o /Users/axel/Development/app/editor/target/client/x86_64-darwin/editor -L/Users/axel/bin/graalvm/lib/svm/clibraries/darwin-amd64 -L/Users/axel/.gluon/substrate/javaStaticSdk/14-ea+5/darwin-x86_64/labs-staticjdk/lib/static -L/Users/axel/.gluon/substrate/javafxStaticSdk/14-ea+gvm4/darwin-x86_64/sdk/lib -L/Users/axel/Development/app/editor/target/client/x86_64-darwin/gvm/lib
Undefined symbols for architecture x86_64:
  "_JVM_ArrayCopy", referenced from:
      _getStringsForNode in libprefs.a(MacOSXPreferencesFile.o)
ld: symbol(s) not found for architecture x86_64

I can see that _JVM_ArrayCopy is referenced from both libjava.a and libprefs.a, but I have no idea where it is defined. There also doesn't seem to be a definition in the libraries under $GRAALVM_HOME/lib.