Skip to content

Instantly share code, notes, and snippets.

@schmir
Created June 20, 2014 12:13
Show Gist options
  • Select an option

  • Save schmir/f7a75f1167ecfad51c2d to your computer and use it in GitHub Desktop.

Select an option

Save schmir/f7a75f1167ecfad51c2d to your computer and use it in GitHub Desktop.

Revisions

  1. schmir created this gist Jun 20, 2014.
    21 changes: 21 additions & 0 deletions user.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    (in-ns 'clojure.core)
    ;; make reloading namespaces work with proxy!

    (defn proxy-name**
    {:tag String}
    [^Class super interfaces]
    (let [inames (into1 (sorted-set) (map #(.getName ^Class %) interfaces))
    ihashes (into1 (sorted-set) (map #(System/identityHashCode %) interfaces))]
    (apply str (.replace (str *ns*) \- \_) ".proxy"
    (interleave (repeat "$")
    (concat
    [(.getName super)]
    (map #(subs % (inc (.lastIndexOf ^String % "."))) inames)
    [(Integer/toHexString (hash ihashes))])))))

    (defn proxy-name
    {:tag String}
    [^Class super interfaces]
    (let [r (proxy-name** super interfaces)]
    (println "using patched proxy-name" [super interfaces] r)
    r))