FULL PRODUCT VERSION :
1.6.0_01
ADDITIONAL OS VERSION INFORMATION :
Tested on Windows. The bug applies to all OSes
A DESCRIPTION OF THE PROBLEM :
In the following code, the two methods getTopAreaTwo are allowed in the DoubleVarargs. The compiler obviously complains that the CallDoubleVarargs .callDoubleVarargs(....) cannot be invoked as there is an ambiguous invocation.
public class DoubleVarargs {
public Long getTopAreaTwo(Long... argument) {
assert argument.length == 2;
return argument[0].longValue()*argument[1].longValue();
}
public Long getTopAreaTwo(Long arg1, Long... argument) {
assert argument.length == 1;
return arg1.longValue()*argument[0].longValue();
}
}
public class CallDoubleVarargs {
void callDoubleVarargs() {
DoubleVarargs doubleVarargs = new DoubleVarargs();
long one = 1;long two = 2;
long three = 3;
long four = 4;
long five = 5;
doubleVarargs.getTopAreaTwo(one, two, three, four, five);
}
}
Why is this a problem?
When you are trying to use reflection to find a method match you have to do extra work to account for the fact that ambiguous invocation is possible.
Please refer to http://datasaas.blogspot.com/2007/05/simplified-reflection.html
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code in the description.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiler should prevent defining ambiguous methods.
REPRODUCIBILITY :
This bug can be reproduced always.
1.6.0_01
ADDITIONAL OS VERSION INFORMATION :
Tested on Windows. The bug applies to all OSes
A DESCRIPTION OF THE PROBLEM :
In the following code, the two methods getTopAreaTwo are allowed in the DoubleVarargs. The compiler obviously complains that the CallDoubleVarargs .callDoubleVarargs(....) cannot be invoked as there is an ambiguous invocation.
public class DoubleVarargs {
public Long getTopAreaTwo(Long... argument) {
assert argument.length == 2;
return argument[0].longValue()*argument[1].longValue();
}
public Long getTopAreaTwo(Long arg1, Long... argument) {
assert argument.length == 1;
return arg1.longValue()*argument[0].longValue();
}
}
public class CallDoubleVarargs {
void callDoubleVarargs() {
DoubleVarargs doubleVarargs = new DoubleVarargs();
long one = 1;long two = 2;
long three = 3;
long four = 4;
long five = 5;
doubleVarargs.getTopAreaTwo(one, two, three, four, five);
}
}
Why is this a problem?
When you are trying to use reflection to find a method match you have to do extra work to account for the fact that ambiguous invocation is possible.
Please refer to http://datasaas.blogspot.com/2007/05/simplified-reflection.html
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code in the description.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiler should prevent defining ambiguous methods.
REPRODUCIBILITY :
This bug can be reproduced always.