I can't figure out how to avoid reflection, in the 'update' method of
MessageDigest.  It is overloaded on a single argument with either
'byte', 'byte[]', or 'java.nio.ByteBuffer'.

   (import '(java.security MessageDigest))
   (set! *warn-on-reflection* true)

The compiler didn't seem to like a tag that wasn't actually a class
name:

   (def byte-array-class
     (class (make-array Byte/TYPE 0)))

   ;; "Unable to resolve classname: byte-array-class"
   (defn update1
     [#^MessageDigest md #^{:tag byte-array-class} item]
     (.update md item))

And it seems to have no effect if I expand it as the tag:

   ;; "call to update can't be resolved."
   (defn update2
     [#^MessageDigest md #^{:tag (class (make-array Byte/TYPE 0))} item]
     (.update md item))

In this particular case, I was able to work around the issue one of
two ways, basically by using a different type.

   (defn workaround
     [#^MessageDigest md item]
     (.update md item 0 (count item)))

   (defn workaround2
     [#^MessageDigest md item]
     (.update md (java.nio.ByteBuffer/wrap item)))

Any ideas?  BTW, my real use case is in a defmethod, where I handle
several other types for the update.

Thanks,
David

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to