Community
Participate
Working Groups
The following should compile: class Test implements IClass{ Test(IClass c, Test t, IType... args) {} Test(IClass c, IType... args) {} public static void main(String args[]) { IClass c = null; Test t = null; Test t2 = new Test(c, t); } } interface IType{} interface IClass extends IType{} Eclipse incorrectly calls the method constructor invocation as ambiguous. Both constructors are applicable. So is the first constructor more specific than the second constructor? According to the rules of JLS3 in the middle of page 448: The first constructor has n=3 parameters & the second constructor has k=2 parameters. This is the first set of rules for n >= k. For all j from 1 to k - 1 (1): Tj <: Uj That gives: IClass <: IClass Then, For all j from k (2) to n, Tj <: Uk That gives: Test <: IType and : IType <: IType Note that the element types of the array (vararg) parameters are used in the comparison, not the array type itself. Note also that javac has this same bug. See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5088429
*** Bug 106866 has been marked as a duplicate of this bug. ***
Waiting to see if the spec is clarified and/or javac's behaviour changes.
Same as bug 346039 *** This bug has been marked as a duplicate of bug 346039 ***