[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Declaring RuntimeExceptions?
From: |
David Holmes |
Subject: |
RE: Declaring RuntimeExceptions? |
Date: |
Fri, 12 Sep 2003 11:06:02 +1000 |
> 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() { }
> }
The code is valid in that its okay for a subclass to declare fewer
exceptions on an overriding method - checked or unchecked. Hence
Bar.meth is correctly defined and must be accepted by any compiler.
However, a compiler could complain that Foo.meth can never throw the
declared HeadlessException (as it should for a checked exception) and
refuse to compile it. I think it would be a bit over-zealous, though
not "illegal", to do so.
David Holmes
- Declaring RuntimeExceptions?, Sascha Brawer, 2003/09/11
- Re: Declaring RuntimeExceptions?, Brian Jones, 2003/09/11
- Re: Declaring RuntimeExceptions?, Ingo Prötel, 2003/09/11
- Re: Declaring RuntimeExceptions?, Otavio Pereira, 2003/09/11
- RE: Declaring RuntimeExceptions?, David Holmes, 2003/09/11
- Re: Declaring RuntimeExceptions?, Eric Blake, 2003/09/11
- Re: Declaring RuntimeExceptions?, Sascha Brawer, 2003/09/11
- Re: Declaring RuntimeExceptions?, Stephen Crawley, 2003/09/11
- RE: Declaring RuntimeExceptions?,
David Holmes <=
- Re: Declaring RuntimeExceptions?, Tom Tromey, 2003/09/17
Re: Declaring RuntimeExceptions?, Tom Tromey, 2003/09/11