1) Your signature has to match your java method, (Foo/bar (byte 1)) will work.
2) There's been a long thread about this. People wanted ints and longs to have a similar behavior and match whatever signature is available when doing interop. When passing (Long. 1), interop tries to match two primitive types, int and long in Java method signatures. It cannot to choose on your behalf between two signatures that match your args, and it warns you consequently. Using an explicit cast (int ...) or (long ...) would solve the issue and direct to the proper method. I did not like this idea of collapsing ints and longs when searching for an interop signature but at least there is a trap to tell you that you have a signature "clash". This behavior has not been extended to bytes and shorts which are rarely used interchangeably with ints and longs. Beware, the above applies to primitive types in method signatures. (Long. 1) is an object so there should be no possible confusion between the Long and Integer classes used in a Java method signature. They would not be considered equivalent candidates. All of the above come from the top of my head but I think it's accurate. Luc P. > 1) > > public class Foo { > public static String bar(byte b) { > return "byte"; > } > } > > user=> (Foo/bar 1) > "byte" > > public class Foo { > public static String bar(byte b) { > return "byte"; > } > > public static String bar(Thread thread) { > return "thread"; > } > } > > user=> (Foo/bar 1) > IllegalArgumentException No matching method found: bar > clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80) > > > Is this a bug or a feature? > > > 2) > > public class Foo { > public static String bar(int i) { > return "int"; > } > > public static String bar(long l) { > return "long"; > } > } > > user=> (Foo/bar 1) > "long" > > user=> (Foo/bar (Long. 1)) > CompilerException java.lang.IllegalArgumentException: More than one > matching method found: bar, compiling:(NO_SOURCE_PATH:3:1) > > user=> (Foo/bar (Integer. 1)) ; Shouldn't this also fail? > "int" > > user=> (def x (Long. 1)) ; same as (def x 1) > #'user/x > > user=> (Foo/bar x) ; a bug? > "int" > > -- > -- > 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. > > > -- Softaddicts<lprefonta...@softaddicts.ca> sent by ibisMail from my ipad! -- -- 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.