Fork me on GitHub
#graalvm
<
2021-06-04
>
rickmoynihan15:06:54

Does anyone know why the graal agent that can discover how to make reflective calls, always generates loads of spurious config that causes warnings like this when compiling the native-image: WARNING: Could not resolve me.raynes.fs$eval2576 for reflection configuration. Reason: java.lang.ClassNotFoundException: me.raynes.fs$eval2576.

borkdude15:06:55

@rickmoynihan The agent gets triggered with a lot of false positives I think because the Clojure compiler uses reflection to look up things for compilation

borkdude15:06:15

And the numbering scheme for functions, etc isn't stable over multiple compilations

rickmoynihan15:06:15

ah ok that makes some sense; I figured it was something like that as a lot of the class names look to essentially be evaluations of defs at the top-level

borkdude15:06:27

If you blindly follow what the agent generates, you will (probably) end up with lots of garbage inside your image

rickmoynihan15:06:21

yeah, I’ve culled everything that gives me a warning; but I suspect there’s a huge amount more I could remove. Not sure where to start with that though

borkdude15:06:06

I usually start with nothing and add only what is needed after testing

borkdude15:06:25

the output of the agent I only use as inspiration if I have trouble finding out what's wrong

rickmoynihan16:06:04

Yeah I think that’s ultimately a better direction; though at least going the other direction I can get something working quickly 🙂

rickmoynihan16:06:38

I’m guessing it can make a pretty huge difference to image size?

borkdude16:06:36

Perhaps, just try

borkdude16:06:54

I usually start with ensuring *warn-on-reflection* is enabled

rickmoynihan16:06:11

yeah doing that already — I have a lot of transitive deps though

borkdude16:06:01

I wonder how you can set it globally...

$ clj -M -e "(alter-var-root #'*warn-on-reflection* (constantly true))" -e '(fn [x] (.length x))'
true
#object[user$eval138$fn__139 0x7c2327fa "user$eval138$fn__139@7c2327fa"]
That doesn't seem to work...

Alex Miller (Clojure team)16:06:05

I don't think there actually is a way

borkdude16:06:57

somehow leiningen pulls it of, but maybe using some hack

Alex Miller (Clojure team)16:06:02

lein is binding around the process iirc

Alex Miller (Clojure team)16:06:59

there really should be a way to do it