Article View: borland.public.jbuilder.java.language
Article #16396Re: finally and return
From: Tor Iver Wilhelmsen
Date: Fri, 26 Feb 1999 00:00
Date: Fri, 26 Feb 1999 00:00
17 lines
1256 bytes
1256 bytes
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.
Technical Details
Message-ID:
<u678p34ga.fsf@sds.no>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36d6e3bb.6330119@forums.inprise.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,92c7634c9c470034 X-Google-Attributes: gidf74b3,public From: Tor Iver Wilhelmsen <tor.wilhelmsen@sds.no> Subject: Re: finally and return Date: 1999/02/26 Message-ID: <u678p34ga.fsf@sds.no> X-Deja-AN: 448655429 Sender: towi@SDSA1761 References: <36d6e3bb.6330119@forums.inprise.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language