1.3.0 permalink Arrow_down_16x16

proxy-super

clojure.core

  • (proxy-super meth & args)
Use to call a superclass method in the body of a proxy method.
Note, expansion captures 'this

1 Example top

  • ;; Create a proxy for java.util.ArrayList that overrides the add() 
    ;; method and calls the super class implementation using proxy-super.
    (def lst (proxy [java.util.ArrayList] []
               (add [x]
                 (println "Adding some stuff:" x)
                 (proxy-super add x))))
    
    user=> (.add lst 1)
    Adding some stuff: 1
    true
    
    user=> (.add lst 2)
    Adding some stuff: 2
    true
    
    user=> (.add lst [:this :is :some :other :stuff])
    Adding some stuff: [:this :is :some :other :stuff]
    true
    
    user=> (.size lst)
    3
    
    
     
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core_proxy.clj:365 top

(defmacro proxy-super 
  "Use to call a superclass method in the body of a proxy method. 
  Note, expansion captures 'this"
  {:added "1.0"}
  [meth & args]
 `(proxy-call-with-super (fn [] (. ~'this ~meth ~@args))  ~'this ~(name meth)))
Vars in clojure.core/proxy-super:
Used in 0 other vars

Comments top

1 comment(s) for proxy-super.

Note that proxy-super calls are not reentrant. If calling the base method results in another call to the virtual method you are overriding (before the proxy-super call has returned), your proxy's code will not be invoked. Instead, the call will go directly to the base class's method.

Log in to add a comment.