Skip to content

Commit

Permalink
prevent dynamic classes from being flushed before use
Browse files Browse the repository at this point in the history
  • Loading branch information
richhickey committed Jun 6, 2010
1 parent 3353eea commit 2ac9319
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/clj/clojure/core_deftype.clj
Expand Up @@ -23,8 +23,9 @@
psig (fn [[name [& args]]]
(vector name (vec (map tag args)) (tag name) (map meta args)))
cname (with-meta (symbol (str (namespace-munge *ns*) "." name)) (meta name))]
`(do (gen-interface :name ~cname :methods ~(vec (map psig sigs)))
(import ~cname))))
`(let []
(gen-interface :name ~cname :methods ~(vec (map psig sigs)))
(import ~cname))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;; reify/deftype ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down Expand Up @@ -294,7 +295,7 @@
tag (keyword (str *ns*) (str name))
hinted-fields fields
fields (vec (map #(with-meta % nil) fields))]
`(do
`(let []
~(emit-defrecord name gname (vec hinted-fields) (vec interfaces) methods)
(defmethod print-method ~classname [o# w#]
((var print-defrecord) o# w#))
Expand Down Expand Up @@ -386,7 +387,7 @@
tag (keyword (str *ns*) (str name))
hinted-fields fields
fields (vec (map #(with-meta % nil) fields))]
`(do
`(let []
~(emit-deftype* name gname (vec hinted-fields) (vec interfaces) methods)
(import ~classname))))

Expand Down
2 changes: 2 additions & 0 deletions src/clj/clojure/core_proxy.clj
Expand Up @@ -331,6 +331,8 @@
(clojure.lang.Compiler/writeClassFile cname bytecode)))
pc-effect (apply get-proxy-class bases)
pname (proxy-name super interfaces)]
;remember the class to prevent it from disappearing before use
(intern *ns* (symbol pname) pc-effect)
`(let [;pc# (get-proxy-class ~@class-and-interfaces)
p# (new ~(symbol pname) ~@args)] ;(construct-proxy pc# ~@args)]
(init-proxy p#
Expand Down

0 comments on commit 2ac9319

Please sign in to comment.