@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.
yes
but it's already there: https://github.com/babashka/babashka/blob/aa0da8f503534b1e620284da719af5af6ed4a511/src/babashka/impl/classes.clj#L135
Perhaps write (set! (.-soloExecutor clojure.lang.Agent) ...)
ah right
will try in a bit
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 onehmm, setting a public field in a class, might not be supported yet... check SCI
right
I thought I fixed something around this recently but can't remember exactly what it was
i'll try to poke around
Ah that was only "getting": https://github.com/babashka/sci/commit/5247b866deeec858480ba2bb22a7d0d3b96c0190
it is so uncommon to mutate public fields that it was never implemented :)
well its either this or clojure releases a new version to support loom 😛
yeah, I think we're just going to support this
file a SCI issue
cool, will use the above code as an example
> 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?
ah i see (if (and (not (Modifier/isStatic mod)) ...
I expect it to be similar, haven't looked into it yet
maybe i could try to have a go at it, since it doesnt seem to be too urgent 😄
yeah, please do :)