🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16405

Re: finally and return

#16405
From: Doug Chamberlin
Date: Fri, 26 Feb 1999 00:00
32 lines
2033 bytes
On 26 Feb 1999 10:21:57 +0100, Tor Iver Wilhelmsen
<tor.wilhelmsen@sds.no> wrote:

>dchamberlinNOSPAM@dlawton.com (Doug Chamberlin) writes:
>
>> I just discovered what I feel is a strange behavior. I was debugging a
>> Java program which had a "return true" statement inside a finally
>> block of a method. The effect of this statement was to CANCEL then
>> exception. That is, the method returned normally and did not propigate
>> the thrown exception which was active upward in the call stack.
>> 
>> Anyone else see this behavior? it was totally unexpected by me!
>
>It's to be expected: at the throw, it goes upwards, and finds a
>finally block to execute. During this execution it performs a return,
>and thus never gets to the "rethrow the exception after 'finally'"
>step.
>
>Place the return statement in the try block instead, the finally block
>will execute regardless.

That's what I've done (put the return in the try block). However, it
seems strange to me that there are certain statements, like return,
which cannot be put into a finally block if you don't want to disrupt
the flow of handling an exception.

In Object Pascal once an expcetion is thrown it propagates back up the
call stack until it is caught. You cannot stop this from happening as
far as I know. That's what gave me pause.

What other statements, if placed in a finally block, cause an
exception to stop being "thrown"?
Technical Details
Message-ID: <36d6c8a3.275742@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36d6e3bb.6330119@forums.inprise.com> <u678p34ga.fsf@sds.no>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,92c7634c9c470034
X-Google-Attributes: gidf74b3,public
From: dchamberlinNOSPAM@dlawton.com (Doug Chamberlin)
Subject: Re: finally and return
Date: 1999/02/26
Message-ID: <36d6c8a3.275742@forums.inprise.com>
X-Deja-AN: 448759775
Content-Transfer-Encoding: 7bit
References: <36d6e3bb.6330119@forums.inprise.com> <u678p34ga.fsf@sds.no>
Content-Type: text/plain; charset=us-ascii
Organization: D. Lawton Associates
Mime-Version: 1.0
Reply-To: dchamberlinNOSPAM@dlawton.com
Newsgroups: borland.public.jbuilder.java.language