[2064] 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 (Christopher Lindblad)
Fri Sep 22 15:46:58 1995

Date: Fri, 22 Sep 1995 09:21:51 -0700
From: Christopher Lindblad <cjl@Eng.Sun.COM>
To: java-interest@java.Eng.Sun.COM

    Date: Thu, 21 Sep 1995 18:46:16 -0400
    From: arnold@cocolat.East.Sun.COM (Ken Arnold - Sun Labs)
    
    As the words on the front of the HHGTTG say:
    
    	DON'T PANIC
    
    A method cannot throw an exception type not declared in its throws
    clause.  This is good.  You now know which exceptions can be thrown by
    a method.
    
Then shouldn't any method that uses the "new" operator be required to either
catch java.lang.OutOfMemoryError or declare it in its throws clause?  The
"new" operator certainly throws this exception.

Also, shouldn't any method that uses arrays or accesses an instance variable
or method on another object either catch java.lang.NullPointerException or
declare it in its throws clause?  The method could potentially cause that
exception to be thrown.

Perhaps these should be considered "universal" exceptions, in that one should
assume that all methods throw them.  In that case, shouldn't
InterruptedException be counted as a "universal" exception too?

-
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