The result can be JVM-dependent. I've solved a bug in our codebase that was due to JDK 7's reflection preferring a different constructor for an object than 6, which was fixed by explicitly wrapping the ambiguous argument in (boolean). Whatever the behavior, it's best to not rely on a specific brokenness.
On Tue, Jun 11, 2013 at 10:14 AM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Hi Nathan, > > I just had a quick look at the implementation: I think Clojure picks the > first matching method if several are found. > > > https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L70 > > It's probably worth testing this out though. > > Thanks, > Ambrose > > > On Tue, Jun 11, 2013 at 9:24 PM, N8Dawgrr <nathan.r.matth...@gmail.com>wrote: > >> Hi All, >> >> I have a question regarding ambiguity in reflective dynamic invocation. >> >> In Clojure you can dynamically invoke a method on a Java class like so: >> >> (. some-instance bar arg) >> >> where bar is a method name. >> If the type inferencer can't ascertain the type of some-instance a >> runtime reflective path is used to perform the method invocation. >> Lets suppose some-instance is of type Foo which has two overloads of >> method bar: >> >> bar(Apple arg) >> >> and >> >> bar(Orange arg) >> >> Now lets suppose Apple is an interface which extends Fruit and so is >> Orange. >> >> Now lastly lets suppose we have a class MutantFruit which implements BOTH >> Apple and Orange. >> >> My question is what method is invoked at runtime for the following code: >> >> (. some-instance bar mutant) >> >> where mutant is an instance of MutantFruit >> >> Regards, >> >> Nathan >> >> -- >> -- >> 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. > > > -- -- 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.