I've had one last throw of the dice - a plan to intercept class definition and remember associated bytecode so that my URLClassLoader server could look it up when given the correspondong class name - with no luck :
;; UNFINISHED ;; let's maintain a map of class-name : byte-code (def class-name-to-byte-code (atom [])) ;; lets provide a class loader that wraps an existing one and remembers the byte code that has been used (defn make-class-loader-wrapper [class-loader] (proxy [java.lang.ClassLoader] [] (^Class defineClass [^String class-name ^"[B" byte-code ^Object src-form] (.defineClass class-loader class-name byte-code src-form) (swap! class-name-to-byte-code conj [class-name byte-code]) )))) ;; let's try to wrap-n-replace the existing class loader with our own (alter-var-root clojure.lang.Compiler/LOADER make-class-loader- wrapper) (var-set clojure.lang.Compiler/LOADER (make-class-loader-wrapper @clojure.lang.Compiler/LOADER)) It looks like clojure.lang.Compiler/LOADER has been doctored to stop people like me playing with it :-) - I can't reset it to point to my wrapper - or else I have made a mistake somewhere ? The whole thing is pretty horrible because ClassLoader is a class not an interface and if I could install my wrapper i would actually have to proxy every method - but you get the idea... Aside from messing with Clojure internals, the only remaining way I can see to capture the bytecode of clojure dynamic types on the way in is using some type of AOP with runtime binding around DynamicClassLoader to do my wrapping for me - but this adds a load of deployment complexity to my app that I am not sure I wish to buy into... I was hoping to come up with an elegant solution using e.g. extend- type to override defineClass on DCl... but I ran out of gas. If anyone else can help out I would be very grateful Jules -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en