Try-catch block injection
Nikolas Nehmer <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to do the following transformation based on bytecode injection:
startLabel:
foo...;
endLabel
into
try {
startLabel:
foo...;
endLabel
} catch (VerifyError e) {
//doSomething;
}
Currently, my code looks like this (raising a java.lang.ClassFormatError):
LabelNode startLabel = new LabelNode();
tempList.add(startLabel);
LabelNode endLabel = new LabelNode();
tempList.add(endLabel);
//catch block
int numberOfLocalVariables = 0;
Object[] localVariableTypes = new Object[0];
int numberOfStackElements = 0;
Object[] stackElementTypes = new Object[0];
tempList.add(new FrameNode(Opcodes.F_FULL, numberOfLocalVariables,
localVariableTypes, numberOfStackElements, stackElementTypes));
tempList.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
logger,"testTryCatch", ("()V")));
list.insertBefore(currentInsnNode, tempList);
list.insert(new FrameNode(Opcodes.F_SAME, numberOfLocalVariables,
localVariableTypes, numberOfStackElements, stackElementTypes));
tryCatchBlocks.add(new TryCatchBlockNode(startLabel, endLabel, endLabel,
"java/lang/Throwable"));
Any suggestions?
Cheers
Nikolas
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