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/.
tvaughan 2021-01-30T01:13:50.074100Z

Not sure if anyone is interested in yet another example of how to compile a native image, but if so https://gitlab.com/tvaughan/kibit-runner#native-image. Only docker is required. For anyone looking to reproduce this without docker, Clojure 1.10.2 is required and for some reason this needs to be specified in deps.edn. A recent version of depstar is also required.

👀 1
1
lread 2021-01-30T18:50:09.082300Z

Just upgraded rewrite-clj v1 branch tests to use Graal v21.0.0. One more datapoint, @borkdude, for the https://github.com/borkdude/clj-reflector-graal-java11-fix not being needed!

lread 2021-01-30T18:52:46.084300Z

For my Graal sci test under JDK11, I did still need to include borkdude/sci.impl.reflector. Did not dig in at all, did you expect this still to be needed @borkdude?

borkdude 2021-01-30T19:04:22.084700Z

yes, this lib is needed, but already pulled in by sci itself?

ericdallo 2021-01-30T19:20:08.085200Z

probably yes, since I removed from clojure-lsp and still works

lread 2021-01-30T19:45:52.085900Z

Oh sorry, I meant the 0.0.1-java11 override version of borkdude/sci.impl.reflector for JDK11.

borkdude 2021-01-30T19:48:38.086300Z

Right, that one isn't needed anymore, since it has the same MethodHandle code

lread 2021-01-30T19:53:29.086800Z

Cool, thanks, I’ll retry without it.

lread 2021-01-30T22:18:33.092800Z

If I retry my rewrite-clj sci tests without overriding borkdude/sci.impl.reflector to 0.0.1-java11, native-image compile works fine, but when I interpret my tests I get java.lang.NoSuchMethodError: java.lang.reflect.AccessibleObject.canAccess exceptions. I’ll create a todo for myself to look at this sometime later.

borkdude 2021-01-30T22:19:18.093300Z

@lee I have encountered this error as well. Adding this method to the reflection config did the trick for me

borkdude 2021-01-30T22:19:48.093600Z

See comment here: https://github.com/seancorfield/next-jdbc/issues/157#issuecomment-770192263

lread 2021-01-30T22:21:02.094600Z

Huh, I thought I had tried that! Worth another shot, thanks!

borkdude 2021-01-30T22:21:09.094800Z

@lee I think this is because the method is looked up using reflection: https://github.com/clojure/clojure/blob/140ed11e905de46331de705e955c50c0ef79095b/src/jvm/clojure/lang/Reflector.java#L38

borkdude 2021-01-30T22:21:22.095100Z

(or something)

borkdude 2021-01-30T22:21:42.095400Z

so basically it's missed by the analysis and you have to help it a little bit

borkdude 2021-01-30T22:22:52.095800Z

This might become a very common config for projects that hit this path, so probably worth documenting

borkdude 2021-01-30T22:23:31.096300Z

[{"name": "java.lang.reflect.AccessibleObject",
  "methods" : [{"name":"canAccess"}]},
 ...

lread 2021-01-30T22:24:05.096600Z

Ya, I’ll add a note to clj-graal-docs.

borkdude 2021-01-30T22:29:52.097200Z

I think I'll copy your note to the reflector graal-fix repo then as well, since if you ran into that one, you'll probably now need this

lread 2021-01-30T22:32:53.097400Z

ah, good idea!

lread 2021-01-30T22:35:20.099800Z

Note that I did not need it when 1) compiling rewrite-clj and its tests, only when 2) compiling rewrite-clj for sci tests. But I don’t use a reflection.json for 1, so maybe that’s the diff.

borkdude 2021-01-30T22:36:00.100400Z

yeah, sci uses this Reflector class to do interop

borkdude 2021-01-30T22:36:06.100700Z

so that makes sense

lread 2021-01-30T22:36:14.100900Z

Ah, right.

lread 2021-01-30T22:37:20.102100Z

reflection.json fix you shared above works for rewrite-clj sci tests, thanks!

borkdude 2021-01-30T22:38:17.102300Z

🎉

lread 2021-01-30T22:39:53.103100Z

oh poo, I guess I’ll need to generate a different reflection.json for jdk8 than I do for jdk11.

borkdude 2021-01-30T22:40:28.103600Z

in babashka I generate these using a script

borkdude 2021-01-30T22:40:46.104200Z

different feature flags also need different reflection configs there

lread 2021-01-30T22:40:48.104300Z

yeah, I stole that at one point, maybe I just need to grab an update!

lread 2021-01-30T22:41:39.105Z

ok, good stuff, should not tax my wee brain too much! :simple_smile:

borkdude 2021-01-30T22:43:22.105500Z

there is only so much manual JSON or YAML my brain can handle before I switch to a clojure script

😂 2