Skip to content

compile-time use of construct-proxy/definterface etc. doesn't work due to ClassLoader #51

Description

@SevereOverfl0w

Clojure assumes that clojure.lang.Compiler/LOADER is a DynamicClassLoader in a few places, but rules-clojure.persistentClassLoader is what's set to the ClassLoader instead. This causes the compilation step to fail. Compiling a namespace referencing a namespace containing (def foo (get-proxy-class ExceptionInfo)) should reproduce the error, with the message :cause class rules_clojure.persistentClassLoader cannot be cast to class clojure.lang.DynamicClassLoader (rules_clojure.persistentClassLoader is in unnamed module of loader 'app'; clojure.lang.DynamicClassLoader is in unnamed module of loader rules_clojure.persistentClassLoader @65ff29ae)

(note: for some reason I have to put that repro in b, and then compile a which :requires b)

~/src/github.com/clojure/clojure master* 
❯ rg '\^.*DynamicClassLoader'           
src/clj/clojure/genclass.clj
722:      (.defineClass ^DynamicClassLoader (deref clojure.lang.Compiler/LOADER)

src/clj/clojure/repl/deps.clj
32:      (.addURL ^DynamicClassLoader loader u)

src/clj/clojure/core_proxy.clj
293:            (. ^DynamicClassLoader (deref clojure.lang.Compiler/LOADER) (defineClass pname bytecode [super interfaces]))))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions