Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 428071

Summary: [1.8][compiler] Bogus error about incompatible return type during override
Product: [Eclipse Project] JDT Reporter: Mathieu Croizard <mcr>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, srikanth_sankaran, stephan.herrmann
Version: 4.3.1   
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mathieu Croizard CLA 2014-02-13 03:40:53 EST
Hello, I have an error from the compiler while compiling this code: 

K1.java :
import java.util.List;
import java.util.Map;
 
public interface K1 {
	public Map<String,List> get();
}

K.java
import java.util.List;
import java.util.Map;


public class K implements K1
{
	@Override
	public Map<String, List> get() {
		return null;
	}
}
"The return type is incompatible with K1.get()"

Why do i have this error, as the signature are the same?
When i put List<?> in both the interface and the class, this work properly. Is the wildcard mandatory?

I am using 1.0.0.v20140213-0104_BETA_JAVA8 Eclipse Java Development Tools Patch for Java 8 Support (BETA), Eclipse Plugin-in Development Environment Patch for Java 8 Support (BETA), Eclipse RCP Patch for Java 8 Support (BETA)

Thanks!
Comment 1 Srikanth Sankaran CLA 2014-02-13 03:49:46 EST
Thanks, will take a look.
Comment 2 Srikanth Sankaran CLA 2014-02-13 04:17:03 EST
Not reproducible in junit, but is reproducible in IDE. Interesting. Under
investigation.
Comment 3 Srikanth Sankaran CLA 2014-02-13 04:21:06 EST
Actually, even in IDE, clean + build does not show the problem, while
incremental build does.
Comment 4 Srikanth Sankaran CLA 2014-02-13 06:21:28 EST
Mathieu - Thank you !

This is such a nasty bug that is truly worth getting rid of before GA.

Basically, there was a race condition in the type system abstraction as a result
of which we end up with two java.util.List's - you can imagine the resultant
chaos from there on.

Stephan, I wonder if the problems we saw with the compiler complaining about
identical types not being compatible go away with this patch or if that is some
other beast altogether.

Fix is simple. Rearrange a couple of lines of code to prevent the race and ensure
identity of types.

Fix and tests here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=0174bc81f7d2de8d27eebb7df04fb04a776d1f62
Comment 5 Jay Arthanareeswaran CLA 2014-02-21 05:07:07 EST
Verified for Java 8 RC1 using Kepler SR2 +  
Eclipse Java Development Tools Patch for Java 8 Support (BETA)   
1.0.0.v20140220-2054