mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-25 11:51:15 +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,
|
||||
String fieldName, int pos) {
|
||||
InsnList insnNodes = new InsnList();
|
||||
// NOTE: will insert in reversed order
|
||||
insnNodes.insert(new MethodInsnNode(INVOKESTATIC, CLASS_TESTABLE_UTIL, FIELD_TO_METHOD_MAPPING.get(fieldName),
|
||||
InsnList il = new InsnList();
|
||||
il.add(new VarInsnNode(ALOAD, 0));
|
||||
il.add(new MethodInsnNode(INVOKESTATIC, CLASS_TESTABLE_UTIL, FIELD_TO_METHOD_MAPPING.get(fieldName),
|
||||
SIGNATURE_TESTABLE_UTIL_METHOD, false));
|
||||
insnNodes.insert(new VarInsnNode(ALOAD, 0));
|
||||
mn.instructions.insert(instructions[pos], insnNodes);
|
||||
mn.instructions.insert(instructions[pos], il);
|
||||
mn.instructions.remove(instructions[pos]);
|
||||
return mn.instructions.toArray();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user