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.
@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
And the numbering scheme for functions, etc isn't stable over multiple compilations
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
If you blindly follow what the agent generates, you will (probably) end up with lots of garbage inside your image
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
I usually start with nothing and add only what is needed after testing
the output of the agent I only use as inspiration if I have trouble finding out what's wrong
Yeah I think that’s ultimately a better direction; though at least going the other direction I can get something working quickly 🙂
I’m guessing it can make a pretty huge difference to image size?
Perhaps, just try
I usually start with ensuring *warn-on-reflection*
is enabled
yeah doing that already — I have a lot of transitive deps though
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...I don't think there actually is a way
somehow leiningen pulls it of, but maybe using some hack
lein is binding around the process iirc
there really should be a way to do it