[2122] 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)
Mon Sep 25 21:42:29 1995

Date: Mon, 25 Sep 1995 16:33:32 -0800 (PDT)
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Reply-To: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
To: dufourd@enst.enst.fr
Cc: java-interest@java.Eng.Sun.COM



Hi,

> >This means that you can NEVER throw an exception from a 
> >toString() method because Object.toString() doesn't throw
> >any exceptions.
> 
> This is my experience too, and this language/compiler design decision
> seems pretty lame to me. Another thing you cannot do is ask for the
> current thread to sleep when you are in the run method because the
> interface Runnable does not specify "throws InterruptedException"...
> I am sure there are lots of other such examples.

It is very important to realize that a Java class is a guaranteed interface.
If an method is declared to throw a certain set of exceptions than there is no
way a sub class can change that. At first this may seem restrictive, but after
a while you will realize that it is wonderful to have this guarantee. 

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