Bug 379871 - Compiler fails to parse valid overloaded method call using varargs
Summary: Compiler fails to parse valid overloaded method call using varargs
Status: VERIFIED DUPLICATE of bug 346038
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.8 M4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-17 20:34 EDT by Erik Johansson CLA
Modified: 2012-05-29 10:17 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.