Re: Re: Re: Adding try/finally block

Nikolas Nehmer <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
problem solved ... just one missing goto  :(

cheers
Nikolas

Nikolas Nehmer schrieb:
> Hi,
>
> I have a follow up problem extending and creating try/catch/finally
> blocks.
>
> I'm trying to implement a try block depth counter on bytecode level. For
> every try block entered the counter is incremented and for a try block
> left the counter is decremented. Of course, there are 3 different use
> cases.
> 1. try block is executed completely
> 2. try block is terminated by an exception that is caught by one of the
> corresponding handlers
> 3. try block is terminated by an exception not caught by one of the
> corresponding handlers
>
> For cases where a complete try/catch/finally structure already exists in
> the source code this apporach works perfectly. But I have serious
> problems rebuilding the finally block structure by myself for the 3rd
> case. By studying several simple try/catch/finally examples I came up
> with the following "general" structure of try/catch/finally blocks:
>
> try block start label
> ...
> some code
> ...
> try block end label
> JumpInsn to normalExecutionFinallyBlockLabel
>
> exception handler start label
> exception handler code
> cloned finally block code
> JumpInsn to End of try block
>
> exception handler start label
> exception handler code
> cloned finally block code
> JumpInsn to End of try block
>
> ... continued for every exception handler
>
> exceptionalExecutionFinallyBlock Label
> FrameInsn
> ASTORE
> cloned finally block code
> ALOAD
> ATHROW
>
> normalExecutionFinallyBlock Label
> cloned finally block code
>
> end of try block label
>
> Assuming this structure is correct, I came up with a solution for the 3
> cases mentioned above. The first two are quite simple to solve. I'm just
> inserting my counter decrement behind the
> normalExecutionFinallyBlockLabel and behind the
> ExcetionHandlerBlockStartLabels. For the third case I would like to add
> my counter decrement to the exceptionalExecutionFinallyBlockLabel. In
> case the finally block structure already exists in the application code,
> this works perfectly. BUT if I have to add the complete finally block
> logic to the code (in case there ony exists a try/catch block within the
> code) a java.lang.VerifyError (Inconsistent stack height 0 != 1) is
> raised. In fact this exception is raised when I'm trying to add a new
> TryCatchBlockNode specifying the corresponding finally block (for case
> 3).
>
> Any help will be appreciated ;-)
>
> Best regards
> Nikolas
>
>   


-- 
Dipl.-Inf. Nikolas Nehmer,
Dept. of Computer Science. University of Kaiserslautern 
P.O. Box 3049, 67653 Kaiserslautern, Germany.
room 36/308, phone: +49 (0) 631 - 205 2644, fax: +49 (0) 631 - 205 3299
mail: [email protected]
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.