Am 09.06.2011 20:04, schrieb Alexander Turner:
Alessio,

You are technically correct. Nevertheless, autoboxing makes the
situation more complex. By autoboxing, one is saying that int is
equivalent in a parameter to Integer. Now Integer is a sub-type of
Object. Therefore int is more specific than Object.

if int were equivalent to Integer, then you would no longer be able to overload using int and Integer as the only difference. But this is not the case, so you have the problem to have to see int as some kind of subtype of Integer, on the other hand Integer can sometimes be kind of seen as subtype of int... and the reality is that there is no subtype relationship at all, and also not equivalent. I think the multipass approach fits most (WARNING: this is a modell, not a compiler implementation).

public void x(String a, int b, Object... c) { ... }
public void x(String a, Object... c) { ... }
x("a", 1, new Object());

using that code in the first pass, the second method is simply none of the applicable methods, since int is not Object. If the first method is not there, then a second pass would be done with int boxed and then we have a fitting method. For this approach you don't need anything in terms of subtype relationship, it is more like widening to some extend.

This does not hold for the earlier versions of Java, but the later
ones with autoboxing start to build this type of equivalence into the
language at user level if not at a formal specification level.

it is bluring the differences, yes, but as language implementor that has to deal with Java I know they are still there and big.

This type of issue (I would suggest) is a consequence of Java maturing
as a language. It is almost impossible for a language to mature
without some parts of its specification becoming case-law instead of
statute.

If they had defined int as subtype of Integer this would surely be a less complicated case, yes.

bye Jochen

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead
http://blackdragsview.blogspot.com/
For Groovy programming sources visit http://groovy.codehaus.org

--
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to