当前位置: 首页>>代码示例>>Java>>正文


Java DirectClassFile.getSuperclass方法代码示例

本文整理汇总了Java中com.android.dx.cf.direct.DirectClassFile.getSuperclass方法的典型用法代码示例。如果您正苦于以下问题:Java DirectClassFile.getSuperclass方法的具体用法?Java DirectClassFile.getSuperclass怎么用?Java DirectClassFile.getSuperclass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.dx.cf.direct.DirectClassFile的用法示例。


在下文中一共展示了DirectClassFile.getSuperclass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addClassWithHierachy

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
private void addClassWithHierachy(String classBinaryName) {
    if (toKeep.contains(classBinaryName)) {
        return;
    }

    String fileName = classBinaryName + CLASS_EXTENSION;
    try {
        DirectClassFile classFile = path.getClass(fileName);
        toKeep.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.
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:24,代码来源:ClassReferenceListBuilder.java

示例2: addSupperClass

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
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);
            }

        }
    }
 
开发者ID:dodola,项目名称:RocooFix,代码行数:21,代码来源:ClassReferenceListBuilder.java

示例3: addClassWithHierachy

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
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.
    }
}
 
开发者ID:dodola,项目名称:RocooFix,代码行数:21,代码来源:ClassReferenceListBuilder.java

示例4: addClassWithHierachy

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
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.
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:23,代码来源:ClassReferenceListBuilder.java

示例5: addClassWithHierarchy

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
private void addClassWithHierarchy(String classBinaryName) {
    if (classNames.contains(classBinaryName)) {
        return;
    }

    try {
        DirectClassFile classFile = path.getClass(classBinaryName + CLASS_EXTENSION);
        if (CLASS_TO_CHECK != null && classBinaryName.contains(CLASS_TO_CHECK)) {
          found();
        }
        classNames.add(classBinaryName);
        CstType superClass = classFile.getSuperclass();
        if (superClass != null) {
            addClassWithHierarchy(superClass.getClassType().getClassName());
        }

        TypeList interfaceList = classFile.getInterfaces();
        int interfaceNumber = interfaceList.size();
        for (int i = 0; i < interfaceNumber; i++) {
            addClassWithHierarchy(interfaceList.getType(i).getClassName());
        }
    } catch (FileNotFoundException e) {
        // Ignore: The referenced type is not in the path it must be part of the libraries.
    }
}
 
开发者ID:facebook,项目名称:buck,代码行数:26,代码来源:ClassReferenceListBuilder.java

示例6: translate0

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Performs the main act of translation. This method is separated
 * from {@link #translate} just to keep things a bit simpler in
 * terms of exception handling.
 *
 * @param filePath {@code non-null;} the file path for the class,
 * excluding any base directory specification
 * @param bytes {@code non-null;} contents of the file
 * @param cfOptions options for class translation
 * @param dexOptions options for dex output
 * @return {@code non-null;} the translated class
 */
private static ClassDefItem translate0(String filePath, byte[] bytes,
        CfOptions cfOptions, DexOptions dexOptions) {
    DirectClassFile cf =
        new DirectClassFile(bytes, filePath, cfOptions.strictNameCheck);

    cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    cf.getMagic();

    OptimizerOptions.loadOptimizeLists(cfOptions.optimizeListFile,
            cfOptions.dontOptimizeListFile);

    // Build up a class to output.

    CstType thisClass = cf.getThisClass();
    int classAccessFlags = cf.getAccessFlags() & ~AccessFlags.ACC_SUPER;
    CstString sourceFile = (cfOptions.positionInfo == PositionList.NONE) ? null :
        cf.getSourceFile();
    ClassDefItem out =
        new ClassDefItem(thisClass, classAccessFlags,
                cf.getSuperclass(), cf.getInterfaces(), sourceFile);

    Annotations classAnnotations =
        AttributeTranslator.getClassAnnotations(cf, cfOptions);
    if (classAnnotations.size() != 0) {
        out.setClassAnnotations(classAnnotations);
    }

    processFields(cf, out);
    processMethods(cf, cfOptions, dexOptions, out);

    return out;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:45,代码来源:CfTranslator.java

示例7: translate0

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Performs the main act of translation. This method is separated
 * from {@link #translate} just to keep things a bit simpler in
 * terms of exception handling.
 *
 * @param cf {@code non-null;} the class file
 * @param bytes {@code non-null;} contents of the file
 * @param cfOptions options for class translation
 * @param dexOptions options for dex output
 * @param dexFile {@code non-null;} dex output
 * @return {@code non-null;} the translated class
 */
private static ClassDefItem translate0(DirectClassFile cf, byte[] bytes,
        CfOptions cfOptions, DexOptions dexOptions, DexFile dexFile) {

    OptimizerOptions.loadOptimizeLists(cfOptions.optimizeListFile,
            cfOptions.dontOptimizeListFile);

    // Build up a class to output.

    CstType thisClass = cf.getThisClass();
    int classAccessFlags = cf.getAccessFlags() & ~AccessFlags.ACC_SUPER;
    CstString sourceFile = (cfOptions.positionInfo == PositionList.NONE) ? null :
        cf.getSourceFile();
    ClassDefItem out =
        new ClassDefItem(thisClass, classAccessFlags,
                cf.getSuperclass(), cf.getInterfaces(), sourceFile);

    Annotations classAnnotations =
        AttributeTranslator.getClassAnnotations(cf, cfOptions);
    if (classAnnotations.size() != 0) {
        out.setClassAnnotations(classAnnotations, dexFile);
    }

    FieldIdsSection fieldIdsSection = dexFile.getFieldIds();
    MethodIdsSection methodIdsSection = dexFile.getMethodIds();
    processFields(cf, out, dexFile);
    processMethods(cf, cfOptions, dexOptions, out, dexFile);

    // intern constant pool method, field and type references
    ConstantPool constantPool = cf.getConstantPool();
    int constantPoolSize = constantPool.size();

    for (int i = 0; i < constantPoolSize; i++) {
        Constant constant = constantPool.getOrNull(i);
        if (constant instanceof CstMethodRef) {
            methodIdsSection.intern((CstBaseMethodRef) constant);
        } else if (constant instanceof CstInterfaceMethodRef) {
            methodIdsSection.intern(((CstInterfaceMethodRef) constant).toMethodRef());
        } else if (constant instanceof CstFieldRef) {
            fieldIdsSection.intern((CstFieldRef) constant);
        } else if (constant instanceof CstEnumRef) {
            fieldIdsSection.intern(((CstEnumRef) constant).getFieldRef());
        }
    }

    return out;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:59,代码来源:CfTranslator.java

示例8: processClass

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Creates an XMLVM element for the given type and appends it to the given
 * root element.
 * 
 * @param cf
 *            the {@link DirectClassFile} instance of this class
 * @param root
 *            the root element to append the generated element to
 * @param referencedTypes
 *            will be filled with the types references in this class file
 * @return the generated element
 */
private Element processClass(DirectClassFile cf, Element root,
        Map<String, ReferenceKind> referencedTypes) {
    Element classElement = new Element("class", NS_XMLVM);
    CstType type = cf.getThisClass();
    PackagePlusClassName parsedClassName = parseClassName(type.getClassType().getClassName());
    addReference(referencedTypes, parsedClassName.toString(), ReferenceKind.SELF);
    classElement.setAttribute("name", parsedClassName.className);
    classElement.setAttribute("package", parsedClassName.packageName);
    String superClassName = "";

    // if we are an innerclass add the enclosingMethod
    AttEnclosingMethod enclosingMethodAnnotation = (AttEnclosingMethod) cf.getAttributes().findFirst(
            AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethodAnnotation != null) {
        CstType enclosingClass=enclosingMethodAnnotation.getEnclosingClass();
        CstNat enclosingMethod = enclosingMethodAnnotation.getMethod();
        if(enclosingClass!=null){
            addReference(referencedTypes, enclosingClass.toHuman(), ReferenceKind.USAGE);
            classElement.setAttribute("enclosingClass", enclosingClass.toHuman());
        }
        if(enclosingMethod!=null){
            classElement.setAttribute("enclosingMethod", enclosingMethod.toHuman());
        }
    }
    
    //get signature annotation if availabke
    AttSignature signatureAnnotation=(AttSignature) cf.getAttributes().findFirst(
            AttSignature.ATTRIBUTE_NAME);
    
    if(signatureAnnotation!=null){
        classElement.setAttribute("signature", signatureAnnotation.getSignature().toHuman());
    }
    
    // This can happen for java.lang.Object.
    if (cf.getSuperclass() != null) {
        superClassName = parseClassName(cf.getSuperclass().getClassType().getClassName())
                .toString();
        addReference(referencedTypes, superClassName, ReferenceKind.SUPER_CLASS);
    }

    classElement.setAttribute("extends", superClassName);

    processAccessFlags(cf.getAccessFlags(), classElement);

    TypeList interfaces = cf.getInterfaces();
    if (interfaces.size() > 0) {
        String interfaceList = "";
        for (int i = 0; i < interfaces.size(); ++i) {
            if (i > 0) {
                interfaceList += ",";
            }
            String interfaceName = parseClassName(interfaces.getType(i).getClassName())
                    .toString();
            interfaceList += interfaceName;
            addReference(referencedTypes, interfaceName, ReferenceKind.INTERFACE);
        }
        classElement.setAttribute("interfaces", interfaceList);
    }

    root.addContent(classElement);
    return classElement;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:76,代码来源:DEXmlvmOutputProcess.java

示例9: analyze

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Performs the hierarchy analysis and returns the result.
 */
public TypeHierarchy analyze() {
    // Extract all class files.
    UniversalFile library = UniversalFileCreator.createDirectory(null, libraryPath);
    UniversalFile[] classes = library.listFilesRecursively(new UniversalFileFilter() {
        @Override
        public boolean accept(UniversalFile file) {
            return file.getName().toLowerCase().endsWith(".class");
        }
    });
    System.out.println("Getting type hierarchy for " + classes.length + " classes.");

    TypeHierarchy result = new TypeHierarchy();
    final String basePath = library.getAbsolutePath();
    for (UniversalFile clazz : classes) {
        String fileName = clazz.getRelativePath(basePath).replace('\\', '.');
        DirectClassFile classFile = new DirectClassFile(clazz.getFileAsBytes(), fileName, false);
        classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
        try {
            classFile.getMagic();
        } catch (ParseException ex) {
            continue;
        }

        final int DOT_CLASS_LENGTH = ".class".length();
        String className = fileName.substring(0, fileName.length() - DOT_CLASS_LENGTH).replace(
                '/', '.');

        // Super-class.
        if (classFile.getSuperclass() != null) {
            String superClassName = Util.parseClassName(
                    classFile.getSuperclass().getClassType().getClassName()).toString();
            result.addDirectSubType(className, superClassName);
        }

        // Interfaces
        TypeList interfaces = classFile.getInterfaces();
        if (interfaces != null) {
            for (int i = 0; i < interfaces.size(); i++) {
                String interfaceName = Util
                        .parseClassName(interfaces.getType(i).getClassName()).toString();
                result.addDirectSubType(className, interfaceName);
            }
        }
    }
    return result;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:50,代码来源:HierarchyAnalyzer.java

示例10: getAllDependencies

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Adds all dependencies of the given class to classDeps.
 */
private static void getAllDependencies(byte[] bytes, String relativePath,
        Dependencies.ClassDeps classDeps) {

    Log.debug(TAG, relativePath);
    DirectClassFile classFile = new DirectClassFile(bytes, relativePath, false);
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    try {
        classFile.getMagic();
    } catch (ParseException ex) {
        Log.warn(TAG, "Put to red-list as it couldn't be parsed: " + relativePath);
        BAD_CLASSES.add(classDeps.getClassName());
        return;
    }

    String superClassName = "";
    // This can happen for java.lang.Object.
    if (classFile.getSuperclass() != null) {
        superClassName = Util.parseClassName(
                classFile.getSuperclass().getClassType().getClassName()).toString();
    }

    // Super Class
    if (!superClassName.isEmpty()) {
        Set<String> superClass = new HashSet<String>();
        superClass.add(superClassName.replace('/', '.'));
        classDeps.getMethodDeps("SUPER").addDependency(superClassName.replace('/', '.'), "");
    }

    // Interfaces
    TypeList interfaces = classFile.getInterfaces();
    if (interfaces.size() > 0) {
        Set<String> interfaceList = new HashSet<String>();
        for (int i = 0; i < interfaces.size(); ++i) {
            interfaceList.add(Util.parseClassName(interfaces.getType(i).getClassName())
                    .toString());
            classDeps.getMethodDeps("INTERFACES").addDependency(
                    Util.parseClassName(interfaces.getType(i).getClassName()).toString(), "");
        }
    }

    // Methods
    MethodList methods = classFile.getMethods();
    for (int i = 0; i < methods.size(); i++) {
        Method method = methods.get(i);
        // CstMethodRef methodRef = new
        // CstMethodRef(method.getDefiningClass(), method.getNat());
        // We shouldn't need to go through the signature. If the class is
        // not used in the code block, we can ignore it.
        // processSignature(methodRef, dependencies);
        processCode(getCode(method, classFile),
                classDeps.getMethodDeps(method.getName().toHuman()));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:57,代码来源:JDKAnalyzer.java

示例11: translate0

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Performs the main act of translation. This method is separated
 * from {@link #translate} just to keep things a bit simpler in
 * terms of exception handling.
 *
 * @param filePath {@code non-null;} the file path for the class,
 * excluding any base directory specification
 * @param bytes {@code non-null;} contents of the file
 * @param cfOptions options for class translation
 * @param dexOptions options for dex output
 * @param optimizerOptions options for the optimizer
 * @return {@code non-null;} the translated class
 */
private static ClassDefItem translate0(DirectClassFile cf, byte[] bytes,
        CfOptions cfOptions, DexOptions dexOptions, OptimizerOptions optimizerOptions, DexFile dexFile) {

    optimizerOptions.loadOptimizeLists(cfOptions.optimizeListFile,
            cfOptions.dontOptimizeListFile);

    // Build up a class to output.

    CstType thisClass = cf.getThisClass();
    int classAccessFlags = cf.getAccessFlags() & ~AccessFlags.ACC_SUPER;
    CstString sourceFile = (cfOptions.positionInfo == PositionList.NONE) ? null :
        cf.getSourceFile();
    ClassDefItem out =
        new ClassDefItem(thisClass, classAccessFlags,
                cf.getSuperclass(), cf.getInterfaces(), sourceFile);

    Annotations classAnnotations =
        AttributeTranslator.getClassAnnotations(cf, cfOptions);
    if (classAnnotations.size() != 0) {
        out.setClassAnnotations(classAnnotations);
    }

    FieldIdsSection fieldIdsSection = dexFile.getFieldIds();
    MethodIdsSection methodIdsSection = dexFile.getMethodIds();
    TypeIdsSection typeIdsSection = dexFile.getTypeIds();
    processFields(cf, out, fieldIdsSection);
    processMethods(cf, cfOptions, dexOptions, optimizerOptions, out, methodIdsSection);

    // intern constant pool method, field and type references
    ConstantPool constantPool = cf.getConstantPool();
    int constantPoolSize = constantPool.size();

    for (int i = 0; i < constantPoolSize; i++) {
        Constant constant = constantPool.getOrNull(i);
        if (constant instanceof CstMethodRef) {
            methodIdsSection.intern((CstBaseMethodRef) constant);
        } else if (constant instanceof CstInterfaceMethodRef) {
            methodIdsSection.intern(((CstInterfaceMethodRef) constant).toMethodRef());
        } else if (constant instanceof CstFieldRef) {
            fieldIdsSection.intern((CstFieldRef) constant);
        } else if (constant instanceof CstEnumRef) {
            fieldIdsSection.intern(((CstEnumRef) constant).getFieldRef());
        } else if (constant instanceof CstType) {
            typeIdsSection.intern((CstType) constant);
        }
    }

    return out;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:63,代码来源:CfTranslator.java

示例12: translate0

import com.android.dx.cf.direct.DirectClassFile; //导入方法依赖的package包/类
/**
 * Performs the main act of translation. This method is separated
 * from {@link #translate} just to keep things a bit simpler in
 * terms of exception handling.
 *
 *
 * @param context
 * @param cf {@code non-null;} the class file
 * @param bytes {@code non-null;} contents of the file
 * @param cfOptions options for class translation
 * @param dexOptions options for dex output
 * @param dexFile {@code non-null;} dex output
 * @return {@code non-null;} the translated class
 */
private static ClassDefItem translate0(DxContext context, DirectClassFile cf, byte[] bytes,
                                       CfOptions cfOptions, DexOptions dexOptions, DexFile dexFile) {

    context.optimizerOptions.loadOptimizeLists(cfOptions.optimizeListFile,
            cfOptions.dontOptimizeListFile);

    // Build up a class to output.

    CstType thisClass = cf.getThisClass();
    int classAccessFlags = cf.getAccessFlags() & ~AccessFlags.ACC_SUPER;
    CstString sourceFile = (cfOptions.positionInfo == PositionList.NONE) ? null :
        cf.getSourceFile();
    ClassDefItem out =
        new ClassDefItem(thisClass, classAccessFlags,
                cf.getSuperclass(), cf.getInterfaces(), sourceFile);

    Annotations classAnnotations =
        AttributeTranslator.getClassAnnotations(cf, cfOptions);
    if (classAnnotations.size() != 0) {
        out.setClassAnnotations(classAnnotations, dexFile);
    }

    FieldIdsSection fieldIdsSection = dexFile.getFieldIds();
    MethodIdsSection methodIdsSection = dexFile.getMethodIds();
    processFields(cf, out, dexFile);
    processMethods(context, cf, cfOptions, dexOptions, out, dexFile);

    // intern constant pool method, field and type references
    ConstantPool constantPool = cf.getConstantPool();
    int constantPoolSize = constantPool.size();

    for (int i = 0; i < constantPoolSize; i++) {
        Constant constant = constantPool.getOrNull(i);
        if (constant instanceof CstMethodRef) {
            methodIdsSection.intern((CstBaseMethodRef) constant);
        } else if (constant instanceof CstInterfaceMethodRef) {
            methodIdsSection.intern(((CstInterfaceMethodRef) constant).toMethodRef());
        } else if (constant instanceof CstFieldRef) {
            fieldIdsSection.intern((CstFieldRef) constant);
        } else if (constant instanceof CstEnumRef) {
            fieldIdsSection.intern(((CstEnumRef) constant).getFieldRef());
        }
    }

    return out;
}
 
开发者ID:facebook,项目名称:buck,代码行数:61,代码来源:CfTranslator.java


注:本文中的com.android.dx.cf.direct.DirectClassFile.getSuperclass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。