classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declaring RuntimeExceptions?


From: Otavio Pereira
Subject: Re: Declaring RuntimeExceptions?
Date: Thu, 11 Sep 2003 14:37:55 +0100 (BST)

Hi, 
I do agree with Ingo, the methods should report any exception that may be throw
explicitly. Of course, methods won't declare the well know
NullPointerException, or ArrayIndexOutOfBounds... etc. but exceptions that are
trhown, such as the HeadlessException, should be reported, not only 'cos the
sun does so, but I think it is a good practise, I mean, anyone who looks at the
method signature will notice that it can trhow that kind of exception, without
looking at the code. And there's also the reflection... so I guess it's better
to declare them, as this will still keep backward and "sideward"(does this word
exists?) compatibility...

-- otavio

 --- Ingo_Prötel <address@hidden> wrote: > Hi Sascha,
> 
> I think Classpath should also declare RuntimeExceptions if JDK does so.
> 
> If you do a getExceptionTypes() on java.lang.reflect.Method you will get
> all declared Throwables. This includes RuntimeExceptions and Errors that
> are declared to be thrown by a method (also for constructors).
> 
> So, to keep the runtime-behavoir of such objects consistent we need to
> declare such Exceptions even if the compiler does require it.
> 
> --ingo
> 
> Sascha Brawer wrote:
> > Hi all,
> > 
> > if the signature of a JDK method declares to throw some RuntimeException,
> > should the Classpath do so, too?
> > 
> > For example, java.awt.Toolkit.createButton declares to throw
> > java.awt.HeadlessException in the JDK, but not in Classpath.
> > HeadlessException extends java.lang.RuntimeException.
> > 
> > -- Sascha


________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]