> From: news [mailto:[EMAIL PROTECTED] On Behalf Of Berin Loritsch
>
> > For example, Hejlsberg lists as one bad thing about rethrowing 
> > exceptions that you loose the stack trace. But if the Exception is 
> > supposed to be handled, then who cares about the stack trace?
> 
> If you rethrow the exact same exception, shouldn't the stack 
> trace remain in tact?  If you throw a wrapped exception, then 
> you can still get to the original stack trace.  The stack 
> trace is important to developers because it helps pinpoint 
> the exact place where the problem occurred.

Hejlsberg meant the case where an Exception is re-thrown and
not wrapped.

> As soon as you declare it, the compiler will require a 
> try/catch or throws clause--even if it is a RuntimeException.

No.

public class Hack {
    
    public void method () {
        method2 ();
    }
    
    public void method2 () throws IllegalArgumentException {
        throw new IllegalArgumentException ("Yadda");
    }
    
    public static void main (String[] args) {
        Hack h = new Hack ();
        h.method();
    }
}

/LS

Reply via email to