lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
2021-01-19T00:02:05.027100Z

just wanted to say, I just upgraded from a > 1 year old clojure-lsp to the latest, and it's improved massively!

2021-01-19T00:02:53.028Z

I jumped from a version that didn't understand why the symbols in a Datalog query weren't defined (even though they're quoted) to a version that groks Datalog completely and caught a bug in mine! (typo'd a ?var)

4
ericdallo 2021-01-19T00:38:54.028400Z

Thanks for the feedback :D we are using clj-kondo in the base to analyze the code and do our magic with the result ;)

ericdallo 2021-01-19T00:39:34.028700Z

We are doing a lot of upgrades too, stay 👀

souenzzo 2021-01-19T20:19:22.030Z

GraalVM now has a good LSP for java Not sure if it's useful https://www.graalvm.org/tools/vscode/graalvm-extension/

borkdude 2021-01-20T21:28:32.031400Z

I can help with turning lsp into a binary, but I'm not sure if that will really help anyone, except for startup time

ericdallo 2021-01-20T21:31:10.031600Z

Oh, if you could help with that PR, it'd be awesome @borkdude, me and @thiagokokada are stuck since we don't know GraalVM very well

kokada 2021-01-20T21:43:12.031900Z

Yeah, if someone with more experience with GraalVM could help us it would be awesome

kokada 2021-01-20T21:43:37.032100Z

I mostly copied some things from clj-kondo/babashka and tried to adapt it

kokada 2021-01-20T21:44:06.032300Z

But I really don't understand neither GraalVM nor Java too much so I got stucked afterwards

borkdude 2021-01-20T21:50:17.032500Z

@ericdallo I chose to keep the VSCode LSP plugin as a Java project, since it's a server and Java makes more sense for long running processes imo

ericdallo 2021-01-20T21:54:54.033400Z

I see, well, I think we'll need to check how to make that happens for clojure-lsp that is made in clojure 😕

borkdude 2021-01-20T21:55:18.033600Z

@ericdallo I mean, the JVM. Clojure on the JVM.

borkdude 2021-01-20T21:55:48.033900Z

A JVM is better suited for high throughput due to JIT

borkdude 2021-01-20T21:56:12.034100Z

A graalvm image is better suited for doing short-lived things

borkdude 2021-01-20T21:56:36.034400Z

But if you have other reasons to make a native image, and you can point me to an issue, I can give some hints probably

ericdallo 2021-01-20T22:02:53.036300Z

I see, clojure-lsp uses the https://github.com/BrunoBonacci/lein-binplus to build a binary with the jar bundled but user still needs java installed, so do you think for clojure-lsp keeps as a JVM would fit better than a Graalvm native image?

borkdude 2021-01-20T22:05:45.039400Z

Ah I see. The way I do this for IntelliJ LSP for example for clj-kondo is just distribute an uberjar

borkdude 2021-01-20T22:06:27.039600Z

The reason I did this, is also that the user didn't have to install anything else when using VSCode

borkdude 2021-01-20T22:06:33.039800Z

No external binaries

ericdallo 2021-01-20T22:06:43.040Z

We also distrubute the jar in the Releases if user don't want to use the binary, for example Calva folks use the jar instead of the binary

ericdallo 2021-01-20T22:07:10.040200Z

Yes, I super like that, that's another reason we thought about using GraalVM

borkdude 2021-01-20T22:07:41.040500Z

And other editor which use the binary version of clj-kondo usually don't use the LSP, so there the binary makes sense to me. But if you want to make it all native, sure we can do that, if all your deps cooperate. I'm not sure which deps you are using. Maybe you can do lein deps :tree or clj -Stree ?

ericdallo 2021-01-20T22:08:30.040700Z

[clj-kondo "2020.12.13-20210119.112957-43"]
   [borkdude/sci "0.2.1"]
     [borkdude/edamame "0.0.11-alpha.28"]
     [borkdude/sci.impl.reflector "0.0.1"]
   [cheshire "5.10.0"]
     [com.fasterxml.jackson.core/jackson-core "2.10.2"]
     [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.10.2"]
     [com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.10.2"]
     [tigris "0.1.2"]
   [com.cognitect/transit-clj "1.0.324"]
     [com.cognitect/transit-java "1.0.343"]
       [commons-codec "1.10"]
       [javax.xml.bind/jaxb-api "2.3.0"]
       [org.msgpack/msgpack "0.6.12"]
         [com.googlecode.json-simple/json-simple "1.1.1" :exclusions [[junit]]]
         [org.javassist/javassist "3.18.1-GA"]
   [io.lambdaforge/datalog-parser "0.1.7"]
   [nrepl/bencode "1.1.0"]
 [cljfmt "0.7.0" :exclusions [[rewrite-cljs]]]
   [com.googlecode.java-diff-utils/diffutils "1.3.0"]
   [org.clojure/tools.cli "1.0.194"]
   [rewrite-clj "0.6.1"]
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [com.google.guava/guava "30.1-jre"]
   [com.google.code.findbugs/jsr305 "3.0.2"]
   [com.google.errorprone/error_prone_annotations "2.3.4"]
   [com.google.guava/failureaccess "1.0.1"]
   [com.google.guava/listenablefuture "9999.0-empty-to-avoid-conflict-with-guava"]
   [com.google.j2objc/j2objc-annotations "1.3"]
   [org.checkerframework/checker-qual "3.5.0"]
 [com.taoensso/tufte "2.2.0"]
   [com.taoensso/encore "3.1.0"]
     [com.taoensso/truss "1.6.0"]
 [digest "1.4.10"]
 [log4j "1.2.17" :exclusions [[javax.mail/mail] [javax.jms/jms] [com.sun.jdmk/jmxtools] [com.sun.jmx/jmxri]]]
 [medley "1.3.0"]
 [nrepl "0.8.3"]
 [org.clojure/clojure "1.10.1"]
   [org.clojure/core.specs.alpha "0.2.44"]
   [org.clojure/spec.alpha "0.2.176"]
 [org.clojure/core.async "1.3.610"]
   [org.clojure/tools.analyzer.jvm "1.1.0"]
     [org.clojure/core.memoize "1.0.236"]
       [org.clojure/core.cache "1.0.207"]
         [org.clojure/data.priority-map "1.0.0"]
     [org.clojure/tools.analyzer "1.0.0"]
     [org.ow2.asm/asm "5.2"]
 [org.clojure/data.json "1.0.0"]
 [org.clojure/tools.logging "1.1.0"]
 [org.clojure/tools.reader "1.3.4"]
 [org.eclipse.lsp4j "0.10.0" :exclusions [[org.eclipse.xtend/org.eclipse.xtend.lib]]]
   [org.eclipse.lsp4j/org.eclipse.lsp4j.generator "0.10.0"]
   [org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc "0.10.0"]
     [com.google.code.gson/gson "2.8.2"]
 [org.eclipse.xtend/org.eclipse.xtend.lib "2.25.0.M1" :exclusions [[com.google.guava/guava]]]
   [org.eclipse.xtend/org.eclipse.xtend.lib.macro "2.25.0.M1"]
   [org.eclipse.xtext/org.eclipse.xtext.xbase.lib "2.25.0.M1"]
 [org.xerial/sqlite-jdbc "3.34.0"]
 [seancorfield/next.jdbc "1.1.613"]
   [org.clojure/java.data "1.0.78"]
 [trptcolin/versioneer "0.2.0"]

ericdallo 2021-01-20T22:09:12.040900Z

since we also have a lot of final users, like emacs, vim, vscode a native image would be useful IMO

borkdude 2021-01-20T22:10:05.041100Z

do you use sqlite ?

ericdallo 2021-01-20T22:10:40.041300Z

Yep, for persisting our atom as sqlite in the .lsp/sqlite.db

ericdallo 2021-01-20T22:10:51.041500Z

but this can change with kondo 100% integration

ericdallo 2021-01-20T22:11:04.041700Z

and I know there are faster ways of persisting that

borkdude 2021-01-20T22:11:34.041900Z

This is the only thing I see in here that I never got to work with graalvm. This is why I (and lispyclouds) wrote a babashka sqlite pod in go instead of graal. The way I persist information to disk in clj-kondo is through transit, no db. But there is another option: hsqldb works with graalvm and is similar to sqlite.

borkdude 2021-01-20T22:12:11.042200Z

So if you could remove sqlite or swap it out with hsqldb, it could work.

borkdude 2021-01-20T22:12:41.042400Z

It would be good to check the license of hsqldb though, I think LSP has to remain fully open source

ericdallo 2021-01-20T22:14:49.042600Z

Nice, thanks for the info, we have https://github.com/clojure-lsp/clojure-lsp/issues/234 with some concerns already pointed by @snoe

borkdude 2021-01-20T22:15:29.042800Z

you are linking to the issues page - did you mean a specific issue?

ericdallo 2021-01-20T22:15:53.043200Z

oh sorry, fixed

borkdude 2021-01-20T22:17:08.043400Z

Datalevin also doesn't work with GraalVM last time I tried it

😿 1
borkdude 2021-01-20T22:17:40.043700Z

If you want to try out and see that HSQLDB works with babashka natively: https://github.com/babashka/pod-registry/blob/master/examples/hsqldb.clj

ericdallo 2021-01-20T22:18:45.044100Z

Cool, I think would fit very well for us, we just need to check the license, I don't know too much about these things though

borkdude 2021-01-20T22:19:00.044300Z

I did try sqlite and things like this in the very beginning of clj-kondo, since I had similar ideas as in that issue. But eventually I partitioned things basically by namespace and try to load only when necessary, minimizing I/O

1
borkdude 2021-01-20T22:19:47.044600Z

Also discovering an issue with transit along the way: https://github.com/cognitect/transit-clj/issues/43

😔 1
ericdallo 2021-01-20T22:20:26.045Z

I think one of the common uses of persisted db on clojure-lsp, is the inital cache, but this may be fixed after kondo 100% integration, since we'll use clj-kondo cache

borkdude 2021-01-20T22:21:24.045500Z

You mean the analysis output right?

ericdallo 2021-01-20T22:21:35.045700Z

yes

ericdallo 2021-01-20T22:22:04.045900Z

@snoe made some testings with that, he may know more about that

borkdude 2021-01-20T22:22:04.046100Z

Yeah, this is exciting, since other tools can re-use this too. Nice convergence of tooling

ericdallo 2021-01-20T22:22:55.046300Z

Totally, After this migration I intend to open a PR improving the docs of the analysis, that's awesome and users need to know more about it

ericdallo 2021-01-20T22:27:41.046500Z

That's what we use from sqlite, just simple insert/query https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/db.clj

borkdude 2021-01-20T22:29:03.046800Z

How big does this data tend to get, how many rows?

borkdude 2021-01-20T22:29:22.047Z

Maybe you could just use .edn or .json

borkdude 2021-01-20T22:29:26.047200Z

or transit

ericdallo 2021-01-20T22:31:16.047400Z

good question, AFAIK, we only save a row, but the analysis column may be huge, since it's the kondo output

ericdallo 2021-01-20T22:31:38.047600Z

It looks weird to me that query, but I never noticed a performance issue

borkdude 2021-01-20T22:32:00.047900Z

This is probably because you do a lot of in memory stuff and only persist when shutting down?

ericdallo 2021-01-20T22:33:55.048100Z

On master (before kondo integration), we persist the crawled jars, that should not change between lsp restart, only if user change deps which we will re-scan/persist

borkdude 2021-01-20T22:34:33.048300Z

right

ericdallo 2021-01-20T22:34:38.048500Z

with clj-kondo integration we are saving all the analysis, but that may be wrong, since the analysis contains analysis from the external jars and from the project which will easily change

ericdallo 2021-01-20T22:35:03.048800Z

Maybe we should persist only the analysis from kondo on jars too

kokada 2021-01-20T23:50:13.049Z

> But if you have other reasons to make a native image, and you can point me to an issue, I can give some hints probably Well, for me it is most an experiment, I think clojure-lsp startup does slow down the general experience of editting Clojure in Emacs (since it takes a while until it is ready), so I think GraalVM can help with this

kokada 2021-01-20T23:50:43.049200Z

Also, I don't think clojure-lsp is really that much CPU intensive for JIT in JVM to makes a difference. I may be wrong though

ericdallo 2021-01-20T23:55:33.049600Z

The slow down time from clojure-lsp is most related to the jars crawling, changing to GraalVM won't change that

ericdallo 2021-01-20T23:56:04.049800Z

We should gain a few secs, but not compared with minutes we take scanning huge projects

ericdallo 2021-01-20T23:56:21.050Z

Hopefully this will change with clj-kondo analysis PR

kokada 2021-01-20T23:57:09.050200Z

> We should gain a few secs, but not compared with minutes we take scanning huge projects Yeah, but this is exactly what I want. A few seconds impacts a lot the feeling of a fast tooling

kokada 2021-01-20T23:57:41.050400Z

Try to add just 0.5 sec to your ls for example:

ls() { sleep 0.5; ls $@; }

kokada 2021-01-20T23:58:45.050700Z

Considering that Clojure alone takes more than half a second to start I still think it is worth to pursuit this, even if is just for a test

kokada 2021-01-20T23:59:11.050900Z

But well, this is a IMO

ericdallo 2021-01-21T00:08:41.051100Z

Yeah, I see your point and agree, I was just saying that for some cases, take 40 secs and take 35 secs may have no difference for most users

ericdallo 2021-01-21T00:08:58.051300Z

but I agree, every performance improvement is welcome

kokada 2021-01-21T00:31:09.051500Z

> We should gain a few secs, but not compared with minutes we take scanning huge projects Ah, now I understood what you said here (I thought you said GraalVM wouldn't bring improvements compared to other huge projects using it, not that clojure-lsp itself takes minutes to scan huge projects)

kokada 2021-01-21T00:31:42.051700Z

I still think GraalVM can helps a with this initial scanning, specially if this initial scanning happens when the VM is cold

kokada 2021-01-21T00:32:19.051900Z

(But only if the issue is CPU bound, if it is IO bound it will not help)

snoe 2021-01-21T04:25:58.003500Z

One of the reasons I picked sqlite is because it is very very good at handling all the intricacies of os io. On the kondo-pr I am also persisting the analysis to the db as it cuts startup from 20s to 5s. https://github.com/oracle/graal/issues/966 this might be an option for graal, seems like people had some success.

ericdallo 2021-01-23T14:51:57.053Z

I just made a simple test compiling with native-image a simple sample project using the same sqlite db we use with clojure-lsp and it worked like a charm 🙂 I'll try to check why @thiagokokada branch is not working

borkdude 2021-01-23T14:53:48.053200Z

huh... sqlite worked with graalvm?

borkdude 2021-01-23T14:54:04.053400Z

I want to see the sample project :)

ericdallo 2021-01-23T14:54:30.053600Z

I'll push it and give you the link, one sec

ericdallo 2021-01-23T14:54:42.053800Z

I hope I did everything correct 😅

ericdallo 2021-01-23T15:04:55.054Z

It's really working, but it gives some exceptions during the build: (but the exceptions shows up even if a simple println clojure project :man-shrugging:)

ericdallo 2021-01-23T15:05:49.054400Z

this is the sample: https://github.com/ericdallo/clojure-sample

borkdude 2021-01-23T15:06:01.054700Z

Ah, this explains it. It's a fallback image. This is not really a native binary, but just a kind of uberjar.

borkdude 2021-01-23T15:06:12.054900Z

Compile with --no-fallback

ericdallo 2021-01-23T15:06:24.055100Z

oh... that's sad 😕

ericdallo 2021-01-23T15:06:47.055300Z

I see, probably it'll not work so

ericdallo 2021-01-23T15:07:05.055500Z

yeah, just saw the warning log right now :man-facepalming:

borkdude 2021-01-23T15:07:38.055700Z

Here are some standard args I always use:

args=("-H:+ReportExceptionStackTraces"
       "-H:ReflectionConfigurationFiles=reflection.json"
       "--initialize-at-build-time"
       "-H:Log=registerResource:"
       "-H:EnableURLProtocols=http,https,jar"
       "--enable-all-security-services"
       "-H:+JNI"
       "--verbose"
       "--no-fallback"
       "--no-server"
       "--report-unsupported-elements-at-runtime"
       "--native-image-info"
       "--verbose")

ericdallo 2021-01-23T15:08:24.055900Z

Ok, it gave me a lot of exceptions indeed (probably related to the reflection.json I'm not using like clj-kondo uses)

ericdallo 2021-01-23T15:08:40.056100Z

I'll step back and try to make it work without sqlite then try to add it

ericdallo 2021-01-23T15:08:50.056300Z

sorry for the false alarm @borkdude and thanks for the help

borkdude 2021-01-23T15:08:56.056500Z

:thumbsup:

borkdude 2021-01-23T15:09:37.056700Z

For babashka we made this: https://github.com/babashka/pod-babashka-sqlite3 It is a component which runs sqlite in a go binary. Small and fast. And it communicates using JSON back and forth, a bit like a webservice

borkdude 2021-01-23T15:09:54.057100Z

transit actually

borkdude 2021-01-23T15:10:18.057300Z

You could use this to workaround your issues, using the JVM pod library which also works in a GraalVM binary

borkdude 2021-01-23T15:10:37.057500Z

but it's a bit of a workaround ;)

ericdallo 2021-01-23T15:11:04.057700Z

yeah, I see, do you think it'd work well with clojure-lsp ?

borkdude 2021-01-23T15:11:13.057900Z

I think it would.

borkdude 2021-01-23T15:11:22.058100Z

It supports even sending over binary blobs

borkdude 2021-01-23T15:12:44.058300Z

I wouldn't just go and distribute this native approach to production very soon, first run some tests with power users

ericdallo 2021-01-23T15:13:00.058500Z

really nice work on that project haha 👏 I'll try to debug graalvm a little more with some more tests and follow the above post from snoe and if does not work I'll try to use pod-babashka-sqlite3

borkdude 2021-01-23T15:13:07.058700Z

as you might run into issues with macOS users and permissions

ericdallo 2021-01-23T15:13:26.058900Z

yes, this needs to be done carefully indeed

ericdallo 2021-01-23T15:14:19.059100Z

if it works, I could test with coworkers that use MacOS on huge Nubank projects

borkdude 2021-01-23T15:16:56.059300Z

yeah

borkdude 2021-01-23T15:17:39.059500Z

You will need to use this lib as a JVM lib: https://github.com/babashka/pods And then do (load-pod ...) as in the README of the sqlite3 pod

borkdude 2021-01-23T15:18:12.060Z

I guess you aren't using deps.edn right?

ericdallo 2021-01-23T15:18:13.060200Z

@borkdude one more question 😅 those deps:https://github.com/clj-kondo/clj-kondo/blob/master/project.clj#L21-L22 they are for something clj-kondo does specific? do you think we'd need to make graalvm work on clojure-lsp too?

borkdude 2021-01-23T15:19:23.060500Z

I am working on a PR for babashka which uses GraalVM 21 and it doesn't seem to be needed anymore.

borkdude 2021-01-23T15:19:45.060700Z

You will need it with 20.3.0

borkdude 2021-01-23T15:19:50.060900Z

but go with 21 I'd say

ericdallo 2021-01-23T15:19:58.061100Z

nice (I'ḿ using 20.3.0 ATM)

ericdallo 2021-01-23T15:20:56.061300Z

BTW, we are using deps.edn , not sure if it's the correct way to use though, we kind of import it from project.clj

borkdude 2021-01-23T15:21:40.061500Z

oh then it's all fine, I was wondering if I should make a clojars release for the pods lib, but you can use it as a git lib then

ericdallo 2021-01-23T15:22:04.061700Z

Oh got it 👍

snoe 2021-01-23T16:31:12.061900Z

Eh I'd say it's a lein project more than deps.edn. Not sure where equivalents to lein bin and test-refresh are these days.

ericdallo 2021-01-23T21:53:17.062400Z

Well, I managed to make it work with org.xerial/sqlite-jdbc , persisting and selecting from sql from a java Class in clojure

ericdallo 2021-01-23T21:53:34.062600Z

But I'm having issues with graalvm work with next.jdbc

borkdude 2021-01-23T21:55:17.062800Z

@ericdallo I have several working examples of next.jdbc and GraalVM, this was never the issue for me.

borkdude 2021-01-23T21:56:01.063Z

The driver was usually the problem

borkdude 2021-01-23T21:56:13.063200Z

so what error are you getting?

ericdallo 2021-01-23T21:56:59.063400Z

Yeah, I saw that issue where you give some examples 😛 This is the stack: https://pastebin.com/Jsw45Rjr

ericdallo 2021-01-23T21:57:31.063600Z

oh, sorry wrong paste

1
ericdallo 2021-01-23T22:15:00.063900Z

https://pastebin.com/Jn3vj7LE

borkdude 2021-01-23T22:19:15.064100Z

Can you also paste ./scripts/native-compile.sh ?

ericdallo 2021-01-23T22:19:31.064300Z

yes, I'm pushing the code right now 🙂

borkdude 2021-01-23T22:21:01.064500Z

@ericdallo you need to use at least clojure 1.10.2+ (rc3 now)

borkdude 2021-01-23T22:21:10.064700Z

to avoid the infamous locking error

borkdude 2021-01-23T22:21:46.064900Z

CLJ-1472

borkdude 2021-01-23T22:22:00.065100Z

(https://clojure.atlassian.net/browse/CLJ-1472)

ericdallo 2021-01-23T22:24:18.065300Z

Oh, good to know

ericdallo 2021-01-23T22:26:53.065800Z

Basically it uses this class which works: https://github.com/ericdallo/clojure-sample/blob/master/src-java/clojure_sample/SampleDb.java

ericdallo 2021-01-23T22:29:15.066100Z

This does works to me, what means that sql is working, right? So if next.jdbc works, basically our problems are gone, right?

ericdallo 2021-01-23T22:30:05.066300Z

Sorry for the code @borkdude it's a mess, I'm doing a lot of tests

ericdallo 2021-01-23T22:33:33.066500Z

I'm checking your examples with next.jdbc, does https://github.com/babashka/babashka-sql-pods/blob/5d04e7fce699741e1b5e8488cf0a8f70843a3e2e/script/compile#L54 works with graalvm 20.3.0?

borkdude 2021-01-23T22:34:00.066800Z

it does yes

ericdallo 2021-01-23T22:34:48.067Z

Ok, probably your example is using some flag that I missing, I'll try to find what is

borkdude 2021-01-23T22:38:19.067200Z

@ericdallo What error do you get after using 1.10.2-rc3 though?

borkdude 2021-01-23T22:38:25.067400Z

That should be done first

borkdude 2021-01-23T22:38:41.067600Z

After that, there should basically be no problems, when your reflection config has all the things needed

ericdallo 2021-01-23T22:38:48.067800Z

I'm compiling right now with that version 😆

ericdallo 2021-01-23T22:38:59.068Z

Oh my, I really hope 🤞

ericdallo 2021-01-23T22:39:16.068200Z

I spent all day compiling hahahah my notebook need some rest 😛

ericdallo 2021-01-23T22:42:09.068400Z

It worked!

ericdallo 2021-01-23T22:42:41.068600Z

I can't believe it 😄

borkdude 2021-01-23T22:42:59.068800Z

This is big news! Are you using 20.3.0?

ericdallo 2021-01-23T22:43:20.069Z

I'll clean the code and do other push, thank you for the help @borkdude with that it's proved that we can compile graalvm app using sqlite!

ericdallo 2021-01-23T22:44:03.069200Z

Actually I'm using 20.2.0 since it's the latest available for NixOS users

borkdude 2021-01-23T22:44:18.069400Z

Yeah, I think a PR to this repo is in order: https://github.com/babashka/babashka-sql-pods/ We already support postgres, hsqldb and now oracle

borkdude 2021-01-23T22:44:37.069600Z

But I can do that myself too using your config

ericdallo 2021-01-23T22:44:55.069800Z

So the trick was using latest clojure and the custom JNI class

borkdude 2021-01-23T22:45:04.070Z

custom JNI class?

ericdallo 2021-01-23T22:45:43.070200Z

Yeah, without this on classpath the sql wasn't working : https://github.com/ericdallo/clojure-sample/blob/master/src-java/clojure_sample/JNIReflectionClasses.java

ericdallo 2021-01-23T22:46:10.070500Z

I could create a fix jar like you did for clojure-reflector

ericdallo 2021-01-23T22:46:12.070700Z

WDYT?

borkdude 2021-01-23T22:46:54.070900Z

Ah, very interesting, I've never used this before. I wonder if it works on macOS as well. I don't think this class is actually needed once you use the generated reflection json

borkdude 2021-01-23T22:47:12.071100Z

could be wrong though

ericdallo 2021-01-23T22:47:45.071300Z

Hum, the json doesn't include org.sqlite custom reflection classes/methods

ericdallo 2021-01-23T22:47:51.071500Z

but I'll try right now

borkdude 2021-01-23T22:48:10.071700Z

ah it only adds it to the build, but doesn't spit it out to the reflection.json?

borkdude 2021-01-23T22:48:21.071900Z

but you are logging these classes

borkdude 2021-01-23T22:48:28.072100Z

so you could manually add those

ericdallo 2021-01-23T22:48:45.072300Z

Hum, yeah, true indeed

ericdallo 2021-01-23T22:49:25.072500Z

It's a lot of classes, don't you think a external jar with that fix would be better?

borkdude 2021-01-23T22:50:12.072700Z

how do I create the uberjar that your script/native-compile.sh needs?

borkdude 2021-01-23T22:50:41.072900Z

I'm getting:

$ lein with-profiles +native-image "do" clean, uberjar
OpenJDK 64-Bit Server VM warning: forcing TieredStopAtLevel to full optimization because JVMCI is enabled
Could not find artifact rewrite-clj:rewrite-clj:jar:0.6.3-SNAPSHOT in clojars (<https://repo.clojars.org/>)

ericdallo 2021-01-23T22:51:14.073100Z

Oh sorry, this was another test of mine hahaha of another issue, you can change it to use 0.6.1 on deps.edn

borkdude 2021-01-23T22:52:08.073300Z

you are using 1 repo for all your issues? great way to mix problems ;)

borkdude 2021-01-23T22:52:48.073500Z

Fatal error:com.oracle.svm.core.util.VMError$HostedError: Option name "TruffleMultiThreaded" has multiple definitions: com.oracle.svm.truffle.api.SubstrateTruffleOptions.TruffleMultiThreaded and com.oracle.svm.truffle.api.SubstateTruffleOptions.TruffleMultiThreaded

ericdallo 2021-01-23T22:53:22.073700Z

hahaha yeah, I usually don't do that, but today I got things messed 😅

ericdallo 2021-01-23T22:53:48.073900Z

Hum, I didn't have this error :thinking_face:

borkdude 2021-01-23T22:53:59.074100Z

this is probably a conflict between 20.2.0 stuff and 20.3.0 stuff

borkdude 2021-01-23T22:54:14.074300Z

in 21 we don't need all this stuff anymore I think

borkdude 2021-01-23T22:54:20.074500Z

but now it's running

ericdallo 2021-01-23T22:54:24.074700Z

got it

borkdude 2021-01-23T22:54:59.074900Z

so I think when you add all the > Declaring class: org.sqlite.core.NativeDB to the reflection config (with all the methods, etc), then it should also work

ericdallo 2021-01-23T22:55:26.075100Z

Yes!

ericdallo 2021-01-23T22:55:37.075300Z

I'm so glad this works now 😄

borkdude 2021-01-23T22:56:01.075500Z

so where are you now using sqlite, or is this only the java version?

ericdallo 2021-01-23T22:56:02.075700Z

I'll clean up this repo and externalize the JNI class to a fix jar

ericdallo 2021-01-23T22:56:14.075900Z

I'm using in the sqlite ns

ericdallo 2021-01-23T22:56:23.076100Z

clojure-sample.sqlite

borkdude 2021-01-23T22:56:30.076300Z

this is all commented out in my checkout

borkdude 2021-01-23T22:57:11.076500Z

Like I said: I don't think a library/jar is needed for this, you can probably add the classes to the reflection config

borkdude 2021-01-23T22:58:17.076700Z

org.sqlite.core.NativeDB
org.sqlite.Function
org.sqlite.Function.Aggregate
org.sqlite.ProgressHandler
org.sqlite.Function.Window
org.sqlite.core.DB.ProgressObserver

ericdallo 2021-01-23T22:59:41.076900Z

Ok, I'll try then

borkdude 2021-01-23T23:00:26.077100Z

Ah I see, you also need to have some JNI json file:

-H:JNIConfigurationFiles=/path/to/jniconfig
https://www.graalvm.org/reference-manual/native-image/JNI/ I think this was the missing part

borkdude 2021-01-23T23:01:02.077500Z

The difference between your class and a .json file is that your class registers these things at runtime, and a .json file is the declarative way of doing the same

ericdallo 2021-01-23T23:05:22.077700Z

you mean we need both the reflection json file with those classes and this H:JNIConfigurationFiles?

ericdallo 2021-01-23T23:05:36.077900Z

I didn't used this H:JNIConfigurationFiles , why do we need it?

borkdude 2021-01-23T23:06:22.078100Z

Like I said: the configuration file is the declarative way of doing the same you are doing with the Java class now

borkdude 2021-01-23T23:07:01.078400Z

both are probably fine, but that logic is often tied to a specific graalvm version whereas a .json file is not

ericdallo 2021-01-23T23:07:10.078600Z

I see but what is the difference between ReflectionConfigurationFiles and H:JNIConfigurationFiles ?

borkdude 2021-01-23T23:07:16.078800Z

so if you can get it working with .json files, that is much better for the future

ericdallo 2021-01-23T23:08:06.079Z

I'll try to use the json file, I just don't get it If I should add the classes to ReflectionConfigurationFiles or to the H:JNIConfigurationFiles

borkdude 2021-01-23T23:08:06.079200Z

> JNI supports looking up classes by their names, and looking up methods and fields by their names and signatures. This requires keeping the necessary metadata for these lookups around. The native image builder must know beforehand which items will be looked up in case they might not be reachable otherwise and therefore would not be included in the native image. Moreover, the native image builder must generate call wrapper code ahead-of-time for any method that can be called via JNI. Therefore, specifying a concise list of items that need to be accessible via JNI guarantees their availability and allows for a smaller footprint.

borkdude 2021-01-23T23:08:19.079400Z

I think all the methods that use JNI need to be also in the JNI .json file

ericdallo 2021-01-23T23:08:53.079900Z

I see, so I think I'll need to keep working to make it work with json files only 😄

ericdallo 2021-01-23T23:09:08.080100Z

thanks for the huge help explaining those things @borkdude

borkdude 2021-01-23T23:09:18.080300Z

I don't know if these classes need to be in both files, or if jni config implies reflection config, but maybe try both :)

1
borkdude 2021-01-23T23:09:22.080500Z

ok, I'm off now

borkdude 2021-01-23T23:09:24.080700Z

late

ericdallo 2021-01-23T23:09:31.080900Z

good night!

borkdude 2021-01-23T23:09:37.081100Z

thanks

ericdallo 2021-01-24T00:17:20.081400Z

I could not make it work with the jni json file 😞 This is how it looks: https://pastebin.com/MsX5Jm7q

ericdallo 2021-01-24T00:17:51.081600Z

I'm not sure if I should specify each method/constructor/field manually, or if these all* should work

ericdallo 2021-01-19T20:20:38.030300Z

Oh really interesting indeed! @thiagokokada could that help us with https://github.com/clojure-lsp/clojure-lsp/pull/213?

souenzzo 2021-01-19T22:24:16.030900Z

Not sure if it's about the same thing This issue is about use native-image to make LSP startup faster That graalvm extension is a implementation of LSP protocol to LSP Languages. It may help for example, in "goto definition" when a clojure code is calling a java class/method. That GraalVM LSP Server isn't only about java, but it integrate with javascript and others languages in Graal ecossystem. The JS things may help in cljs linting

ericdallo 2021-01-19T22:26:00.031100Z

Yes, we could use that on graal vm native image to group returned clojure-lsp values with the lsp from graalvm, at least is what I could understand

👍 1