-
Bug
-
Resolution: Fixed
-
P5
-
5.0, 6u22
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2203535 | 6-pool | Unassigned | P4 | Closed | Won't Fix |
$ 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...).
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...).
- backported by
-
JDK-2203535 Unambiguous varargs method calls flagged as ambiguous
- Closed
- duplicates
-
JDK-6886431 Handling of "most specific" varargs method inconsistent with JLS
- Closed
-
JDK-6998691 Vararg method overloading fails
- Closed
-
JDK-6558474 Var args and most specific
- Closed
- relates to
-
JDK-7042566 Regression: new ambiguity between varargs method
- Closed
-
JDK-7013865 varargs: javac crashes during overload resolution with generic varargs
- Closed
-
JDK-5088429 varargs overloading problem
- Closed
(2 relates to)