-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
generic
-
generic
Rob [...] has discovered something that Neal and I believe to be a javac bug. Consider this program:
public class Foo {
public static void main(String[] args) {
Bar bar = new Bar();
bar.add("Hello");
bar.add("Hello, world", "Buddy");
}
}
class Bar {
public void add(String... ss) {
System.out.println("Array");
}
private void add(String s) {
System.out.println("Element");
}
}
In javac (1.5 and 1.6) it won't compile, but generates this error message:
Foo.java:4: add(java.lang.String) has private access in Bar
bar.add("Hello");
^
1 error
In Eclipse, it compiles.
Looking in JLS 3, we see that the compiler should first look for applicable methods w/o boxing unboxing, or varargs. It should find non, and go on to phases two and three. It should find the varargs method in phase three, but it never gets there. If you agree with this analysis, please file a bug report. If not, please tell us where we goofed.
Thanks,
Josh (and Neal)
public class Foo {
public static void main(String[] args) {
Bar bar = new Bar();
bar.add("Hello");
bar.add("Hello, world", "Buddy");
}
}
class Bar {
public void add(String... ss) {
System.out.println("Array");
}
private void add(String s) {
System.out.println("Element");
}
}
In javac (1.5 and 1.6) it won't compile, but generates this error message:
Foo.java:4: add(java.lang.String) has private access in Bar
bar.add("Hello");
^
1 error
In Eclipse, it compiles.
Looking in JLS 3, we see that the compiler should first look for applicable methods w/o boxing unboxing, or varargs. It should find non, and go on to phases two and three. It should find the varargs method in phase three, but it never gets there. If you agree with this analysis, please file a bug report. If not, please tell us where we goofed.
Thanks,
Josh (and Neal)
- duplicates
-
JDK-6746184 javac fails to compile call to public varargs method
- Closed