Clojure will use reflection to find *a* method, but if you want it to pick the correct one from multiple overloads, you need to give clojure type hints so it knows the correct static types of the parameters. At least I think that's how it works.
When I've hit this before, I've just played with type hints until it works. It's one place where type hints have a semantic effect, rather than just being an optimisation. Phil On May 13, 2013 1:25 AM, "Korny Sietsma" <ko...@sietsma.com> wrote: > Hi folks - I met some strange behaviour today using the clj-ssh library - > but it looks like it might not be the library's fault as such. > > If I call (add-identity agent {:private-key-path "foo" :passphrase "bar"}) > the clj-ssh library (eventually) calls a java method: > > (.addIdentity agent "foo" "bar") > > This method has several implementations, including: > public void addIdentity(java.lang.String prvkey, byte[] passphrase); > public void addIdentity(java.lang.String prvkey, java.lang.String > passphrase); > and for some reason this fails with > ClassCastException java.lang.String cannot be cast to [B > > If instead I call: > (add-identity agent {:private-key-path "foo" :passphrase (.getBytes > "bar")}) > then everything works. > > I had thought Clojure would use reflection to find the right addIdentity > call - any idea why it isn't? Or am I misdiagnosing something somewhere? > > - Korny > > -- > Kornelis Sietsma korny at my surname dot com http://korny.info > .fnord { display: none !important; } > > -- > -- > 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/groups/opt_out. > > > -- -- 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/groups/opt_out.