babashka-sci-dev

lispyclouds 2022-09-22T09:23:13.745209Z

@borkdude in order to run (set! clojure.lang.Agent/soloExecutor (Executors/newVirtualThreadPerTaskExecutor)) on the loom bb I need to add Agent.soloExecutor to the reflection config? this is to make (future ...) calls use virtual threads.

borkdude 2022-09-22T09:23:44.356409Z

yes

borkdude 2022-09-22T09:24:31.024389Z

Perhaps write (set! (.-soloExecutor clojure.lang.Agent) ...)

lispyclouds 2022-09-22T09:24:40.873979Z

ah right

lispyclouds 2022-09-22T09:24:50.342699Z

will try in a bit

lispyclouds 2022-09-22T09:53:51.292029Z

given the code

(import '[clojure.lang Agent]
        '[java.util.concurrent Executors])

(set! (.-soloExecutor Agent) (Executors/newFixedThreadPool 10))
gives the error
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Invalid assignment target
Data:     {:type :sci/error, :line 4, :column 1, :file "/Users/rahul.de/code/expts/clojure/foo.clj", :phase "analysis"}
Location: /Users/rahul.de/code/expts/clojure/foo.clj:4:1
Phase:    analysis

----- Context ------------------------------------------------------------------
1: (import '[clojure.lang Agent]
2:         '[java.util.concurrent Executors])
3:
4: (set! (.-soloExecutor Agent) (Executors/newFixedThreadPool 10))
   ^--- Invalid assignment target

----- Stack trace --------------------------------------------------------------
user - /Users/rahul.de/code/expts/clojure/foo.clj:4:1
this is using the released bb, not the jdk19 one

borkdude 2022-09-22T09:54:53.544239Z

hmm, setting a public field in a class, might not be supported yet... check SCI

lispyclouds 2022-09-22T09:55:04.290499Z

right

borkdude 2022-09-22T09:56:29.492899Z

I thought I fixed something around this recently but can't remember exactly what it was

lispyclouds 2022-09-22T09:56:40.076239Z

i'll try to poke around

borkdude 2022-09-22T09:57:11.651969Z

Ah that was only "getting": https://github.com/babashka/sci/commit/5247b866deeec858480ba2bb22a7d0d3b96c0190

borkdude 2022-09-22T09:57:29.797099Z

it is so uncommon to mutate public fields that it was never implemented :)

lispyclouds 2022-09-22T09:58:00.378429Z

well its either this or clojure releases a new version to support loom 😛

borkdude 2022-09-22T09:58:15.318009Z

yeah, I think we're just going to support this

borkdude 2022-09-22T09:58:20.240729Z

file a SCI issue

lispyclouds 2022-09-22T09:58:34.705299Z

cool, will use the above code as an example

👍 1
lispyclouds 2022-09-22T12:12:11.931519Z

https://github.com/babashka/sci/issues/804

🙏 1
lispyclouds 2022-09-22T12:17:03.043129Z

> https://github.com/babashka/sci/commit/5247b866deeec858480ba2bb22a7d0d3b96c0190 looking at this, it seems to read a field from an object whereas the above code uses a static public field. would the access pattern for a static field be similar to a non static one?

lispyclouds 2022-09-22T12:18:19.231719Z

ah i see (if (and (not (Modifier/isStatic mod)) ...

borkdude 2022-09-22T12:18:25.742669Z

I expect it to be similar, haven't looked into it yet

lispyclouds 2022-09-22T12:19:58.049729Z

maybe i could try to have a go at it, since it doesnt seem to be too urgent 😄

borkdude 2022-09-22T12:20:09.348139Z

yeah, please do :)

🙏🏼 1