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


Java DirectClassFile类代码示例

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


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

示例1: dump

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * Does the dumping.
 */
public void dump() {
    byte[] bytes = getBytes();
    ByteArray ba = new ByteArray(bytes);
    DirectClassFile cf =
        new DirectClassFile(ba, getFilePath(), getStrictParse());

    cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    cf.setObserver(this);
    cf.getMagic(); // Force parsing to happen.

    int at = getAt();
    if (at != bytes.length) {
        parsed(ba, at, bytes.length - at, "<extra data at end of file>");
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:ClassDumper.java

示例2: dump

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * Does the dumping.
 */
public void dump() {
    byte[] bytes = getBytes();
    ByteArray ba = new ByteArray(bytes);

    /*
     * First, parse the file completely, so we can safely refer to
     * attributes, etc.
     */
    classFile = new DirectClassFile(ba, getFilePath(), getStrictParse());
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    classFile.getMagic(); // Force parsing to happen.

    // Next, reparse it and observe the process.
    DirectClassFile liveCf =
        new DirectClassFile(ba, getFilePath(), getStrictParse());
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    liveCf.getMagic(); // Force parsing to happen.
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:BlockDumper.java

示例3: run

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
private void run() {
    ByteArray ba = new ByteArray(bytes);

    /*
     * First, parse the file completely, so we can safely refer to
     * attributes, etc.
     */
    classFile = new DirectClassFile(ba, filePath, strictParse);
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    classFile.getMagic(); // Force parsing to happen.

    // Next, reparse it and observe the process.
    DirectClassFile liveCf =
        new DirectClassFile(ba, filePath, strictParse);
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    liveCf.getMagic(); // Force parsing to happen.
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:DotDumper.java

示例4: visitClassAnnotation

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * Inspects a class annotation.
 *
 * @param cf {@code non-null;} class file
 * @param ann {@code non-null;} annotation
 */
private void visitClassAnnotation(DirectClassFile cf,
        BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.TYPE)) {
        return;
    }

    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatch(cf);
        }
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:AnnotationLister.java

示例5: printMatch

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * Prints, or schedules for printing, elements related to a matching
 * class.
 *
 * @param cf {@code non-null;} matching class
 */
private void printMatch(DirectClassFile cf) {
    for (Main.PrintType pt : args.printTypes) {
        switch (pt) {
            case CLASS:
                String classname;
                classname =
                    cf.getThisClass().getClassType().getClassName();
                classname = classname.replace('/','.');
                System.out.println(classname);
                break;
            case INNERCLASS:
                matchInnerClassesOf.add(
                        cf.getThisClass().getClassType().getClassName());
                break;
            case METHOD:
                //TODO
                break;
            case PACKAGE:
                break;
        }
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:29,代码来源:AnnotationLister.java

示例6: 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

示例7: defineClass

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Class<?> defineClass(String name, byte[] data) {
    try {
        DexOptions dexOptions = new DexOptions();
        DexFile dexFile = new DexFile(dexOptions);
        DirectClassFile classFile = new DirectClassFile(data, name.replace('.', '/') + ".class", true);
        classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
        classFile.getMagic();
        dexFile.add(CfTranslator.translate(classFile, null, new CfOptions(), dexOptions, dexFile));
        Dex dex = new Dex(dexFile.toDex(null, false));
        Dex oldDex = getLastDex();
        if (oldDex != null) {
            dex = new DexMerger(new Dex[]{dex, oldDex}, CollisionPolicy.KEEP_FIRST).merge();
        }
        return loadClass(dex, name);
    } catch (IOException | ClassNotFoundException e) {
        throw new FatalLoadingException(e);
    }
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:23,代码来源:BaseAndroidClassLoader.java

示例8: 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

示例9: addRootsV2

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

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

示例10: addDependencies

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
private void addDependencies(DirectClassFile classFile) {
    for (Constant constant : classFile.getConstantPool().getEntries()) {
        if (constant instanceof CstType) {
            checkDescriptor(((CstType) constant).getClassType().getDescriptor());
        } else if (constant instanceof CstFieldRef) {
            checkDescriptor(((CstFieldRef) constant).getType().getDescriptor());
        } else if (constant instanceof CstBaseMethodRef) {
            checkPrototype(((CstBaseMethodRef) constant).getPrototype());
        }
    }
    FieldList fields = classFile.getFields();
    int nbField = fields.size();
    for (int i = 0; i < nbField; i++) {
      checkDescriptor(fields.get(i).getDescriptor().getString());
    }
    MethodList methods = classFile.getMethods();
    int nbMethods = methods.size();
    for (int i = 0; i < nbMethods; i++) {
      checkPrototype(Prototype.intern(methods.get(i).getDescriptor().getString()));
    }
}
 
开发者ID:dodola,项目名称:RocooFix,代码行数:22,代码来源:ClassReferenceListBuilder.java

示例11: 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

示例12: addDependencies

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
private void addDependencies(DirectClassFile classFile) {
    for (Constant constant : classFile.getConstantPool().getEntries()) {
        if (constant instanceof CstType) {
            checkDescriptor(((CstType) constant).getClassType().getDescriptor());
        } else if (constant instanceof CstFieldRef) {
            checkDescriptor(((CstFieldRef) constant).getType().getDescriptor());
        } else if (constant instanceof CstBaseMethodRef) {
            checkPrototype(((CstBaseMethodRef) constant).getPrototype());
        }
    }

    FieldList fields = classFile.getFields();
    int nbField = fields.size();
    for (int i = 0; i < nbField; i++) {
      checkDescriptor(fields.get(i).getDescriptor().getString());
    }

    MethodList methods = classFile.getMethods();
    int nbMethods = methods.size();
    for (int i = 0; i < nbMethods; i++) {
      checkPrototype(Prototype.intern(methods.get(i).getDescriptor().getString()));
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:24,代码来源:ClassReferenceListBuilder.java

示例13: 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

示例14: getCode

import com.android.dx.cf.direct.DirectClassFile; //导入依赖的package包/类
/**
 * Extracts the code block from the given method of the given class, or
 * <code>null</code>, if method is native or abstract.
 */
private static DalvCode getCode(Method method, DirectClassFile classFile) {
    boolean isNative = AccessFlags.isNative(method.getAccessFlags());
    boolean isStatic = AccessFlags.isStatic(method.getAccessFlags());
    boolean isAbstract = AccessFlags.isAbstract(method.getAccessFlags());

    if (isNative || isAbstract) {
        return null;
    }

    ConcreteMethod concrete = new ConcreteMethod(method, classFile, false, false);
    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth = Ropper.convert(concrete, advice);
    CstMethodRef meth = new CstMethodRef(method.getDefiningClass(), method.getNat());
    int paramSize = meth.getParameterWordCount(isStatic);
    DalvCode code = RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize);
    DalvCode.AssignIndicesCallback callback = new DalvCode.AssignIndicesCallback() {
        public int getIndex(Constant cst) {
            // Everything is at index 0!
            return 0;
        }
    };
    code.assignIndices(callback);
    return code;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:JDKAnalyzer.java


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