:bananadance:
feel the tingle in the air?
Hi there. I'm trying to compile simple code with lein native-image which is using com.jcraft.jsch.JSch and got following error
Error: No instances of <http://java.net|java.net>.Inet4Address are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use -H:+TraceClassInitialization.
Detailed message:
Trace: Object was reached by
reading field com.jcraft.jsch.PortWatcher.anyLocalAddress
How can I prevent this? I tried --initialize-at-run-time with anyLocalAddress but it didn't help. Maybe someone compiled Jsch before? The code looks like this
(ns binssh.core
(:import (com.jcraft.jsch JSch))
(:gen-class))
(defn -main
[& args]
(let [[user host keyname & other] args
ssh (JSch.)
port 22]
(let [sess (.getSession ssh user host port)]
(.setPortForwardingL sess 8842 "localhost" 8888)
(.connect sess))))
@romantsopin which graalvm version are you using?
@romantsopin I think this project might be using JSch: https://github.com/epiccastle/spire - maybe you can look at that
GraalVM CE 20.0.0
which java version, 8 or 11?
it's 13. This may cause problems?
13 is not a java version that graal supports, it's either 8 or 11
anyway, try with 19.3.1-java8
Will do, thank you!
also, take care that you don't get reflection, so put *warn-on-reflection*
to true
I took option --initialize-at-run-time=com.jcraft.jsch.PortWatcher from epiccastle/spire and seems like it's working
this is awesome, thanks @borkdude!
Also maybe you have a good reference which explains all this flags in detail and how do exactly they work?
we have some docs here: https://github.com/lread/clj-graal-docs welcome to contribute if you have anything to add!
borkdude, any reason why java8 instead of java11?
@zilti I've had some issues with jdk11, so in case of problems it's good to see if java8 behaves differently