[antlr-interest] Exceptions and finally blocks

Terence Parr parrt at cs.usfca.edu
Sun Mar 12 11:22:31 PST 2006


  I'm running into this very strange Java behavior, which I believe  
is considered normal but it does not give us what we want.   when an  
exception is thrown in a method it still tries to execute the finally  
of course. However, when an exception occurs usually it means that  
this stuff in the finally clause will not execute without its own  
exception. This second exception forces the first exception to be  
lost. It is very confusing because you see an exception in the  
finally when all of those variables should be okay but you get null  

  should I add the following:

catch (Exception e) {
..handle exception..perhaps noUserFinally=true;
throw e;
finally {
   usual cleanup
   if ( !noUserFinally ) { user stuff }

Hmm.... this is turning out to be a serious problem for me as I  
developed my Mantra language with version three. Very very   
annoying.  Suggestions?


More information about the antlr-interest mailing list