Closed Bug 214945 Opened 23 years ago Closed 23 years ago

finally not executed if try empty

Categories

(Rhino Graveyard :: Compiler, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: okidoky, Assigned: norrisboyd)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20021213 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20021213 (Appologies in advance if this bug was already reported.) When there is no code in a try block, then the finally block is not executed. Reproducible: Always Steps to Reproduce: try { } finally { print(123 } Actual Results: (nothing) Expected Results: 123 I tried this with the command line 'js', which seems to default to interprete mode. When I do js -opt 9, I get the same results, so it looks like the compiler is also affected. In C's version 'SpiderMonkey' does appear to work, and does print the 123 message. If I add a semicolon, it works: js> try { ; } finally { print(123) } 123
The bug is triggered by an incorrect optimization in createTryCatchFinally of omj/IRFactory.java where it removes all try/catch/finally as long as try is empty. The patch changes that to apply optimization only if finally is empty as well. In principle the case of empty try with a non-trivial finally can be replaced by just the finally block instead of generating full code for try/catch/finally support but IMO it does not that frequent to bother.
I committed the fix
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 217591 has been marked as a duplicate of this bug. ***
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: