use of org.jf.dexlib2.builder.MutableMethodImplementation in project smali by JesusFreke.
the class MutableMethodImplementationTest method testNewLabelByAddress.
@Test
public void testNewLabelByAddress() {
MethodImplementationBuilder builder = new MethodImplementationBuilder(10);
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction32x(Opcode.MOVE_16, 0, 0));
MutableMethodImplementation mutableMethodImplementation = new MutableMethodImplementation(builder.getMethodImplementation());
mutableMethodImplementation.addCatch(mutableMethodImplementation.newLabelForAddress(0), mutableMethodImplementation.newLabelForAddress(8), mutableMethodImplementation.newLabelForAddress(1));
Assert.assertEquals(0, mutableMethodImplementation.getTryBlocks().get(0).getStartCodeAddress());
Assert.assertEquals(8, mutableMethodImplementation.getTryBlocks().get(0).getCodeUnitCount());
Assert.assertEquals(1, mutableMethodImplementation.getTryBlocks().get(0).getExceptionHandlers().get(0).getHandlerCodeAddress());
}
use of org.jf.dexlib2.builder.MutableMethodImplementation in project smali by JesusFreke.
the class MutableMethodImplementationTest method testTryEndAtEndOfMethod.
@Test
public void testTryEndAtEndOfMethod() {
MethodImplementationBuilder builder = new MethodImplementationBuilder(10);
Label startLabel = builder.addLabel("start");
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
builder.addInstruction(new BuilderInstruction32x(Opcode.MOVE_16, 0, 0));
Label endLabel = builder.addLabel("end");
builder.addCatch(startLabel, endLabel, startLabel);
MethodImplementation methodImplementation = builder.getMethodImplementation();
Assert.assertEquals(0, methodImplementation.getTryBlocks().get(0).getStartCodeAddress());
Assert.assertEquals(8, methodImplementation.getTryBlocks().get(0).getCodeUnitCount());
methodImplementation = new MutableMethodImplementation(methodImplementation);
Assert.assertEquals(0, methodImplementation.getTryBlocks().get(0).getStartCodeAddress());
Assert.assertEquals(8, methodImplementation.getTryBlocks().get(0).getCodeUnitCount());
}
Aggregations