[2147] in java-interest

home help back first fref pref prev next nref lref last post

Re: throws declataration in Java/beta

daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Tue Sep 26 06:19:16 1995

Date: Mon, 25 Sep 1995 10:14:55 -0800 (PDT)
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Reply-To: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
To: Paul Ambrose <pambrose@weblogic.com>
Cc: java-interest@java.Eng.Sun.COM



Hi Paul,

> Can someone please confirm the following:
> 
> In beta Java, if object A extends object B, and both implement method
> foo(),  A.foo() *cannot* throw exception X unless B.foo() also
> throws X.  If you declare that A.foo()  throws X, the compiler
> will complain that B doesn't also throw X.
> 
> This means that you can NEVER throw an exception from a 
> toString() method because Object.toString() doesn't throw
> any exceptions.
> 
> Is this correct? 

Yes. The toString() method declaration is a guarantee. That means that
you can't break it later on and throw an exception anyway.

Have fun,

	Arthur van Hoff


-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post