graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
Ashwin Bhaskar 2020-09-08T05:57:34.015800Z

i am trying to make https://github.com/ashwinbhaskar/aerospike-migration command line application graalvm compatible. I am able to generate the native image with if I give --report-unsupported-elements-at-runtime parameter. But when I try to run the native image, I get this error

Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
	at clojure.lang.RT.load(RT.java:466)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.lang.RT.doInit(RT.java:471)
	at clojure.lang.RT.<clinit>(RT.java:338)
	at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
	at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
Has anyone faced such an error?

Ashwin Bhaskar 2020-09-08T08:35:28.017900Z

doesn’t the presence of :gen-class generate the main class ahead of time?

Ashwin Bhaskar 2020-09-08T09:51:24.018100Z

@smith.adriane did you mean adding :aot :all to project.clj? I tried this. Still get the same error

borkdude 2020-09-08T11:59:53.018300Z

@ashwinbhskr Check the contents of you uberjar

borkdude 2020-09-08T12:00:08.018500Z

with jar -tf the-uberjar.jar

Ashwin Bhaskar 2020-09-08T12:03:10.018700Z

@borkdude I did that. I am able to see clojure/core__init.class in output

borkdude 2020-09-08T12:03:47.018900Z

What is your native-image invocation?

borkdude 2020-09-08T12:06:22.019100Z

I think it would be easier if you made a repro repo on Github

Ashwin Bhaskar 2020-09-08T12:14:09.019300Z

@borkdude sure, pushed all my changes to the repo. To reproduce. 1. Clone the repo and run make create-jar 2. A jar with name aerospike-migration.jar will be created. 3. Copy the jar to the Graalvm bin directory. 4. Run ./native-image --report-unsupported-elements-at-runtime -jar aerospike-migration.jar -H:Name=aerospike-migration --no-fallback -H:+ReportExceptionStackTraces 5. A native image with the name aerospike-migration will be generated. 6. Just run ./aerospike-migration --help You should see the error that I am getting

borkdude 2020-09-08T12:15:08.019500Z

@ashwinbhskr Try adding --initialize-at-build-time, see https://github.com/lread/clj-graal-docs/blob/master/doc/hello-world.md

Ashwin Bhaskar 2020-09-08T12:19:10.020Z

@borkdude using --initialize-at-build-time gives this exception while generating the native iamge

Call path from entry point to clojure.core.server$io_prepl$fn__8940.invoke(Object):
	at clojure.core.server$io_prepl$fn__8940.invoke(server.clj:284)
	at clojure.tools.logging.proxy$java.io.ByteArrayOutputStream$ff19274a.flush(Unknown Source)
	at java.io.PrintStream.flush(PrintStream.java:338)
	at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:772)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(generated:0)
Original exception that caused the problem: org.graalvm.compiler.core.common.PermanentBailoutException: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [1,2,41,_,_,_,_] stack: [44] locks: [] rethrowException]
Other frame state: [locals: [1,2,41,_,_,_,_] stack: [74] locks: [51 / 42] rethrowException]
Parser context: clojure.core.server$io_prepl$fn__8940.invoke(server.clj:287) [bci: 84, intrinsic: false]

borkdude 2020-09-08T12:19:31.020200Z

Use clojure 1.10.2-alpha1, also see the linked repo

Ashwin Bhaskar 2020-09-08T12:19:59.020400Z

okay, will do

Ashwin Bhaskar 2020-09-08T14:05:16.020700Z

@borkdude Tried out as given in the linked repo and shifting to clojure 1.10.2-alpha1. Now it gives the error:

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Class initialization of org.postgresql.sspi.SSPIClient failed. Use the option --initialize-at-run-time=org.postgresql.sspi.SSPIClient to explicitly request delayed initialization of this class.
Detailed message:

Ashwin Bhaskar 2020-09-08T14:05:31.020900Z

Is the postgresql jdbc driver not graal compatible?

borkdude 2020-09-08T14:08:30.021200Z

It is, but you need an additional setting.

borkdude 2020-09-08T14:09:03.021400Z

Here's an example: https://github.com/BrunoBonacci/graalvm-clojure/blob/master/next-jdbc/project.clj

Ashwin Bhaskar 2020-09-09T00:15:44.021900Z

Yes, using the additional setting made it work. But it complained that there no method that takes 1 argument for class CompletableFuture

Ashwin Bhaskar 2020-09-09T00:16:33.022100Z

Adding type hint solved the problem. Now I am able to execute the native image fine. Thanks a lot @borkdude!

phronmophobic 2020-09-08T06:24:48.017500Z

looking at the project.clj, it doesn’t look like you’re AOTing your uberjar