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/.
borkdude 2020-02-26T15:46:03.044Z

:bananadance:

16
👀 2
alexmiller 2020-02-26T15:49:38.044600Z

feel the tingle in the air?

✔️ 6
2020-02-26T18:24:23.047700Z

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
  [&amp; args]
  (let [[user host keyname &amp; other] args
        ssh (JSch.)
        port 22]
    (let [sess (.getSession ssh user host port)]
      (.setPortForwardingL sess 8842 "localhost" 8888)
      (.connect sess))))

borkdude 2020-02-26T18:41:26.048200Z

@romantsopin which graalvm version are you using?

borkdude 2020-02-26T18:42:32.048600Z

@romantsopin I think this project might be using JSch: https://github.com/epiccastle/spire - maybe you can look at that

2020-02-26T18:43:50.049100Z

GraalVM CE 20.0.0

borkdude 2020-02-26T18:44:05.049600Z

which java version, 8 or 11?

2020-02-26T18:45:16.050500Z

it's 13. This may cause problems?

borkdude 2020-02-26T18:45:40.050800Z

13 is not a java version that graal supports, it's either 8 or 11

borkdude 2020-02-26T18:45:58.051100Z

anyway, try with 19.3.1-java8

2020-02-26T18:46:17.051500Z

Will do, thank you!

borkdude 2020-02-26T18:46:41.052100Z

also, take care that you don't get reflection, so put *warn-on-reflection* to true

2020-02-26T18:48:01.052800Z

I took option --initialize-at-run-time=com.jcraft.jsch.PortWatcher from epiccastle/spire and seems like it's working

2020-02-26T18:48:18.053300Z

this is awesome, thanks @borkdude!

👍 1
2020-02-26T18:50:10.054700Z

Also maybe you have a good reference which explains all this flags in detail and how do exactly they work?

borkdude 2020-02-26T18:50:37.055100Z

we have some docs here: https://github.com/lread/clj-graal-docs welcome to contribute if you have anything to add!

👍 1
zilti 2020-02-26T20:20:20.055900Z

borkdude, any reason why java8 instead of java11?

borkdude 2020-02-26T20:22:39.056900Z

@zilti I've had some issues with jdk11, so in case of problems it's good to see if java8 behaves differently