This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197972 - Covariant return type override bug not reported
Summary: Covariant return type override bug not reported
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 6.x
Hardware: Macintosh (x86) Mac OS X
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 23:20 UTC by arg
Modified: 2011-04-22 15:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arg 2011-04-21 23:20:31 UTC
There's a Java bug "Problem with interfaces and covariant return type overriding", see: http://bugs.sun.com/view_bug.do?bug_id=6656332

I extended their sample a little, see below.  I'm using JDK 1.6.0 (apparently this bug is fixed in 1.7).  No error is indicated in the edit window.  If you clean and build, you do get a compile error, as expected.  The curious thing is that if you run, the code executes fine without any error messages.

public class NewClass {

    // see http://bugs.sun.com/view_bug.do?bug_id=6656332
    interface A {
        A m();
    }

    interface B extends A {
        B m();
    }

    interface C extends A {
        C m();
    }

    interface D extends B,C {
        D m();
    }

    public class X implements D {

        public D m() {
            return new X();
        }

        public String method() {
            return "HELLO";
        }
    }

    public X getX() {
        return (X) new X().m();
    }

    public static void main(String[] args) {
        NewClass nc = new NewClass();
        System.out.println("TEST " + nc.getX().method());
    }
}
Comment 1 Dusan Balek 2011-04-22 15:27:58 UTC
You probably have "Compile On Save" on. Your source gets compiled by the NB internal compiler (which is based on 7.0 javac) and the compiled class is executed.