Search in sources :

Example 1 with DirectClassFile

use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.

the class ClassReferenceListBuilder method addRootsV2.

public void addRootsV2(String name) {
    if (name.endsWith(CLASS_EXTENSION)) {
        classNames.add(name.substring(0, name.length() - CLASS_EXTENSION.length()));
    }
    if (name.endsWith(CLASS_EXTENSION)) {
        DirectClassFile classFile;
        try {
            classFile = path.getClass(name);
            addDependencies(classFile);
        } catch (FileNotFoundException e) {
        //                throw new IOException("Class " + name +
        //                        " is missing form original class path " + path, e);
        }
    }
}
Also used : DirectClassFile(com.android.dx.cf.direct.DirectClassFile) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with DirectClassFile

use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.

the class ClassReferenceListBuilder method addClassWithHierachy.

private void addClassWithHierachy(String classBinaryName) {
    if (classNames.contains(classBinaryName)) {
        return;
    }
    try {
        DirectClassFile classFile = path.getClass(classBinaryName + CLASS_EXTENSION);
        classNames.add(classBinaryName);
        CstType superClass = classFile.getSuperclass();
        if (superClass != null) {
            addClassWithHierachy(superClass.getClassType().getClassName());
        }
        TypeList interfaceList = classFile.getInterfaces();
        int interfaceNumber = interfaceList.size();
        for (int i = 0; i < interfaceNumber; i++) {
            addClassWithHierachy(interfaceList.getType(i).getClassName());
        }
    } catch (FileNotFoundException e) {
    // Ignore: The referenced type is not in the path it must be part of the libraries.
    }
}
Also used : DirectClassFile(com.android.dx.cf.direct.DirectClassFile) CstType(com.android.dx.rop.cst.CstType) FileNotFoundException(java.io.FileNotFoundException) StdTypeList(com.android.dx.rop.type.StdTypeList) TypeList(com.android.dx.rop.type.TypeList)

Example 3 with DirectClassFile

use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.

the class ClassReferenceListBuilder method addSupperClass.

public void addSupperClass(String name) {
    if (name.endsWith(CLASS_EXTENSION)) {
        classNames.add(name.substring(0, name.length() - CLASS_EXTENSION.length()));
    }
    if (name.endsWith(CLASS_EXTENSION)) {
        DirectClassFile classFile;
        try {
            classFile = path.getClass(name);
            CstType superClass = classFile.getSuperclass();
            if (superClass != null) {
                String superClassName = superClass.getClassType().getClassName();
                classNames.add(superClassName);
            }
        } catch (FileNotFoundException e) {
        //                throw new IOException("Class " + name +
        //                        " is missing form original class path " + path, e);
        }
    }
}
Also used : DirectClassFile(com.android.dx.cf.direct.DirectClassFile) CstType(com.android.dx.rop.cst.CstType) FileNotFoundException(java.io.FileNotFoundException)

Example 4 with DirectClassFile

use of com.android.dx.cf.direct.DirectClassFile in project bazel by bazelbuild.

the class Dexing method parseClassFile.

public static DirectClassFile parseClassFile(byte[] classfile, String classfilePath) {
    DirectClassFile result = new DirectClassFile(new ByteArray(classfile), classfilePath, /*strictParse*/
    false);
    result.setAttributeFactory(StdAttributeFactory.THE_ONE);
    // triggers the parsing
    result.getMagic();
    return result;
}
Also used : DirectClassFile(com.android.dx.cf.direct.DirectClassFile) ByteArray(com.android.dx.util.ByteArray)

Example 5 with DirectClassFile

use of com.android.dx.cf.direct.DirectClassFile in project buck by facebook.

the class Main method parseClass.

private DirectClassFile parseClass(String name, byte[] bytes) {
    DirectClassFile cf = new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck);
    cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    // triggers the actual parsing
    cf.getMagic();
    return cf;
}
Also used : DirectClassFile(com.android.dx.cf.direct.DirectClassFile)

Aggregations

DirectClassFile (com.android.dx.cf.direct.DirectClassFile)19 FileNotFoundException (java.io.FileNotFoundException)11 IOException (java.io.IOException)6 ByteArray (com.android.dx.util.ByteArray)5 CstType (com.android.dx.rop.cst.CstType)4 StdTypeList (com.android.dx.rop.type.StdTypeList)3 TypeList (com.android.dx.rop.type.TypeList)3 InputStream (java.io.InputStream)3 ZipEntry (java.util.zip.ZipEntry)3 File (java.io.File)2 BaseAnnotations (com.android.dx.cf.attrib.BaseAnnotations)1 ClassPathOpener (com.android.dx.cf.direct.ClassPathOpener)1 StdAttributeFactory (com.android.dx.cf.direct.StdAttributeFactory)1 Attribute (com.android.dx.cf.iface.Attribute)1 AttributeList (com.android.dx.cf.iface.AttributeList)1 DexOptions (com.android.dx.dex.DexOptions)1 CfOptions (com.android.dx.dex.cf.CfOptions)1 DexFile (com.android.dx.dex.file.DexFile)1 DexException (com.googlecode.d2j.DexException)1 ClassVisitorFactory (com.googlecode.d2j.dex.ClassVisitorFactory)1