On Thu, Sep 22, 2011 at 2:56 PM, Kevin Downey <redc...@gmail.com> wrote:
> most likely the compiler is creating a new DynamicClassLoader, it uses
> a var clojure.lang.Compiler/LOADER and pushes and pops class loaders
> from there.

You nailed it.

It looks like each top-level form currently gets its own fresh
DynamicClassLoader.

(do
  (deftype C [])
  (def x1 (C.))
  (deftype C [a])
  (def x2 (C. 42)))

(.getClassLoader (class x1))
;=> #<DynamicClassLoader clojure.lang.DynamicClassLoader@3e5b38d7>

(.getClassLoader (class x2))
;=> #<DynamicClassLoader clojure.lang.DynamicClassLoader@727f3b8a>

Note the numbers after the @s are different -- each got its own
classloader.  This is not exclusive to deftype of course:

(do (def a #()) (def b #()))

(.getClassLoader (class a))
;=> #<DynamicClassLoader clojure.lang.DynamicClassLoader@638bd7f1>

(.getClassLoader (class b))
;=> #<DynamicClassLoader clojure.lang.DynamicClassLoader@581de498>

--Chouser

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to