Created
May 2, 2014 20:03
-
-
Save brandonbloom/1636c60c176f992cb60c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import '[clojure.lang Reflector]) | |
(defn static-invoke [class member & args] | |
(if (zero? (count args)) | |
(try | |
(Reflector/getStaticField class member) | |
(catch Exception e | |
(Reflector/invokeStaticMethod | |
class member clojure.lang.RT/EMPTY_ARRAY))) | |
(Reflector/invokeStaticMethod class member (object-array args)))) | |
(defn staticfn [class member] | |
(fn [& args] | |
(apply static-invoke class member args))) | |
(deftype Point [x y]) | |
((staticfn (class (Point. 5 10)) "getBasis")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment