Package org.jf.dexlib2

Examples of org.jf.dexlib2.AccessorTest


                            // intentional fall-through
                        case ARRAY_PAYLOAD: {
                            if ((location.codeAddress & 0x01) != 0) {
                                int previousIndex = location.index - 1;
                                MethodLocation previousLocation = instructionList.get(previousIndex);
                                Instruction previousInstruction = previousLocation.instruction;
                                assert previousInstruction != null;
                                if (previousInstruction.getOpcode() == Opcode.NOP) {
                                    removeInstruction(previousIndex);
                                    index--;
                                } else {
                                    addInstruction(location.index, new BuilderInstruction10x(Opcode.NOP));
                                    index++;
View Full Code Here


    private void fixInstructions(@Nonnull MutableMethodImplementation methodImplementation) {
        List<? extends Instruction> instructions = methodImplementation.getInstructions();

        for (int i=0; i<instructions.size(); i++) {
            Instruction instruction = instructions.get(i);

            if (instruction.getOpcode() == Opcode.CONST_STRING) {
                if (stringSection.getItemIndex(
                        (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) {
                    methodImplementation.replaceInstruction(i, new BuilderInstruction31c(Opcode.CONST_STRING_JUMBO,
                            ((OneRegisterInstruction)instruction).getRegisterA(),
                            ((ReferenceInstruction)instruction).getReference()));
View Full Code Here

                    protected Instruction readNextItem(@Nonnull DexReader reader) {
                        if (reader.getOffset() >= endOffset) {
                            return null;
                        }

                        Instruction instruction = DexBackedInstruction.readFrom(reader);

                        // Does the instruction extend past the end of the method?
                        int offset = reader.getOffset();
                        if (offset > endOffset || offset < 0) {
                            throw new ExceptionWithContext("The last instruction in the method is truncated");
View Full Code Here

        ClassPath classPath = ClassPath.fromClassPath(ImmutableList.<String>of(), ImmutableList.<String>of(), dexFile,
                15);
        InlineMethodResolver inlineMethodResolver = new CustomInlineMethodResolver(classPath, "Lblah;->blah()V");
        MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classPath, method, inlineMethodResolver);

        Instruction deodexedInstruction = methodAnalyzer.getInstructions().get(0);
        Assert.assertEquals(Opcode.INVOKE_VIRTUAL, deodexedInstruction.getOpcode());

        MethodReference methodReference = (MethodReference)((Instruction35c)deodexedInstruction).getReference();
        Assert.assertEquals(method, methodReference);
    }
View Full Code Here

        ClassPath classPath = ClassPath.fromClassPath(ImmutableList.<String>of(), ImmutableList.<String>of(), dexFile,
                15);
        InlineMethodResolver inlineMethodResolver = new CustomInlineMethodResolver(classPath, "Lblah;->blah()V");
        MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classPath, method, inlineMethodResolver);

        Instruction deodexedInstruction = methodAnalyzer.getInstructions().get(0);
        Assert.assertEquals(Opcode.INVOKE_STATIC, deodexedInstruction.getOpcode());

        MethodReference methodReference = (MethodReference)((Instruction35c)deodexedInstruction).getReference();
        Assert.assertEquals(method, methodReference);
    }
View Full Code Here

        List<? extends Instruction> instructions =
                Lists.newArrayList(implBuilder.getMethodImplementation().getInstructions());

        Assert.assertEquals(instructions.size(), 1);

        Instruction instruction = instructions.get(0);

        Assert.assertEquals(instruction.getOpcode(), Opcode.ARRAY_PAYLOAD);
    }
View Full Code Here

        ClassPath classPath = ClassPath.fromClassPath(ImmutableList.<String>of(), ImmutableList.<String>of(), dexFile,
                15);
        InlineMethodResolver inlineMethodResolver = new CustomInlineMethodResolver(classPath, "Lblah;->blah()V");
        MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classPath, method, inlineMethodResolver);

        Instruction deodexedInstruction = methodAnalyzer.getInstructions().get(0);
        Assert.assertEquals(Opcode.INVOKE_DIRECT, deodexedInstruction.getOpcode());

        MethodReference methodReference = (MethodReference)((Instruction35c)deodexedInstruction).getReference();
        Assert.assertEquals(method, methodReference);
    }
View Full Code Here

        List<? extends Instruction> instructions =
                Lists.newArrayList(implBuilder.getMethodImplementation().getInstructions());

        Assert.assertEquals(instructions.size(), 3);

        Instruction instruction = instructions.get(0);
        Assert.assertEquals(instruction.getOpcode(), Opcode.MOVE);

        instruction = instructions.get(1);
        Assert.assertEquals(instruction.getOpcode(), Opcode.NOP);

        instruction = instructions.get(2);
        Assert.assertEquals(instruction.getOpcode(), Opcode.ARRAY_PAYLOAD);
    }
View Full Code Here

                        Opcode.NOP,
                        Opcode.NOP,
                        Opcode.NOP,
                        Opcode.PACKED_SWITCH});

        OffsetInstruction gotoInstruction = (OffsetInstruction)instructions.get(0);
        Assert.assertEquals(12, gotoInstruction.getCodeOffset());

        PackedSwitchPayload payload = (PackedSwitchPayload)instructions.get(2);
        Assert.assertEquals(3, payload.getSwitchElements().size());
        Assert.assertEquals(-16, payload.getSwitchElements().get(0).getOffset());
        Assert.assertEquals(-2, payload.getSwitchElements().get(1).getOffset());
        Assert.assertEquals(-1, payload.getSwitchElements().get(2).getOffset());

        OffsetInstruction referent = (OffsetInstruction)instructions.get(7);
        Assert.assertEquals(-14, referent.getCodeOffset());
    }
View Full Code Here

                        Opcode.NOP,
                        Opcode.NOP,
                        Opcode.NOP,
                        Opcode.SPARSE_SWITCH});

        OffsetInstruction gotoInstruction = (OffsetInstruction)instructions.get(0);
        Assert.assertEquals(16, gotoInstruction.getCodeOffset());

        SparseSwitchPayload payload = (SparseSwitchPayload)instructions.get(2);
        Assert.assertEquals(3, payload.getSwitchElements().size());
        Assert.assertEquals(-20, payload.getSwitchElements().get(0).getOffset());
        Assert.assertEquals(-2, payload.getSwitchElements().get(1).getOffset());
        Assert.assertEquals(-1, payload.getSwitchElements().get(2).getOffset());

        OffsetInstruction referent = (OffsetInstruction)instructions.get(7);
        Assert.assertEquals(-18, referent.getCodeOffset());
    }
View Full Code Here

TOP

Related Classes of org.jf.dexlib2.AccessorTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.