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

Unambiguous varargs method calls flagged as ambiguous

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      5.0
    • Introduced In Version:
      5.0
    • Resolved In Build:
      b123
    • CPU:
      generic, x86
    • OS:
      generic, linux_suse_sles_9
    • Verification:
      Verified

      Backports

        Description

        $ cat -n Test.java
             1 class Test {
             2 public static void foo(int ...i) {}
             3 public static void foo(double...d) {}
             4
             5 public static void main(String[] args) {
             6 foo(1, 2, 3);
             7 }
             8 }
             9
        $ javac Test.java
        Test.java:6: reference to foo is ambiguous, both method foo(int...) in Test and method foo(double...) in Test match
                foo(1, 2, 3);
                ^
        1 error

        Javac is incorrect since int <: double which makes foo(int...) more specific than foo(double...).

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mcimadamore Maurizio Cimadamore
                  Reporter:
                  ahe Peter Ahe
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: