Sherry's right, of course, there are too many m() methods that have signatures matching your parameters, but I want to explain a little more about why they are considered to be ambiguous. (I'm a little new at this, so someone please correct me if I'm wrong.)
Let's use a modified example of your code, with simpler method identifiers:
Trying to compile this code will give you the error "The method m(A, A) is ambiguous for the type C".
When the compiler is stepping through its method resolution process, it determines which methods may apply based on the signature. In this case, that means all 5 m() methods. Next, if it finds that there is more than one applicable signature, it tries to determine which method is most specific based on the following general rule:
"The informal intuition is that one method declaration is more specific than another if any invocation handled by the first method could be passed on to the other one without a compile-time type error." In your case, you have two methods that are "equally" specific. We can toss out methods m(A,A) and m(A,B) because they both can be converted into (via method invocation conversion) by the other three. m(B,A) is also less specific because m(B,B) can be converted into it. I.e.,
m(B,A); m(B,B); m(A,C) can all be converted to m(A,A), thus making them more specific
m(B,B); m(A,C); can both be converted to m(A,B), thus making them more specific
m(B,B); can be coverted to m(A,B)
However, the specificity rules stop there. m(B,A) and m(A,C) can't be converted into each other. They are, in essence, "equally" specific, so the compiler can't decide which one to pick!
What can solve this is a new overloaded method:
m(B,C) can be converted up the chain to any of the previous 5 m() methods, including our two problem methods, m(B,A) and m(A,C), so it is more specific than all of them. Thus, that would be the one the compiler could pick.
For more on this, look at the JLS, specifically section 15.12.2.2, "Choose the Most Specific Method":
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#20448 EDIT: Added link, corrected spelling
[ August 22, 2005: Message edited by: Ryan Kade ]