I am working on a bytecode toolkit project. Currently, when processing objects, the verifier most often causes an error. Therefore, I would like to get an idea of ββthe rules with objects (I read the JVMS, but could not find the answer I was looking for):
I use the NEW statement:
original bytecode
NEW <MyClass> DUP INVOKESPECIAL <MyClass.<init>>
after instrumentation
NEW <MyClass> DUP INVOKESTATIC <Profiler.handleNEW> DUP INVOKESPECIAL <MyClass.<init>>
Note that I added a call to Profiler.handleNEW (), which takes as an argument a reference to an object (a newly created object).
The code part above throws a VerificationError. Although, if I do not add INVOKESTATIC (leaving only DUP), it is not. So what is the rule that I break? I can duplicate an uninitialized link, but I can not pass it as a parameter? I would be grateful for any help. Thanks you
java bytecode verification instrumentation
Hh
source share