Package org.jf.dexlib2.util

Examples of org.jf.dexlib2.util.SyntheticAccessorResolver$AccessedMember


    public void testCustomMethodInlineTable_Static() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.STATIC.getValue(), null,
                methodImpl);

        ClassDef classDef = new ImmutableClassDef("Lblah;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null,
                null, null, null, null, ImmutableList.of(method), null);
View Full Code Here


    public void testCustomMethodInlineTable_Direct() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PRIVATE.getValue(), null,
                methodImpl);

        ClassDef classDef = new ImmutableClassDef("Lblah;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null,
                null, null, null, null, ImmutableList.of(method), null);
View Full Code Here

public class CustomMethodInlineTableTest {
    @Test
    public void testCustomMethodInlineTable_Virtual() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PUBLIC.getValue(), null,
                methodImpl);
View Full Code Here

    @Test
    public void testCustomMethodInlineTable_Static() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.STATIC.getValue(), null,
                methodImpl);
View Full Code Here

    @Test
    public void testCustomMethodInlineTable_Direct() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PRIVATE.getValue(), null,
                methodImpl);
View Full Code Here

public class CustomMethodInlineTableTest {
    @Test
    public void testCustomMethodInlineTable_Virtual() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PUBLIC.getValue(), null,
                methodImpl);
View Full Code Here

    }

    @Test
    public void testCustomMethodInlineTable_Static() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.STATIC.getValue(), null,
                methodImpl);
View Full Code Here

    }

    @Test
    public void testCustomMethodInlineTable_Direct() {
        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PRIVATE.getValue(), null,
                methodImpl);
View Full Code Here

        //baksmali/smali cycles for some reason. If a class with a colliding name is added or removed, the filenames
        //may still change of course
        List<? extends ClassDef> classDefs = Ordering.natural().sortedCopy(dexFile.getClasses());

        if (!options.noAccessorComments) {
            options.syntheticAccessorResolver = new SyntheticAccessorResolver(classDefs);
        }

        final ClassFileNameHandler fileNameHandler = new ClassFileNameHandler(outputDirectoryFile, ".smali");

        ExecutorService executor = Executors.newFixedThreadPool(options.jobs);
View Full Code Here

    public void testAccessors() throws IOException {
        URL url = AccessorTest.class.getClassLoader().getResource("accessorTest.dex");
        Assert.assertNotNull(url);
        DexFile f = DexFileFactory.loadDexFile(url.getFile(), 15);

        SyntheticAccessorResolver sar = new SyntheticAccessorResolver(f.getClasses());

        ClassDef accessorTypesClass = null;
        ClassDef accessorsClass = null;

        for (ClassDef classDef: f.getClasses()) {
            String className = classDef.getType();

            if (className.equals("Lorg/jf/dexlib2/AccessorTypes;")) {
                accessorTypesClass = classDef;
            } else if (className.equals("Lorg/jf/dexlib2/AccessorTypes$Accessors;")) {
                accessorsClass = classDef;
            }
        }

        Assert.assertNotNull(accessorTypesClass);
        Assert.assertNotNull(accessorsClass);

        for (Method method: accessorsClass.getMethods()) {
            Matcher m = accessorMethodPattern.matcher(method.getName());
            if (!m.matches()) {
                continue;
            }
            String type = m.group(1);
            String operation = m.group(2);

            MethodImplementation methodImpl = method.getImplementation();
            Assert.assertNotNull(methodImpl);

            for (Instruction instruction: methodImpl.getInstructions()) {
                Opcode opcode = instruction.getOpcode();
                if (opcode == Opcode.INVOKE_STATIC || opcode == Opcode.INVOKE_STATIC_RANGE) {
                    MethodReference accessorMethod =
                            (MethodReference)((ReferenceInstruction) instruction).getReference();

                    SyntheticAccessorResolver.AccessedMember accessedMember = sar.getAccessedMember(accessorMethod);

                    Assert.assertNotNull(String.format("Could not resolve accessor for %s_%s", type, operation),
                            accessedMember);

                    int operationType = operationTypes.get(operation);
View Full Code Here

TOP

Related Classes of org.jf.dexlib2.util.SyntheticAccessorResolver$AccessedMember

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.