Often Clojure users want to be as lazy as possible and delay the creation of classes and objects. In the same vein, if I want to call a built-in function that is allowed at runtime from Java, I can use com.sun.jna.Function.getFunction("foolibrary", "foofuncname")which returns com.sun.jna.Function, which may be invoked.
In Clojure, it looks like this:
(let [f (com.sun.jna.Function/getFunction "c" "printf")]
(.invoke f Integer (to-array ["Hello World"])))
BridJ, on the other hand, offers an attractive performance advantage and requires a simplified API, but itโs not yet clear to me how to use BridJ to do something similar to the JNA implementation example. Can anyone demonstrate how? Also, if possible, are there any performance penalties with this approach? Otherwise, it seems that generating the Java source file ahead of time is the only solution. I would appreciate it if someone could confirm this.
source
share