mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-26 20:30:29 +08:00
use add instead of insert
This commit is contained in:
parent
f9fc1e6224
commit
2ad671e1f9
@ -85,12 +85,11 @@ public class TestClassHandler extends BaseClassHandler {
|
|||||||
|
|
||||||
private AbstractInsnNode[] replaceTestableUtilField(MethodNode mn, AbstractInsnNode[] instructions,
|
private AbstractInsnNode[] replaceTestableUtilField(MethodNode mn, AbstractInsnNode[] instructions,
|
||||||
String fieldName, int pos) {
|
String fieldName, int pos) {
|
||||||
InsnList insnNodes = new InsnList();
|
InsnList il = new InsnList();
|
||||||
// NOTE: will insert in reversed order
|
il.add(new VarInsnNode(ALOAD, 0));
|
||||||
insnNodes.insert(new MethodInsnNode(INVOKESTATIC, CLASS_TESTABLE_UTIL, FIELD_TO_METHOD_MAPPING.get(fieldName),
|
il.add(new MethodInsnNode(INVOKESTATIC, CLASS_TESTABLE_UTIL, FIELD_TO_METHOD_MAPPING.get(fieldName),
|
||||||
SIGNATURE_TESTABLE_UTIL_METHOD, false));
|
SIGNATURE_TESTABLE_UTIL_METHOD, false));
|
||||||
insnNodes.insert(new VarInsnNode(ALOAD, 0));
|
mn.instructions.insert(instructions[pos], il);
|
||||||
mn.instructions.insert(instructions[pos], insnNodes);
|
|
||||||
mn.instructions.remove(instructions[pos]);
|
mn.instructions.remove(instructions[pos]);
|
||||||
return mn.instructions.toArray();
|
return mn.instructions.toArray();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user