Re: How to copy an InsnList?
"Markus Heiden" <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <3F0B33274C0A47B29933E5D48639DBB6@Laptop> |
Hi Michael,
I tried a little harder and it seems to work now:
public static MethodNode copy(MethodNode method) {
String[] exceptions = (String[]) method.exceptions.toArray(new
String[method.exceptions.size()]);
MethodNode result = new MethodNode(method.access, method.name,
method.desc, method.signature, exceptions) {
/**
* Label remapping.
* Old label -> new label.
*/
private final Map<Label, Label> labels = new HashMap<Label, Label>();
@Override
protected LabelNode getLabelNode(Label label) {
Label newLabel = labels.get(label);
if (newLabel == null) {
newLabel = new Label();
labels.put(label, newLabel);
}
return super.getLabelNode(newLabel);
}
};
method.accept(result);
return result;
}
I hope this one is correct... At least the copied method produces no error
messages in the Analyzer anymore.
Thanks for the hint with XML. I will give it a try, when I do the tests for
my byte code transfomer.
Markus
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