On Sep 4, 2009, at 4:47 AM, Charles Lee <littlee1...@gmail.com> wrote:

On Fri, Sep 4, 2009 at 5:07 PM, Tim Ellison <t.p.elli...@gmail.com> wrote:

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.


Sorry. I am asking for opinion :-)



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.


Order is mater because the logic of findMethod in XMLDecoder. As the
example, method 3 has the smallest distance. If the order is (4, 1, 2, 3), findMethod will find 4 and 2 has the same distance then throw an exception. But if the order is (1, 2, 3, 4), method 3 appears before method 4, no exception thrown and findMethod find method 3. I suggest this method should be order free. I will fix this if I know which situation should be correct.


What does the JavaBeans spec say? It would seem odd that the order of the result would matter. Is the order of the result of findMethods even guaranteed or defined?

-Nathan



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





--
Yours sincerely,
Charles Lee

Reply via email to