Re: Try-catch block injection
Eugene Kuleshov <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Not sure what suggestion you are looking for, but your code is
incomplete to drive any conclusions (e.g. what's the
currentInsnNode?).
I'd suggest to forget about stackmap frames for now, it is going to
work without them just fine and you can get back to them when you get
a better grip on a bytecode.
Also, write your java code before and after transformation and use
ASMifier to get the code to generate bytecodes, so you can compare
what changes.
Anyways, from what I read, your code is transforming this:
currentInsnNode
into this:
{
startLabel (created by you)
endLabel (created by you)
} catch(Throwable e) {
logger.testTryCatch();
}
currentInsnNode
...
Note that you also are NOT consuming the exception value off the stack.
regards,
Eugene
On Mon, Mar 22, 2010 at 9:03 AM, Nikolas Nehmer
<[email protected]> wrote:
> 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
>
>
> --
> 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
>
>
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