本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}