Fork me on GitHub
#babashka-sci-dev
<
2022-09-22
>
lispyclouds09:09:13

@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.

borkdude09:09:31

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

lispyclouds09:09:50

will try in a bit

lispyclouds09:09:51

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

borkdude09:09:53

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

borkdude09:09:29

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

lispyclouds09:09:40

i'll try to poke around

borkdude09:09:29

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

lispyclouds09:09:00

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

borkdude09:09:15

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

borkdude09:09:20

file a SCI issue

lispyclouds09:09:34

cool, will use the above code as an example

👍 1
lispyclouds12:09:03

> 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?

lispyclouds12:09:19

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

borkdude12:09:25

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

lispyclouds12:09:58

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

borkdude12:09:09

yeah, please do :)

1