diff options
author | Christophe Grand <christophe@cgrand.net> | 2009-08-27 14:38:51 +0200 |
---|---|---|
committer | Chouser <chouser@n01se.net> | 2009-09-12 22:52:20 -0400 |
commit | e73abece1ebf3a4aba22104ae9452b2b816ab0d7 (patch) | |
tree | 13e9194bcefb00aff1971ca8ab65921e55d94f93 | |
parent | cc78418e773517d1c3427818cbee2254689fc0d8 (diff) |
proxy now caches generated classes per namespace and include a hash to distinguish proxy classes implementing homonymous interfaces. Fixes #181
Signed-off-by: Chouser <chouser@n01se.net>
-rw-r--r-- | src/clj/clojure/core_proxy.clj | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/core_proxy.clj index 93e3e0ba..7653deab 100644 --- a/src/clj/clojure/core_proxy.clj +++ b/src/clj/clojure/core_proxy.clj @@ -34,10 +34,13 @@ (defn proxy-name {:tag String} [#^Class super interfaces] - (apply str "clojure.proxy." - (.getName super) - (interleave (repeat "$") - (sort (map #(.getSimpleName #^Class %) interfaces))))) + (let [inames (into (sorted-set) (map #(.getName #^Class %) interfaces))] + (apply str (.replace (str *ns*) \- \_) ".proxy" + (interleave (repeat "$") + (concat + [(.getName super)] + (map #(subs % (inc (.lastIndexOf #^String % "."))) inames) + [(Integer/toHexString (hash inames))]))))) (defn- generate-proxy [#^Class super interfaces] (let [cv (new ClassWriter (. ClassWriter COMPUTE_MAXS)) |