title: In Java and using Bridj, how can you dynamically invoke any native function?
body: <p>Often users of Clojure wish to be as lazy as possible, and delay the creation of classes and objects. In that same spirit, if I wish to invoke a native function which is resolved during runtime from within Java, I can use <code>com.sun.jna.Function.getFunction("foolibrary", "foofuncname")</code>, which returns a <code>com.sun.jna.Function</code>, which can be <code>invoked</code>.</p>
  
  <p>In Clojure this looks like:</p>
  
  <pre><code>(let [f (com.sun.jna.Function/getFunction "c" "printf")]
    (.invoke f Integer (to-array ["Hello World"])))
  </code></pre>
  
  <p>BridJ, on the other hand, offers an attractive performance benefit and claimed simplier API, however, it is still not clear to me how to use BridJ to do something similar to the runtime binding JNA example. Can someone demonstrate how? Also, if this is possible, are there any performance penalties with this approach? Otherwise, it appears generating the Java source file ahead of time is the only solution. I would appreciate it if someone could confirm this.</p>