graalvm

Dumch 2022-06-16T10:40:51.512669Z

Can't make Dart->Clojure translator work with graalvm, need help 🙏. Seems like I have problems with reflection:

╰$ ./dartclj "Text('1')"
Exception in thread "main" java.lang.IllegalArgumentException: No matching method substring
 found taking 2 args for class java.lang.String
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:127)
        at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:102)
Here is a https://github.com/Liverm0r/DartClojure/blob/main/compile.sh file. I pass a flag -H:ReflectionConfigurationFiles with json, where I ask to remain allMethods, constructors, etc. But it doesn't work.

Dumch 2022-06-16T10:52:32.084269Z

graalvm -v 22.1, java 11

Dumch 2022-06-16T10:56:31.040799Z

I have also found this @borkdude https://github.com/borkdude/clj-reflector-graal-java11-fix and tryied to add

{ 
    "name": "java.lang.reflect.AccessibleObject",
    "methods" : [{"name":"canAccess"}]
  },
— didn't work

borkdude 2022-06-16T10:58:45.247549Z

Read this: https://github.com/clj-easy/graal-docs#reflection

borkdude 2022-06-16T10:59:13.891069Z

Just add the String class in your reflection config file

borkdude 2022-06-16T10:59:24.796009Z

or get rid off your reflection using type hints in Clojure which is even better

borkdude 2022-06-16T11:01:08.891499Z

Put #?(:clj (set! *warn-on-reflection* true)) in the top of this file: https://github.com/Liverm0r/DartClojure/blob/7e1a72e2e046725084439be9eb812903f300c042/src/dumch/parse.cljc#L372

borkdude 2022-06-16T11:01:19.202559Z

and then it will warn you about the reflective .substring usage

borkdude 2022-06-16T11:01:26.101509Z

but you can just use subs there as well btw

Dumch 2022-06-16T12:38:54.944199Z

Thank you!