summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-03-15 14:46:47 +0000
committerRich Hickey <richhickey@gmail.com>2008-03-15 14:46:47 +0000
commit9979f81f862b60c03b60ad442d5a29676b1016b7 (patch)
treebce80ae7d90cdffaf5bdf81b0cf7e42d81af8ca1
parentc5d47859139bb5fd0a8164aca15c896d19790645 (diff)
filter all considered methods in superclass traverse, to avoid implementing method turned final in derived
-rw-r--r--src/proxy.clj36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/proxy.clj b/src/proxy.clj
index 6e3009e8..d9aceffb 100644
--- a/src/proxy.clj
+++ b/src/proxy.clj
@@ -138,24 +138,26 @@
(. gen (endMethod)))
;calc set of supers' non-private instance methods
- (let [mm (loop [mm {} c super]
+ (let [mm (loop [mm {} considered #{} c super]
(if c
- (recur
- (loop [mm mm meths (concat
- (seq (. c (getDeclaredMethods)))
- (seq (. c (getMethods))))]
- (if meths
- (let [#^java.lang.reflect.Method meth (first meths)
- mods (. meth (getModifiers))
- mk [(. meth (getName)) (seq (. meth (getParameterTypes)))]]
- (if (or (contains? mm mk)
- (. Modifier (isPrivate mods))
- (. Modifier (isStatic mods))
- (. Modifier (isFinal mods)))
- (recur mm (rest meths))
- (recur (assoc mm mk meth) (rest meths))))
- mm))
- (. c (getSuperclass)))
+ (let [[mm considered]
+ (loop [mm mm
+ considered considered
+ meths (concat
+ (seq (. c (getDeclaredMethods)))
+ (seq (. c (getMethods))))]
+ (if meths
+ (let [#^java.lang.reflect.Method meth (first meths)
+ mods (. meth (getModifiers))
+ mk [(. meth (getName)) (seq (. meth (getParameterTypes)))]]
+ (if (or (considered mk)
+ (. Modifier (isPrivate mods))
+ (. Modifier (isStatic mods))
+ (. Modifier (isFinal mods)))
+ (recur mm (conj considered mk) (rest meths))
+ (recur (assoc mm mk meth) (conj considered mk) (rest meths))))
+ [mm considered]))]
+ (recur mm considered (. c (getSuperclass))))
mm))]
;add methods matching supers', if no mapping -> call super
(doseq #^java.lang.reflect.Method meth (vals mm)