stack map frames
"Eric J. Van der Velden" <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
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() ;
}
}
I did
ClassWriter w=new ClassWriter(ClassWriter.COMPUTE_FRAMES) ;
...
MethodVisitor v6=w.visitMethod(ACC_PUBLIC,"g","(J)V",null,null) ;
v6.visitCode() ;
Label t=new Label() ;
Label c=new Label() ;
Label f=new Label() ;
v6.visitTryCatchBlock(t,c,c,"java/lang/InterruptedException") ;
v6.visitLabel(t) ;
v6.visitVarInsn(LLOAD,1);
v6.visitMethodInsn(INVOKESTATIC, "java/lang/Thread", "sleep", "(J)V");
v6.visitJumpInsn(GOTO,f);
v6.visitLabel(c) ;
v6.visitVarInsn(ASTORE,3);
v6.visitVarInsn(ALOAD,3);
v6.visitMethodInsn(INVOKEVIRTUAL, "java/lang/InterruptedException",
"printStackTrace", "()V");
v6.visitLabel(f) ;
v6.visitInsn(RETURN);
v6.visitMaxs(0,0);
v6.visitEnd();
With javap on the result I see
public void g(long);
Signature: (J)V
flags: ACC_PUBLIC
Code:
stack=2, locals=4, args_size=2
0: lload_1
1: invokestatic #23 // Method java/lang/Thread.sleep:(J)V
4: goto 12
7: astore_3
8: aload_3
9: invokevirtual #26 // Method
java/lang/InterruptedException.printStackTrace:()V
12: return
Exception table:
from to target type
0 7 7 Class java/lang/InterruptedException
StackMapTable: number_of_entries = 2
frame_type = 71 /* same_locals_1_stack_item */
stack = [ class java/lang/InterruptedException ]
frame_type = 4 /* same */
When I compile the Java code and look at javap on that, I see almost the
same, but in the exception table it says 'to 4' instead of 'to 7'.
I have studied jdk1.2.2, so stack map frames are new for me. They are not in
my JVM spec book. Do you know a place where they are explained, so I can
read about them? So that I can understand 'frame type = 71' .
Also did I programmed it right in ASM, because of the difference in the
exception table?
Also suppose I do
ClassWriter w=new ClassWriter(0)
Which MethodVisitor.visitFrame calls I have to make, and where?
I hope it is not too much. Thanks.
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