graalvm 2024-02-16

Hi, after long time I try to graalize a clojure cli project: https://repo.prod.meissa.de/meissa/c4k-forgejo/src/branch/feature/native-build/project.clj Unfortunately I get

Exception in thread "main" java.lang.IllegalArgumentException: No matching method getBytes found taking 1 args for class java.lang.String
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:127)
	at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:102)
For building the uberjar I use openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing) I thought this problem only occurs on old java version .... What am I doing wrong?

you are hitting some reflection issue

is it possible to share more of the stacktrace?

then you could find it out where exactly the reflection is happening and solve it

Exception in thread "main" java.lang.IllegalArgumentException: No matching method getBytes found taking 1 args for class java.lang.String
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:127)
	at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:102)
	at dda.c4k_common.base64$encode.invokeStatic(base64.clj:11)
	at dda.c4k_common.base64$encode.invoke(base64.clj:7)
	at dda.c4k_common.postgres$generate_secret.invokeStatic(postgres.cljc:94)
	at dda.c4k_common.postgres$generate_secret.invoke(postgres.cljc:89)
	at dda.c4k_forgejo.core$k8s_objects.invokeStatic(core.cljc:40)
	at dda.c4k_forgejo.core$k8s_objects.invoke(core.cljc:34)
	at dda.c4k_common.common$generate_common.invokeStatic(common.cljc:68)
	at dda.c4k_common.common$generate_common.invoke(common.cljc:60)
	at dda.c4k_common.uberjar$main_common.invokeStatic(uberjar.clj:50)
	at dda.c4k_common.uberjar$main_common.invoke(uberjar.clj:31)
	at dda.c4k_forgejo.uberjar$_main.invokeStatic(uberjar.clj:8)
	at dda.c4k_forgejo.uberjar$_main.doInvoke(uberjar.clj:7)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at dda.c4k_forgejo.uberjar.main(Unknown Source)
	at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

that 's the full stacktrace ...

No need to send the stacktrace to the channel. In fact, that is the part of this thread I would not send to the channel 😂

👍 1

definitely, add ^String input and this will solve the issue

in doubt, add

(set! *warn-on-reflection* true)
in the file and you'll see whatever reflection issues remain when evaluating the file

Cool ... now it works 🙂

👍 1

thx four your nice help

👍 1