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/.
2021-03-10T12:28:48.131500Z

Hi, i wonder how i can include a file (xsd) the native-image ? I did try -H:IncludeResources='.*/Resource.*txt$ and then try to use (io/resource "Resource.txt") but it doesn't work

ericdallo 2021-03-10T12:31:35.131600Z

I needed to included a resource file on clojure-lsp called CLOJURE_LSP_VERSION and this way works: https://github.com/clojure-lsp/clojure-lsp/blob/master/resources/META-INF/native-image/clojure-lsp/clojure-lsp/native-image.properties#L8

borkdude 2021-03-10T12:32:20.132500Z

Note that the resource pattern must be relative to your classpath, not your working dir

2021-03-10T12:37:44.132600Z

Wow many thanks ! and you can then use it with io/resource ?

borkdude 2021-03-10T12:38:03.132800Z

yes

2021-03-10T12:40:08.133Z

Ok many thanks can't make it work and i have almost the samle structure. I'll see with you compilation parameters if i miss something

borkdude 2021-03-10T12:40:48.133200Z

Is that dir even on your classpath? Are you able to get it in on the JVM?

2021-03-10T12:46:03.133400Z

It is ok now i found my error ... Many thanks to you both, for the quick help and for the faboulous tools you bring to clojure !!!!

2021-03-10T13:25:13.134400Z

Also i have this code that work with lein run but not once compiled as native-image (InputSource. (http://clojure.java.io/input-stream (.getBytes data)))

2021-03-10T13:27:28.134500Z

** ERROR: **
Exception: #error {
 :cause No matching field found: getBytes for class java.lang.String
 :via
 [{:type java.lang.IllegalArgumentException
   :message No matching field found: getBytes for class java.lang.String
   :at [clojure.lang.Reflector getInstanceField Reflector.java 397]}]
 :trace
 [[clojure.lang.Reflector getInstanceField Reflector.java 397]
  [clojure.lang.Reflector invokeNoArgInstanceMember Reflector.java 440]
  [sm_validator_cli.core$create_xml_doc invokeStatic core.clj 43]

borkdude 2021-03-10T13:41:04.134700Z

@ouvasam You need to avoid reflection warnings with (set! *warn-on-reflection* true)

2021-03-10T13:45:39.134900Z

Thanks but this does not work too

2021-03-10T13:56:53.135100Z

Typehint seems to work for this part (InputSource. (http://clojure.java.io/input-stream (.getBytes ^java.lang.String data)))

2021-03-10T13:57:15.135300Z

now i have

(InputSource. (<http://clojure.java.io/input-stream|clojure.java.io/input-stream> (.getBytes data))) ** ERROR: **
Exception: #error {
 :cause org.apache.xerces.parsers.ObjectFactory
 :via
 [{:type java.lang.NoClassDefFoundError
   :message nil
   :at [org.apache.xerces.parsers.ObjectFactory class$ nil -1]}
  {:type java.lang.ClassNotFoundException
   :message org.apache.xerces.parsers.ObjectFactory
   :at [com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]}]
 :trace
 [[com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]

2021-03-10T13:57:20.135500Z

😭