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


Java CfTranslator.translate方法代码示例

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


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

示例1: processClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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.cf.CfTranslator; //导入方法依赖的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: translateClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例4: translateClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例5: generateDexFile

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例6: addToDexFile

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例7: translateClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例8: addClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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

示例9: processClass

import com.android.dx.dex.cf.CfTranslator; //导入方法依赖的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.cf.CfTranslator.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。