Package org.jf.baksmali.Adaptors

Examples of org.jf.baksmali.Adaptors.ClassDefinition


        }

        File smaliFile = fileNameHandler.getUniqueFilenameForClass(classDescriptor);

        //create and initialize the top level string template
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);

        //write the disassembly
        Writer writer = null;
        try
        {
            File smaliParent = smaliFile.getParentFile();
            if (!smaliParent.exists()) {
                if (!smaliParent.mkdirs()) {
                    // check again, it's likely it was created in a different thread
                    if (!smaliParent.exists()) {
                        System.err.println("Unable to create directory " + smaliParent.toString() + " - skipping class");
                        return false;
                    }
                }
            }

            if (!smaliFile.exists()){
                if (!smaliFile.createNewFile()) {
                    System.err.println("Unable to create file " + smaliFile.toString() + " - skipping class");
                    return false;
                }
            }

            BufferedWriter bufWriter = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(smaliFile), "UTF8"));

            writer = new IndentingWriter(bufWriter);
            classDefinition.writeTo((IndentingWriter)writer);
        } catch (Exception ex) {
            System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
            ex.printStackTrace();
            // noinspection ResultOfMethodCallIgnored
            smaliFile.delete();
View Full Code Here


        options.useImplicitReferences = false;

        for (ClassDef classDef: dexFile.getClasses()) {
            StringWriter stringWriter = new StringWriter();
            IndentingWriter writer = new IndentingWriter(stringWriter);
            ClassDefinition classDefinition = new ClassDefinition(options, classDef);
            classDefinition.writeTo(writer);
            writer.close();

            String className = classDef.getType();
            String smaliPath = String.format("%s%s%s.smali", test, File.separatorChar,
                    className.substring(1, className.length() - 1));
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

TOP

Related Classes of org.jf.baksmali.Adaptors.ClassDefinition

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.