Re: Re: Retrieving the object reference of the return value or exception in onMethodExit

Buu Vinh <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Since you mentioned, it very obvious :-) 
Thanks, Eric.

--- On Fri, 2/11/11, Eric Bruneton <[email protected]> wrote:

From: Eric Bruneton <[email protected]>
Subject: [asm] Re: Retrieving the object reference of the return value or exception in onMethodExit
To: "[email protected]" <[email protected]>
Date: Friday, February 11, 2011, 10:28 AM

11/02/2011 03:06, Buu Vinh wrote:
> Since the top element of the stack contains the return value or the
> exception instance, I tried to retrieve them in onMethodExit, but it
> resulted in stack exception. Please advice.
>
> protected void onMethodExit(int opcode){
>
> if (opcode == ATHROW){
> mv.visitInsn(DUP);
> mv.visitVarInsn(ASTORE, exceptionIndex); // Stores exception in local
> variable
> }
> else {
> mv.visitInsn(ACONST_NULL);
> mv.visitVarInsn(ASTORE, exceptionIndex);
> if (opcode == ARETURN) {
> mv.visitInsn(DUP);
> mv.visitVarInsn(ASTORE, returnValueIndex); // Stores return value in
> local variable
> }
> }
> mv.visitVarInsn(ALOAD, myClassIndex);
> mv.visitVarInsn(ALOAD, exceptionIndex); // passes them to MyClass
> mv.visitVarInsn(ASTORE, returnValueIndex);

I think the line above should use ALOAD instead of ASTORE

> mv.visitMethodInsn(INVOKEVIRTUAL, "com/bv/MyClass", "myMethod",
> "(Ljava/lang/Throwable;Ljava/lang/Object;)V");

Eric

-----Inline Attachment Follows-----


-- 
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
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.