On 04/Sep/2009 08:26, Charles Lee wrote: > Thanks Regis. > > The testcase will *pass* on ri and harmony+vme. But failed on harmony+drlvm. > The reason cause this difference is due to differenct order returned by the > Class.getMethods. > It seems findMethod in XMLDecoder shoud fix this problem, because it should > be order free. > > Also I use "*" around the word "pass" when I mentioned result using harmony > + vme. It is a fake pass. The exception it throw is "Cannot decide which > method to call to match get" due to the specific method order it get. The > senario as follows: > > Class A has four method: > 1. test(int, String) > 2. test(Integer, Object) > 3. test(Object, String) > 4. test(String, Object) > > I want to invoke the test with arg null and "aaa", that is > method.invoke(null, "aaa"). Which method should be invoked? > RI: NoSuchMethodException > vme: (mothed order is 4, 1, 2, 3), "Cannot decide which method to call to > match get", because method 4 and method 2 has the same distance. > drlvm: (mothd order is 1, 2, 3, 4), method 3 is invoked because it has the > smallest distance. > > My question is: which method should be invoked?
Is this a quiz, or are you asking for an opinion? I would hope that the correct answer could be determined from the Beans spec, otherwise we should follow the RI's behavior. I would guess 3, since null is a valid actual parameter for an Object formal parameter (and an int is not) and String matches exactly. I don't think the order should matter. However, I'm not so familiar with the spec to say whether my 'logical answer' is the one the spec would give you. Regards, Tim
