Bug 84743 - [1.5][compiler] Cast between two interfaces doesn't need to check compatibility of method return types
Summary: [1.5][compiler] Cast between two interfaces doesn't need to check compatibili...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-08 16:53 EST by Olivier Thomann CLA
Modified: 2005-02-16 09:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-02-08 16:53:11 EST
In 1.5, the following code should compile:

interface I {
   int foo();
}
interface J {
   String foo();
}
 
public class X implements I {
   public int foo() {
 	return 0;
   }
   public static void main(String[] args) {
         I i = new X();
        J j = (J) i;
        System.out.println(j);
  }
}

It will throw a ClassCastException at runtime.

In 1.4, the code would have failed at compile time.
Comment 1 Olivier Thomann CLA 2005-02-08 16:53:56 EST
Same result with == and != operators.
Comment 2 Philipe Mulet CLA 2005-02-10 09:12:58 EST
Added GenericTypeTest#test498. Also tuned CastTest to add nuance based on
compliance level.

Fixed
Comment 3 David Audel CLA 2005-02-16 09:01:41 EST
Verified in I20050215-2300