Re: stack map frames

Yaroslav Kavenchuk <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Eric J. Van der Velden wrote:
> Hi,
>
> I don't know if this is the right place to ask question. If not, I would
> like to hear that from you. In the meantime I just ask my question.
>
> I have tried to do in ASM
>
>          void g(long d){
>          try{
>                  Thread.sleep(d);
>          }catch(InterruptedException e){
>                  e.printStackTrace()     ;
>          }
>          }
>

For this code org.objectweb.asm.util.ASMifierClassVisitor generate next:

mv = cw.visitMethod(0, "g", "(J)V", null, null);
mv.visitCode();
Label l0 = new Label();
Label l1 = new Label();
Label l2 = new Label();
mv.visitTryCatchBlock(l0, l1, l2, "java/lang/InterruptedException");
mv.visitLabel(l0);
mv.visitVarInsn(LLOAD, 1);
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Thread", "sleep", "(J)V");
mv.visitLabel(l1);
Label l3 = new Label();
mv.visitJumpInsn(GOTO, l3);
mv.visitLabel(l2);
mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] 
{"java/lang/InterruptedException"});
mv.visitVarInsn(ASTORE, 3);
mv.visitVarInsn(ALOAD, 3);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/InterruptedException", 
"printStackTrace", "()V");
mv.visitLabel(l3);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 4);
mv.visitEnd();


This some different from your code

-- 
WBR, Yaroslav Kavenchuk
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.