| Summary: | [1.6][compiler] Generic method override bug, Eclipse compiles code ok but Sun javac fails with error | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Tobias Gierke <tobias.gierke> | ||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Status: | VERIFIED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | jarthana, Olivier_Thomann, tobias.gierke | ||||
| Version: | 3.6 | ||||||
| Target Milestone: | 3.6 RC1 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 167732 [details]
Demonstrates the bug
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
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.
> 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 ?
Using 3.6M7 should be good enough. 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 ! 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. Verified for 3.6RC1 using build I20100513-1500. |
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