Bug 209429 - [compiler] Compiler reports unhandled exception even though there is no exception being thrown
Summary: [compiler] Compiler reports unhandled exception even though there is no excep...
Status: VERIFIED DUPLICATE of bug 79798
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-11 13:33 EST by shibin CLA
Modified: 2008-04-29 07:31 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shibin CLA 2007-11-11 13:33:43 EST
Build ID: N20071111-0010

Steps To Reproduce:

The code sample is taken from Java Puzzlers problem 37.
Expected Result: The code should compile fine
Actual Result: ecj reports unhandled exception 

code
----

interface Type1 {
    void f() throws CloneNotSupportedException;
}

interface Type2 {
    void f() throws InterruptedException;
}

interface Type3 extends Type1, Type2 {}


public class Arcane3 implements Type3 {
    public void f() {
        System.out.println("Hello world");
    }
    public static void main(String[] args) {
        Type3 t3 = new Arcane3();
        t3.f();
    }
}

problem
-------
The method f in interface Type3 doesn't throw any exception  so main method needn't handle any exception, but eclipse requires CloneNotSupportedException to be handled.
  
Quoting from the book
"The set of checked exceptions that a method can throw is the intersection of the sets of checked exceptions that it is declared to throw in all applicable types, not the union. As a result, the f method on an object whose static type is Type3 can't throw any checked exceptions at all. Therefore, Arcane3 compiles without error and prints Hello world." 

More information:
Comment 1 Philipe Mulet CLA 2007-11-12 03:20:06 EST
Indeed, we should be intersecting exception types.
Comment 2 Kent Johnson CLA 2008-03-27 15:44:12 EDT
seems the same as bug 79798 
Comment 3 Kent Johnson CLA 2008-04-23 14:03:57 EDT
Fixed with the same change as bug 79798

*** This bug has been marked as a duplicate of bug 79798 ***
Comment 4 David Audel CLA 2008-04-29 07:31:30 EDT
Verified for 3.4M7 using I20080427-2000