Bug 312280 - [1.6][compiler] Generic method override bug, Eclipse compiles code ok but Sun javac fails with error
Summary: [1.6][compiler] Generic method override bug, Eclipse compiles code ok but Sun...
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-10 11:34 EDT by Tobias Gierke CLA
Modified: 2010-05-17 03:28 EDT (History)
3 users (show)

See Also:


Attachments
Demonstrates the bug (1.74 KB, application/x-compressed-tar)
2010-05-10 11:35 EDT, Tobias Gierke CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Gierke CLA 2010-05-10 11:34:31 EDT
Build Identifier: 20100218-1602

The following code compiles using Eclipse 3.5.2 but fails with Javac 1.6.20:

public interface SomeInterface {
	public Vector<String> getStuff();
}

public class BaseClass implements SomeInterface {

	@Override
	public Vector getStuff() {
		return new Vector();
	}
}

public class SubClass extends BaseClass {

	@Override
	public Vector<? extends String> getStuff() {
		return super.getStuff();
	}
}



Reproducible: Always

Steps to Reproduce:
1. Open attached project in Eclipse , compiles (with warnings)
2. Try to compile the same classes using javac 1.6.20 on the command-line => failure
Comment 1 Tobias Gierke CLA 2010-05-10 11:35:23 EDT
Created attachment 167732 [details]
Demonstrates the bug
Comment 2 Tobias Gierke CLA 2010-05-10 11:37:15 EDT
Sorry, forgot the javac output:


> javac -d target src/*.java
src/SubClass.java:6: getStuff() in SubClass cannot implement getStuff() in SomeInterface; attempting to use incompatible return type
found   : java.util.Vector<? extends java.lang.String>
required: java.util.Vector<java.lang.String>
        public Vector<? extends String> getStuff() {
                                        ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Comment 3 Olivier Thomann CLA 2010-05-10 11:49:36 EDT
Using HEAD contents in 1.6 mode I get:
[compiled 24 lines in 562 ms: 42.7 lines/s]
[2 .class files generated]
----------
1. ERROR in D:\tests_sources\SubClass.java (at line 6)
	public Vector<? extends String> getStuff() {
	       ^^^^^^^^^^^^^^^^^^^^^^^^
The return type is incompatible with SomeInterface.getStuff()
----------
1 problem (1 error)

which seems to be consistent with javac.

Srikanth, could you please double-check this case?
Thanks.

Tobias, please use a newer version of the compiler.
Comment 4 Tobias Gierke CLA 2010-05-10 14:39:06 EDT
> Tobias, please use a newer version of the compiler.

Since I'm already using the latest Eclipse version, do you want me to try the compiler from HEAD ? Is there an update site where I can get the binaries or do I need to compile it myself ?
Comment 5 Olivier Thomann CLA 2010-05-10 14:50:36 EDT
Using 3.6M7 should be good enough.
Comment 6 Tobias Gierke CLA 2010-05-10 15:12:01 EDT
Stupid me, didn't think of the milestone releases :) The code does not compile with Eclipse 3.6M7 and the error message is correct.

Thanks for your quick response !
Comment 7 Srikanth Sankaran CLA 2010-05-11 06:37:08 EDT
While this is not a duplicate of bug# 302358 the fix for
that bug also addresses this issue and hence the behavior
3.6 M6+ is correct and matches javac.
Comment 8 Jay Arthanareeswaran CLA 2010-05-17 03:28:44 EDT
Verified for 3.6RC1 using build I20100513-1500.