ARM: preserve supressed exceptions due to throw in finally block

Neal Gafter neal at gafter.com
Thu Apr 8 11:27:06 PDT 2010


Carlos-

This has the same problem as the proposal for handling suppressed exceptions
in ARM: we have no experience to suggest that this way of preserving
suppressed exceptions is usable in realistic programs.  This
software-engineering aspect of ARM language design seems to have been
largely ignored.  I think more study of such software engineering aspects
would be well advised before ARM or any extensions to it are moved into the
jdk.

Cheers,
Neal

On Thu, Apr 8, 2010 at 2:55 AM, Carlos Costa e Silva <carlos at keysoft.pt>wrote:

> Hi everyone,
>
> Small suggestion for an improvement in the ARM proposal.
>
> In a try/finally block:
>
> try {
>    // try code
> }
> finally {
>    // finally code
> }
>
>
> If an exception is thrown in the finally block, any exception thrown in
> the try block is lost.
>
>
> As the ARM proposal adds suppressed exceptions, how about adding the
> "try" exception to the suppressed exceptions of the "finally" exception?
>
>
> Compiler generated pseudo code:
>
> try {
>        // try code
> }
> finally {
>
>    Throwable tryException = (exception thrown in try block, if any);
>    try {
>        // finally code
>    }
>    catch (Throwable t) {
>        if (tryException != null) {
>            t.addSupressedException(tryException);
>        }
>        throw t;
>    }
> }
>
>
> IMHO, this is a small change and would help catch some non obvious
> mistakes.
>
> Carlos
>
>
>



More information about the coin-dev mailing list