ARM: preserve supressed exceptions due to throw in finally block
    Carlos Costa e Silva 
    carlos at keysoft.pt
       
    Thu Apr  8 02:55:58 PDT 2010
    
    
  
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