Infrequently updated blog!

Things Calum may be responsible for

Java gotcha o' the day

Monday, 18 February 2008

Here's something in Java that I just couldn't predict what it was going to do:
try
{
    try
    {
        throw new RuntimeException("Lost?");
    }
    finally
    {
        throw new RuntimeException("Interloper");
    }   
}
catch (Exception e)
{
    System.out.println(e);
}
In hindsight I guess it's obvious that the exception thrown in the finally block would take precedence, but losing exceptions without having to explicitly deal with them seems quite the dangerous thing. It's just strange to say. That said, anyone throwing exceptions from a finally block should probably be strung up anyway.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home