My guess is the class generated by jnr-ffi can't be inspected with reflection for some reason or other, you should try poking at that sodium instance with http://clojure.github.io/clojure/branch-master/clojure.reflect-api.html in a repl and see what you get!
In terms of "how expensive reflection is" I can help you out quickly there though and say "very". Reflection is very expensive. If it's going to run more than once a minute you should try and avoid reflection. On Thursday, June 30, 2016 at 12:08:34 PM UTC-7, lvh wrote: > > Hi, > > > In my project, caesium, I’m binding against libsodium using jnr-ffi. This > involves creating an Interface with a bunch of methods. This all works > swimmingly, most of the time. > > I have two functions that differ only in their arguments being type > hinted: > > (defn secretbox-easy-to-byte-bufs-nocast! > [^ByteBuffer out ^ByteBuffer msg ^ByteBuffer nonce ^ByteBuffer key] > (.crypto_secretbox_easy sodium out msg (.remaining msg) nonce key) > out) > > (defn secretbox-easy-refl! > [out msg nonce key] > (.crypto_secretbox_easy sodium out msg (.remaining msg) nonce key) > out) > > When calling this function with direct byte buffers (and only with direct > byte buffers!), the call fails. First few lines of traceback: > > actual: java.lang.IllegalArgumentException: No matching method found: > crypto_secretbox_easy for class caesium.binding.Sodium$jnr$ffi$0 > at clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80) > clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28) > caesium.crypto.secretbox$secretbox_easy_refl_BANG_.invokeStatic > (secretbox.clj:85) > > The type hinted version works fine. > > Is this expected behavior, or a bug? I’m trying to measure how expensive > reflection is, and wasn’t expecting this problem. DirectByteBuffer appears > undocumented, but it is a subclass of MappedByteBuffer, implementing > ByteBuffer. > > > lvh -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.