Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369592 - Compiler erroneously reports "Method is ambigious for type"
Summary: Compiler erroneously reports "Method is ambigious for type"
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Sasikanth Bharadwaj CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-24 15:14 EST by Christopher Schultz CLA
Modified: 2019-12-26 15:30 EST (History)
3 users (show)

See Also:


Attachments
Source file which demonstrates this problem. (1.41 KB, application/octet-stream)
2012-01-24 15:16 EST, Christopher Schultz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Schultz CLA 2012-01-24 15:14:28 EST
Build Identifier: Indigo SR1 20110916-0149

Here is a single source file which has been modified from a project that compiles cleanly using:

java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

Eclipse flags an error on line 39 (the line containing "super.call()") saying that the call is ambiguous:

super.call(context, functionName, args);

'context' is a String, 'functionName' is a String, and 'args' is an Object[].

The compiler has two choices for methods this could match:

        public Object call(String context,
                           String functionName,
                           Object[] args)

        protected abstract Object call(String context,
                                       Object lvalue,
                                       Object rvalue)

The correct match is the one with the more-specific types (String,String,Object[]) and Eclipse says that call(String,Object,Object) is ambiguous.


Reproducible: Always

Steps to Reproduce:
Dump the attached file into an Eclipse project.

This project has had its compiler compliance level set to "1.3".
Comment 1 Christopher Schultz CLA 2012-01-24 15:16:16 EST
Created attachment 210007 [details]
Source file which demonstrates this problem.
Comment 2 Srikanth Sankaran CLA 2012-01-24 16:21:20 EST
Shorter test case:

//------------

public class X {
	void f(String name, Object[] args) {
	}

	void f(Object l, Object r) {
	}

	public static class Y extends X {
		void f(Object l, Object r) {
		}
	}

	public static class Z extends Y {
		void f(String name, Object[] args) {
			super.f(name, args);
		}
	}
}
//----------------------

Compiles fine under 1.4+ modes, but not in 1.3 compliance.
It has been this way for some time.

javac -source 1.3 accepts this.

I'll take a look.
Comment 3 Christopher Schultz CLA 2012-04-09 13:42:07 EDT
It's obviously not marked as FIXED, so this should come as no shock:

Still observing this in 1.4.2.20120213-0813 after an update. :(
Comment 4 Doug P. CLA 2012-10-18 14:27:19 EDT
Any update? This blocks people from going to indigo.
Comment 5 Srikanth Sankaran CLA 2012-10-19 01:43:51 EDT
(In reply to comment #4)
> Any update? This blocks people from going to indigo.

Are you sure you are hitting this very same bug ? Per comment#2, this affects
only 1.3 mode - Are you on 1.3 ?
Comment 6 Christopher Schultz CLA 2012-10-19 09:37:33 EDT
Just an update: still observable in:

Version: Juno Release
Build id: 20120614-1722
Comment 7 Christopher Schultz CLA 2012-10-19 09:45:07 EDT
Updated to note the latest affected release: 4.2.1.

Just updated to:

Version: Juno Service Release 1
Build id: 20121004-1855

Compiler still gives the same error.
Comment 8 Srikanth Sankaran CLA 2014-11-03 21:50:15 EST
Sorry, have been too busy with Java 8 work in the last couple of years.
Sasi, please take it forward.
Comment 9 Michael Giroux CLA 2015-12-30 13:32:20 EST
Just tried to build Jenkins Git-plugin (https://github.com/jenkinsci/git-plugin.git) and got this error.

Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200

JDK I've tried several.

Seems a shame this defect has been outstanding going on 4 years, and there is a popular open source project (jenkins git-plugin) that experiences this issue.

I would vote to escalate this issue.

FOR WHAT ITS WORTH, the git-plugin builds without error when built from command line using maven.
Comment 10 Sasikanth Bharadwaj CLA 2015-12-31 01:06:29 EST
(In reply to comment #9)
> Just tried to build Jenkins Git-plugin
> (https://github.com/jenkinsci/git-plugin.git) and got this error.
> 
> Version: Mars.1 Release (4.5.1)
> Build id: 20150924-1200
> 
> JDK I've tried several.
> 
> Seems a shame this defect has been outstanding going on 4 years, and there is a
> popular open source project (jenkins git-plugin) that experiences this issue.
> 
> I would vote to escalate this issue.
> 
> FOR WHAT ITS WORTH, the git-plugin builds without error when built from command
> line using maven.
I suspect if it's the same bug you are running into because this is seen only at 1.3 compliance and I saw 1.5 in the pom.xml for the jenkins git plugin. If you can give me instructions how to build the project to see the issue, we can sort it out. It's probably a misconfiguration of the eclipse compiler that leads it to believe the target is 1.3 where as you want to build it for 1.5
Comment 11 Michael Giroux CLA 2015-12-31 09:43:07 EST
I did nothing special, clone the repo and import the project to eclipse.

1. in the eclipse git repository view, clone the project (https://github.com/jenkinsci/git-plugin.git)
2. after the clone is complete, select the new repository in the Git Repositories view, right-click and select the "import maven projects..." menu
3. after the import is complete (it took several minutes on my system) right-click the project in the package explorer (or whatever view you prefer) and click the maven->update project menu.
4. when the update is complete, and the automatic project build completes, you will see two errors in the problems view on the /git/src/test/java/hudson/plugins/git/GitSCMTest.java module.

I made NO source changes.

Open a terminal window, cd to the project and 'mvn compile' will report no errors.


NOTE, as in the original report, my system is mac os x.  I'm not sure if this issue exists in the Windows version of eclipse.
Comment 12 Michael Giroux CLA 2015-12-31 12:57:47 EST
I'm also getting the error on my Windows box, so it is unrelated to Mac OS X.
Comment 13 Sasikanth Bharadwaj CLA 2016-01-01 04:09:07 EST
Thanks for the steps Michael. I was able to reproduce the error and filed bug 485066 to track this issue as it is a totally different one from what's mentioned here.
Comment 14 Eclipse Genie CLA 2019-12-26 15:30:44 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.