• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ClassDefItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: processClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
/**
 * Processes one classfile.
 *
 * @param name {@code non-null;} name of the file, clipped such that it
 * <i>should</i> correspond to the name of the class it contains
 * @param bytes {@code non-null;} contents of the file
 * @return whether processing was successful
 */
private static boolean processClass(String name, byte[] bytes) {
    if (! args.coreLibrary) {
        checkClassName(name);
    }

    try {
        ClassDefItem clazz =
            CfTranslator.translate(name, bytes, args.cfOptions, args.dexOptions);
        synchronized (outputDex) {
            outputDex.add(clazz);
        }
        return true;
    } catch (ParseException ex) {
        DxConsole.err.println("\ntrouble processing:");
        if (args.debug) {
            ex.printStackTrace(DxConsole.err);
        } else {
            ex.printContext(DxConsole.err);
        }
    }

    warnings++;
    return false;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:33,代码来源:Main.java


示例2: translateClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) {
    try {
        return CfTranslator.translate(cf, bytes, cfOptions, dexOptions, outputDex);
    } catch (ParseException e) {
        e.printStackTrace();
        errors.incrementAndGet();
        return null;
    }
}
 
开发者ID:imkiva,项目名称:Krine,代码行数:10,代码来源:DexConverter.java


示例3: ClassDefItemConsumer

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private ClassDefItemConsumer(DexConverter converter, String name, Future<ClassDefItem> futureClazz, int maxMethodIdsInClass, int maxFieldIdsInClass) {
    this.dexConverter = converter;
    this.name = name;
    this.futureClazz = futureClazz;
    this.maxMethodIdsInClass = maxMethodIdsInClass;
    this.maxFieldIdsInClass = maxFieldIdsInClass;
}
 
开发者ID:imkiva,项目名称:Krine,代码行数:8,代码来源:DexConverter.java


示例4: call

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
public Boolean call() throws Exception {
    try {
        ClassDefItem ex = this.futureClazz.get();
        if (ex != null) {
            dexConverter.addClassToDex(ex);
        }
    } catch (ExecutionException e) {
        Throwable t = e.getCause();
        throw t instanceof Exception ? (Exception) t : e;
    }
    return true;
}
 
开发者ID:imkiva,项目名称:Krine,代码行数:13,代码来源:DexConverter.java


示例5: translateClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private static ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) {
    try {
        return CfTranslator.translate(cf, bytes, args.cfOptions,
                args.dexOptions, outputDex);
    } catch (ParseException ex) {
        System.err.println("\ntrouble processing:");
        if (args.debug) {
            ex.printStackTrace(System.err);
        } else {
            ex.printContext(System.err);
        }
    }
    errors.incrementAndGet();
    return null;
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:16,代码来源:Dexer.java


示例6: ClassDefItemConsumer

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private ClassDefItemConsumer(String name, Future<ClassDefItem> futureClazz,
        int maxMethodIdsInClass, int maxFieldIdsInClass) {
    this.name = name;
    this.futureClazz = futureClazz;
    this.maxMethodIdsInClass = maxMethodIdsInClass;
    this.maxFieldIdsInClass = maxFieldIdsInClass;
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:8,代码来源:Dexer.java


示例7: call

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
    try {
        ClassDefItem clazz = futureClazz.get();
        if (clazz != null) {
            addClassToDex(clazz);
            updateStatus(true);
        }
        return true;
    } catch(ExecutionException ex) {
        // Rethrow previously uncaught translation exceptions.
        // These, as well as any exceptions from addClassToDex,
        // are handled and reported in processAllFiles().
        Throwable t = ex.getCause();
        throw (t instanceof Exception) ? (Exception) t : ex;
    } finally {
        if (args.multiDex) {
            // Having added our actual indicies to the dex file,
            // we subtract our original estimate from the total estimate,
            // and signal the translation phase, which may be paused
            // waiting to determine if more classes can be added to the
            // current dex file, or if a new dex file must be created.
            synchronized(dexRotationLock) {
                maxMethodIdsInProcess -= maxMethodIdsInClass;
                maxFieldIdsInProcess -= maxFieldIdsInClass;
                dexRotationLock.notifyAll();
            }
        }
    }
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:31,代码来源:Dexer.java


示例8: translate0

import com.android.dx.dex.file.ClassDefItem; //导入依赖的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


示例9: translateClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private static ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) {
    try {
        return CfTranslator.translate(cf, bytes, args.cfOptions,
                args.dexOptions, outputDex);
    } catch (ParseException ex) {
        DxConsole.err.println("\ntrouble processing:");
        if (args.debug) {
            ex.printStackTrace(DxConsole.err);
        } else {
            ex.printContext(DxConsole.err);
        }
    }
    errors.incrementAndGet();
    return null;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:16,代码来源:Main.java


示例10: generateDexFile

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private OutputFile generateDexFile(OutputFile classFile) {
    if (!classFile.getFullPath().startsWith(arguments.option_out())) {
        Log.error("DexOutputProcess: Something is wrong with the class output path.");
        return null;
    }
    String relativePath = classFile.getFullPath()
            .substring(arguments.option_out().length() + 1);

    // Remove a starting slash or backslash.
    if (relativePath.startsWith("/") || relativePath.startsWith("\\")) {
        relativePath = relativePath.substring(1);
    }
    Log.debug("DExing:" + relativePath);

    CfOptions options = new CfOptions();
    options.strictNameCheck = false;
    ClassDefItem item = CfTranslator.translate(relativePath, classFile.getDataAsBytes(),
            options);
    DexFile dexFile = new DexFile();
    dexFile.add(item);
    try {
        byte[] rawDex = dexFile.toDex(null, false);
        OutputFile result = new OutputFile(rawDex);
        result.setLocation(classFile.getLocation());
        result.setFileName(classFile.getFileName().replace(ClassFile.CLASS_ENDING, DEX_ENDING));
        return result;
    } catch (IOException e) {
        e.printStackTrace();
        Log.error("Could not generate DEX file.");
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:33,代码来源:DexOutputProcess.java


示例11: addToMethod

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
/**
 * Add this annotation to a method.
 *
 * @param dexMaker DexMaker instance.
 * @param method Method to be added to.
 */
public void addToMethod(DexMaker dexMaker, MethodId<?, ?> method) {
    if (annotatedElement != ElementType.METHOD) {
        throw new IllegalStateException("This annotation is not for method");
    }

    if (method.declaringType != declaringType) {
        throw new IllegalArgumentException("Method" + method + "'s declaring type is inconsistent with" + this);
    }

    ClassDefItem classDefItem = dexMaker.getTypeDeclaration(declaringType).toClassDefItem();

    if (classDefItem == null) {
        throw new NullPointerException("No class defined item is found");
    } else {
        CstMethodRef cstMethodRef = method.constant;

        if (cstMethodRef == null) {
            throw new NullPointerException("Method reference is NULL");
        } else {
            // Generate CstType
            CstType cstType = CstType.intern(type.ropType);

            // Generate Annotation
            Annotation annotation = new Annotation(cstType, AnnotationVisibility.RUNTIME);

            // Add generated annotation
            Annotations annotations = new Annotations();
            for (NameValuePair nvp : elements.values()) {
                annotation.add(nvp);
            }
            annotations.add(annotation);
            classDefItem.addMethodAnnotations(cstMethodRef, annotations, dexMaker.getDexFile());
        }
    }
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:42,代码来源:AnnotationId.java


示例12: addToDexFile

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
public ClassDefItem addToDexFile(DexFile dest, DirectClassFile classFile) {
  ClassDefItem result = CfTranslator.translate(
      context,
      classFile,
      (byte[]) null /*ignored*/,
      cfOptions,
      dest.getDexOptions(),
      dest);
  dest.add(result);
  return result;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:12,代码来源:Dexing.java


示例13: translateClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) {
    try {
        return CfTranslator.translate(context, cf, bytes, args.cfOptions,
            args.dexOptions, outputDex);
    } catch (ParseException ex) {
        context.err.println("\ntrouble processing:");
        if (args.debug) {
            ex.printStackTrace(context.err);
        } else {
            ex.printContext(context.err);
        }
    }
    errors.incrementAndGet();
    return null;
}
 
开发者ID:facebook,项目名称:buck,代码行数:16,代码来源:Main.java


示例14: ClassDefItemConsumer

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private ClassDefItemConsumer(String name, Future<ClassDefItem> futureClazz,
    int maxMethodIdsInClass, int maxFieldIdsInClass) {
    this.name = name;
    this.futureClazz = futureClazz;
    this.maxMethodIdsInClass = maxMethodIdsInClass;
    this.maxFieldIdsInClass = maxFieldIdsInClass;
}
 
开发者ID:facebook,项目名称:buck,代码行数:8,代码来源:Main.java


示例15: addClassToDex

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private boolean addClassToDex(ClassDefItem clazz) {
    synchronized (outputDex) {
        outputDex.add(clazz);
        return true;
    }
}
 
开发者ID:imkiva,项目名称:Krine,代码行数:7,代码来源:DexConverter.java


示例16: translate0

import com.android.dx.dex.file.ClassDefItem; //导入依赖的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


示例17: addClassToDex

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
private static boolean addClassToDex(ClassDefItem clazz) {
    synchronized (outputDex) {
        outputDex.add(clazz);
    }
    return true;
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:7,代码来源:Dexer.java


示例18: addClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
public void addClass(String nameClass, byte[] byteClass) {
    final CfOptions cf_options = new CfOptions();
    //System.out.println(nameClass);
    final ClassDefItem cdi = CfTranslator.translate(nameClass, byteClass, cf_options, dex_options);
    file.add(cdi);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:7,代码来源:DexFile.java


示例19: translate0

import com.android.dx.dex.file.ClassDefItem; //导入依赖的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


示例20: processClass

import com.android.dx.dex.file.ClassDefItem; //导入依赖的package包/类
/**
 * Processes one classfile.
 *
 * @param name {@code non-null;} name of the file, clipped such that it
 * <i>should</i> correspond to the name of the class it contains
 * @param bytes {@code non-null;} contents of the file
 * @return whether processing was successful
 */
private boolean processClass(String name, byte[] bytes) {
    if (! args.coreLibrary) {
        checkClassName(name);
    }

    DirectClassFile cf =
        new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck);

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

    int numMethodIds = outputDex.getMethodIds().items().size();
    int numFieldIds = outputDex.getFieldIds().items().size();
    int numTypeIds = outputDex.getTypeIds().items().size();
    int constantPoolSize = cf.getConstantPool().size();

    if (args.multiDex && ((numMethodIds + constantPoolSize > args.maxNumberOfIdxPerDex) ||
        (numFieldIds + constantPoolSize > args.maxNumberOfIdxPerDex) ||
        (numTypeIds + constantPoolSize
                /* annotation added by dx are not counted in numTypeIds */
                + AnnotationUtils.DALVIK_ANNOTATION_NUMBER
                > args.maxNumberOfIdxPerDex))) {
      createDexFile();
    }

    try {
        ClassDefItem clazz =
            CfTranslator.translate(cf, bytes, args.cfOptions, args.dexOptions, args.optimizerOptions, outputDex);
        synchronized (outputDex) {
            outputDex.add(clazz);
        }
        return true;

    } catch (ParseException ex) {
        dxConsole.err.println("\ntrouble processing:");
        if (args.debug) {
            ex.printStackTrace(dxConsole.err);
        } else {
            ex.printContext(dxConsole.err);
        }
    }
    errors++;
    return false;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:53,代码来源:Main.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogKeywords类代码示例发布时间:2022-05-22
下一篇:
Java SPacketChunkData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap