Sascha, > So, should a java compiler accept the following? > > // java.awt.HeadlessException > // extends java.lang.UnsupportedOperationException > // extends java.lang.RuntimeException > > class Foo > { > void meth() throws java.awt.HeadlessException { } > } > > class Bar > extends Foo > { > void meth() { } > }
Yes it should. Refer to the JLS Section 8.4.4. The last two paragraphs read as follows: A method that overrides or hides another method (§8.4.6), including methods that implement abstract methods defined in interfaces, may not be declared to throw more checked exceptions than the overridden or hidden method. More precisely, suppose that B is a class or interface, and A is a superclass or superinterface of B, and a method declaration n in B overrides or hides a method declaration m in A. If n has a throws clause that mentions any checked exception types, then m must have a throws clause, and for every checked exception type listed in the throws clause of n, that same exception class or one of its superclasses must occur in the throws clause of m; otherwise, a compile-time error occurs. Note that these rules are for >>checked<< exceptions only; i.e. exception classes that are NOT subtypes of Error or RuntimeException. > javac 1.4.1 compiles this code, but gcj 3.2 complains about the throws > clause (of *Foo*.meth, which is a bit misleading). gcj 3.2 is clearly wrong, IMO. -- Steve _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath