Bug 379871

Summary: Compiler fails to parse valid overloaded method call using varargs
Product: [Eclipse Project] JDT Reporter: Erik Johansson <erikj>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: jarthana, satyam.kandula, srikanth_sankaran
Version: 3.8   
Target Milestone: 3.8 M4   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Erik Johansson CLA 2012-05-17 20:34:12 EDT
Build Identifier: 20120216-1857

The Eclipse IDE fails to compile the following test class, which compiles correctly from the command line with javac. I am using a recent Oracle Java version for both the IDE and command line:

java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)

The IDE gives me the following error message:

"The method insert(String, long[]) is ambiguous for the type X"

Here is the test class. By substituting the various types for foo in the method call you will get similar errors. None of these errors occur when compiling from the command line in a shell. I have had to resort to poor workarounds to circumvent this error in my real codes (e.g., using "new long[] {foo_l}" in place of foo_l in the method call).

Thanks for any help you can provide.

Test class:

public class X {

	public void insert(String name, long... values) {}

	public void insert(String name, int... values) {}

	public void insert(String name, double... values) {}

	public void insert(String name, float... values) {}
	
	static void main() {
		
	    X x = new X();
	    
	    long foo_l = 0;
	    int foo_i = 0;
	    double foo_d = 0d;
	    float foo_f = 0f;
	    
	    x.insert("foo", foo_l);
	    
	}

}

Reproducible: Always

Steps to Reproduce:
1.Create a Java project
2.Create a new class X in the project using the code included in the error description.
3. IDE will show an error.
Comment 1 Srikanth Sankaran CLA 2012-05-17 22:22:42 EDT
Same as bug 346038

*** This bug has been marked as a duplicate of bug 346038 ***
Comment 2 Jay Arthanareeswaran CLA 2012-05-29 10:17:02 EDT
Verified for 3.8 RC2 with build I20120524-2100.