Folks... here's something weird. I'm doing a project to see if I can expose Pathom as a library. So I made this project: https://gitlab.com/mauricioszabo/patao/-/tree/make-a-gem, and tried to compile it on a CI, so that it could generate binaries for Linux, Windows, and maybe Mac. Now... here's the weird part. On Linux, it compiles just fine. On windows, it fails with the following error:
Error: Expected Object but got Word for call argument in big_duck.LibPatao.gen_resolver(LibPatao.java:22). One possible cause for this error is when word values are passed into lambdas as parameters or from variables in an enclosing scope, which is not supported, but can be solved by instead using explicit classes (including anonymous classes).
com.oracle.svm.core.util.UserError$UserException: Expected Object but got Word for call argument in big_duck.LibPatao.gen_resolver(LibPatao.java:22). One possible cause for this error is when word values are passed into lambdas as parameters or from variables in an enclosing scope, which is not supported, but can be solved by instead using explicit classes (including anonymous classes).
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:85)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.checkWordType(SharedGraphBuilderPhase.java:798)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.createMethodCallTarget(SharedGraphBuilderPhase.java:636)
... lots of other stuff here...
LibPatao.java, at line 22, contains exactly this:
Function<String, String> adaptedCallback = (argument) -> {
And it's used to adapt what will be a "C Function Pointer" into a Java one (so that I can pass to Clojure and do the magic). Any idea on what might be wrong?Did that help?
Yes, I basically inherited the Java "Function" class and instead of using a lambda, I created this new class, and that worked. Thanks!
Just checked that it works on Linux, now I really want to be sure that the library also works on Windows, but at least it's generating it correctly 🙂
It's complaining about a Lambda and you are using a lambda there. Is it possible to rewrite it without using a lambda? In other words, create a subclass of Function and use that as your callback (or otherwise create the callback without lambda syntax)?
Maybe.... let me just first understand why GraalVM decided to not export my functions again 😢