Re: Retrieving the object reference of the return value or exception in onMethodExit
Eric Bruneton <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
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
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