Using ASM to get the reference returned via ARETURN bytecode instruction -


i have method returns value generated in method similar this:

public static filechannel open() {     return provider.newobject(); } 

so bytecode of method looks this:

invokevirtual org/test/helper.process ()lorg/test/myobject; areturn 

i have java agent uses asm bytecode-transformation when jvm starts up.

now inject code access returned myobject without doing changes invoke itself, i.e. ideally add bytecode instructions before areturn.

which asm/bytecode construct allows me access object returned here?

for simple, can put dup instruction in there followed desired use. if need inject more complex code, should store in register (it doesn't matter since won't used after code except in exceedingly unlikely event areturn throws exception , there's exception handler in method).

so if you're using register 0 go astore_0 (your code) aload_0 areturn.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -