ARM: preserve supressed exceptions due to throw in finally block
Joshua Bloch
jjb at google.com
Thu Apr 8 11:10:58 PDT 2010
Carlos,
I like it, but it scares me a bit: there are billions (literally) of
try-finally blocks out there, and this would change the code emitted by all
of them. It would, without question, increase the size of the class files
emitted by many (most?) Java programs. Hopefully it wouldn't slow them
down, but you never know until you measure.
Josh
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