Skip to content

Instantly share code, notes, and snippets.

@mccraigmccraig
Created June 12, 2009 11:00
Show Gist options
  • Save mccraigmccraig/128577 to your computer and use it in GitHub Desktop.
Save mccraigmccraig/128577 to your computer and use it in GitHub Desktop.
clojure/java : make java private data public
(def state-field (first (filter #(= "state" (.getName %)) (seq (.getDeclaredFields (java.lang.Class/forName "clojure.lang.Agent"))))))
(.setAccessible state-field true)
(def foo (agent 1))
(.set state-field foo 5)
user=> @foo
5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment