JDK-6558474 : Var args and most specific
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2007-05-17
  • Updated: 2010-04-02
  • Resolved: 2009-03-13
Related Reports
Duplicate :  
Description
Good question.  At the very least javac and the spec don't agree.  I think the compiler is doing what I intended, but I can't see any harm in the specified behavior.  Let's call it a javac bug.

On 12/13/06, ... wrote:
This case is rejected as ambiguous by javac 1.5:
        
        class A {
                 void f(int ... x) {}
                 void f(double ... x) {}
        
                 void g() {
                         f(0);
                 }
        }
        
        We accept it, and my reading of the 15.12.2.5 rules suggest we're
        doing the
        right thing, because the int... is more specific than the double...
        method.
        javac bug, or am I misunderstanding the rules?
        
        (If I take out the "..." on both, the int method is selected, of course, 
        by both javac and our front end.)