Community
Participate
Working Groups
// Puzzle 37 from "Java Puzzlers" by Joshua Bloch and Neal Gafter 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(); } } This program does not compile within Eclipse 3.1.2 using JRE 1.5.0_02 but it does compile using the JDK 1.5.0_02 directly. Eclipse reports "Unhandled exception type CloneNotSupportedException" in line 19. The OS used in both cases is Windows XP.
I think it is worth reporting the explanation 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." This means that f cannot throw any checked exceptions at all. So the code should compile.
This is the same as bug 79798
*** This bug has been marked as a duplicate of 79798 ***
Verified for 3.4M7 using I20080427-2000