Bug 128560 - [compiler] Java 1.4 compiler (UI?) incorrectly reports incompatible return type
Summary: [compiler] Java 1.4 compiler (UI?) incorrectly reports incompatible return type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 18:23 EST by Nathan Beyer CLA
Modified: 2006-03-27 08:57 EST (History)
0 users

See Also:


Attachments
Zip file containing two projects to demonstrate this issue. (4.50 KB, application/zip)
2006-02-19 18:26 EST, Nathan Beyer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Beyer CLA 2006-02-19 18:23:17 EST
I'm not sure if this is an issue with the JDT compiler or the UI.

I have a Java class that implements an interface and a method on that interface. The method signature is modified such that the return type is the type of the class rather than the type of the interface.

When the project is configured with Java 1.4 compliance (Java 1.4 .class files, Java 1.4 source), the methods are marked with errors that say: "The return type is incompatible with Appendable.append(char)". When the project is configured with Java 5.0 compliance (Java 1.4 .class files, Java 1.4 source), the class compiles fine. In both cases, the JRE libraries are from a Java 5 distribution (I've used both a Sun JRE and a BEA JRE).

My assumption is that since I'm setting the ".class file compliance" and "source file compliance" to "1.4", they should work the same.

I've tested this in 3.1.2, 3.2M4 and 3.2M5 and they all report the same results.

I looked for related bugs and I think this may be related to bug 105808, bug 81535 and bug 58715.

Example:
public class StringAppender implements Appendable {
    public StringAppender append(char c) {
        return null;
    }
    //snip
}

public interface Appendable { //from java.lang
    public Appendable append(char c);
    //snip
}
Comment 1 Nathan Beyer CLA 2006-02-19 18:26:37 EST
Created attachment 34977 [details]
Zip file containing two projects to demonstrate this issue.

This ZIP contains two Java Projects that demonstrate this issue. These were created on Eclipse 3.2M5 with a default JRE that's Java 5 compliant.

appender-java1_4 - This is the project with the Java 1.4 compliance setting that shows compile errors.
appender-java5 - This is the project (same code) with the Java 5.0 compliance setting that compiles fine.
Comment 2 Philipe Mulet CLA 2006-02-20 04:35:43 EST
Bug 81535 is the related one. Its fix was wrong, covariance should require -source 1.5 or better; independantly from compliance, as you correctly observed.

In fact, bug 81535 was a consequence of ignoring bridge methods; which got resolved since then; see bug 124943.
Comment 3 Philipe Mulet CLA 2006-02-20 04:36:59 EST
Change allocation of MethodVerifier15 to be conditionned on source level strictly (instead of compliance level).

Comment 4 Philipe Mulet CLA 2006-02-20 04:37:20 EST
Fixed. Added MethodVerifierTest#test078.
Comment 5 David Audel CLA 2006-03-27 08:57:34 EST
Verified for 3.2 M6 using build I20060327-0010