Access Java fields dynamically in Clojure?

Viewed 1615

I'm a novice in clojure and java.

In order to access a Java field in Clojure you can do:

Classname/staticField

which is just the same as

(. Classname staticField)

(correct me if I'm wrong)

How can I access a static field when the name of the field in held within a variable? i.e.:

(let [key-stroke 'VK_L
      key-event KeyEvent/key-stroke])

I want key-stroke to be evaluated into the symbol VK_L before it tries to access the field.

4 Answers
Related