Thank you Henry.
I had read a few posts similar to that
thread entry, nonetheless, they don't discuss at what point "method conversion" rules are kicked in and at what juncture "most specific" rules are applied (
http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2.1). And that's exactly what I was referring to; a very undeterministic methodology to confidently state that an invocation calls this particular overloaded method.
Does boxing/widening always precede vararg of supertype, i.e. doSomething(
Object) wins over doSomething(
long...) when doSomething(
20) is called?
And if we have doSomething(
new Integer(20)), and overloaded methods of doSomething(
Long) and doSomething(
long...), I understand why the former is discarded (widening and boxing is not allowed), but why does doSomething(
long...) is called? Does the procedure, first
unbox new Integer(20), then widens to select doSomething(
long...)?
But if that's the case, when we add doSomething(
Object) to the mix [of doSomething(
Long) and doSomething(
long...)], the same call (doSomething(
new Integer(20))) result in doSomething(
Object) to be called! So, is my previous assumption of "
unboxing then widening" inaccurate?
Henry Wong wrote:
The topic tries to figure out rules based on what behavior is seen, and not based on what the JLS says, and quite frankly, when stuff is up for interpretation, it may change from release to release, and version to version.
Argh! That's what I was afraid of too.