Re: instrumenting try block
Eric Bruneton <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hi, 18/07/2011 18:56, Yudi Zheng wrote: > Hi, > > We are trying to insert new code section into existing exception handler. > In an example below is just simplified scenario, but we are using similar > code to insert try-finally into methods. > > We have encountered buggy behavior when using COMPUTE_FRAMES > in conjunction with COMPUTE_MAXS within ClassWriter. > > The following code (for full runnable code see attachments) produces > Java VerifyError. If we use the Class writer twice in a row at the end, > the produced result is as expected. > > Do you have any idea, what can cause the error? > ilst.insert(handler, new IntInsnNode(Opcodes.ALOAD, > method.maxLocals)); > ilst.insert(handler, new IntInsnNode(Opcodes.ASTORE, > method.maxLocals)); the error is that you used IntInsnNode instead of VarInsnNode. This type of error can easily be detected with a CheckClassAdapter: // Transform into bytecode ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); ClassVisitor cv = new CheckClassAdapter(cw); cn.accept(cv); 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