Skip to content
Browse files

prevent dynamic classes from being flushed before use

  • Loading branch information...
1 parent 3353eea commit 2ac93197e356af3c826ca895b5a538ad08c5715a @richhickey richhickey committed Jun 6, 2010
Showing with 7 additions and 4 deletions.
  1. +5 −4 src/clj/clojure/core_deftype.clj
  2. +2 −0 src/clj/clojure/core_proxy.clj
View
9 src/clj/clojure/core_deftype.clj
@@ -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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -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#))
@@ -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))))
View
2 src/clj/clojure/core_proxy.clj
@@ -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#

0 comments on commit 2ac9319

Please sign in to comment.
Something went wrong with that request. Please try again.