Skip to content

Support setting public static fields in classes #804

@lispyclouds

Description

@lispyclouds

Is your feature request related to a problem? Please describe.
I stumbled onto this when trying to override the Executor for clojure.lang.Agent. The minimum code that needs to run:

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

(set! (.-soloExecutor Agent) (Executors/newFixedThreadPool 10))

Currently, as setting of the public static fields in a class isn't supported, this results in the following error:

----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Invalid assignment target
Data:     {:type :sci/error, :line 4, :column 1, :file "foo.clj", :phase "analysis"}
Location: 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 - foo.clj:4:1

Describe the solution you'd like
I should be able to set that field and other public static fields in a class.

Describe alternatives you've considered
None

Additional context
This is mainly for the ability to be able to override the Executors to support virtual threads in core constructs like (future ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions