Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6558474

Var args and most specific

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      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.)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ahe Peter Ahe
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: