Community
Participate
Working Groups
Build Identifier: I20120531-1500 With the compiler of eclipse 3.7 the following example compiled and the call of the method bar in the following example invoked the second method ( void bar(int intValue, Object... objs) ). The compiler of eclipse 4.2 (RC3) tells me now that the method bar is abiguous. ----------------------------------------------- public class Main { public static void main(String[] args) { bar(5); // Compiler error: The method bar(Object[]) is ambiguous for the type Main } private static void bar(Object... objs) {} private static void bar(int intValue, Object... objs) {} // this method was invoked with the compiler of eclipse 3.7 } ----------------------------------------------- Reproducible: Always Steps to Reproduce: 1. Copy the example of the description into the IDE 2. Look at the compiler errors
Javac8 complains: C:\jtests>C:\jdk-7-fcs-bin-b147-windows-i586-27_jun_2011\jdk7\jdk1.7.0\bin\javac -Xlint:unchecked -Xlint:rawtypes -Xlint:varargs -Xlint:deprecation -sourcepath c:\jtests X.java X.java:4: error: reference to bar is ambiguous, both method bar(Object...) in X and method bar(int,Object...) in X match bar(5); // Compiler error: The method bar(Object[]) is ambiguous for the type Main ^ 1 error //-------------- I believe this is the intended behavior and eclipse behavior change was in response to javac change. I'll dig up the original bug report shortly.
Srikanth, do we want to include this case too under the system property being worked on in bug 383780? (The patch there doesn't fix this issue)
(In reply to comment #2) > Srikanth, do we want to include this case too under the system property being > worked on in bug 383780? (The patch there doesn't fix this issue) After due analysis and confirming that this is the same case - yes, please.
Use -DtolerateIllegalAmbiguousVarargsInvocation = true to get this code compiled with 4.3/Juno SR1 once bug 383780 is fixed. *** This bug has been marked as a duplicate of bug 383780 ***
Verified that the patch proposed at bug 383780 addresses the present problem.
Verified for 3.8.1 using Build id: M20120809-1000