本文整理汇总了Java中org.jf.dexlib2.writer.pool.DexPool.writeTo方法的典型用法代码示例。如果您正苦于以下问题:Java DexPool.writeTo方法的具体用法?Java DexPool.writeTo怎么用?Java DexPool.writeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.writer.pool.DexPool
的用法示例。
在下文中一共展示了DexPool.writeTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRawDexSingleThread
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
static void writeRawDexSingleThread(DexDataStore dataStore, DexFile dexFile, int maxDexPoolSize,
DexIO.Logger logger, File file) throws IOException {
Set<? extends ClassDef> classes = dexFile.getClasses();
Iterator<? extends ClassDef> classIterator = classes.iterator();
DexPool dexPool = new DexPool(dexFile.getOpcodes());
int classCount = 0;
while (classIterator.hasNext()) {
ClassDef classDef = classIterator.next();
dexPool.internClass(classDef);
if (getDexPoolOverflow(dexPool, maxDexPoolSize)) {
handleDexPoolOverflow(classDef, classCount, classes.size());
throw new AssertionError("unexpected type count");
}
classCount++;
}
if (logger != null) logger.log(file, SingletonDexContainer.UNDEFINED_ENTRY_NAME, classCount);
dexPool.writeTo(dataStore);
}
示例2: merge
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
public void merge(){
try {
DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
dexfile.setaddDexFile(addfile, new FilterClassDef() {
@Override
public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
// TODO Auto-generated method stub
String className = classDef.getType();
if (ADD_ALL) {
if (!className.startsWith("Landroid") &&
!className.startsWith("Ljava") &&
!className.startsWith("Ldalvik")) {
return classDef;
}else{
return null;
}
}
if (internedItem.containsKey(className)) {
System.out.println("contain " + className);
return classDef;
}
return null;
}
});
DexRewriter rewriter = new DexRewriter(new RewriterModule());
DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
DexPool.writeTo(config.outPath, rewrittenDexFile);
config.hasModifed = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: writeDexFile
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
public static void writeDexFile(String path, DexFile dexFile) throws IOException {
DexPool.writeTo(path, dexFile);
}
示例4: rewriteDex
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
public void rewriteDex(final onWriteListener listener) throws IOException {
final DexRewriter rewriter = new DexRewriter(new RewriterModule() {
@Nonnull
@Override
public Rewriter<Method> getMethodRewriter(@Nonnull Rewriters rewriters) {
return new MethodRewriter(rewriters) {
@Nonnull
@Override
public Method rewrite(@Nonnull Method value) {
if (listener != null) {
final MethodImplementation implementation = listener.rewriteMethod(value);
if (implementation != null) {
return new RewrittenMethod(value){
public MethodImplementation getImplementation() {
return implementation;
}
};
}
}
return new RewrittenMethod(value);
}
};
}
// @Nonnull
// public Rewriter<ClassDef> getClassDefRewriter(@Nonnull Rewriters rewriters){
// return new ClassDefRewriter(rewriters){
// @Nonnull
// @Override
// public ClassDef rewrite(@Nonnull ClassDef classDef) {
// return new RewrittenClassDef(classDef){
// @Nonnull
// @Override
// public Iterable<? extends Method> getVirtualMethods(){
// if (listener != null) {
// final List<Method> addmethods = listener.addMethods(classDef);
// if (addmethods != null && addmethods.size() > 0) {
// Iterable<Method> tmp = new Iterable<Method>() {
// @Override
// public Iterator<Method> iterator() {
// Iterable<? extends Method> iterator = classDef.getVirtualMethods();
// return Iterators.concat(iterator.iterator(), addmethods.iterator());
// }
// };
// return RewriterUtils.rewriteIterable(rewriters.getMethodRewriter(), tmp);
// }
// }
// return RewriterUtils.rewriteIterable(rewriters.getMethodRewriter(), classDef.getVirtualMethods());
// }
// };
// }
// };
// }
}) {
@Nonnull
@Override
public DexFile rewriteDexFile(@Nonnull DexFile dexFile) {
return new RewrittenDexFile(dexFile) {
@Nonnull
@Override
public Set<? extends ClassDef> getClasses() {
Set<? extends ClassDef> classes = dexFile.getClasses();
if (listener != null) {
Set<ClassDef> addclasses = listener.addClasses();
addclasses.addAll(classes);
return RewriterUtils.rewriteSet(getClassDefRewriter(), addclasses);
}
return RewriterUtils.rewriteSet(getClassDefRewriter(), dexfile.getClasses());
}
};
}
};
DexFile rewritefile = rewriter.rewriteDexFile(dexfile);
DexPool.writeTo("out.dex", rewritefile);
}
示例5: writeDexFile
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
public static void writeDexFile(@Nonnull String path, @Nonnull DexFile dexFile) throws IOException {
DexPool.writeTo(path, dexFile);
}
示例6: modify
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
public void modify() throws IOException{
DexFile rewrittenDexFile = rewriter.rewriteDexFile(this.dexFile);
DexPool.writeTo(config.outPath, rewrittenDexFile);
config.hasModifed = true;
}
示例7: writeDexFile
import org.jf.dexlib2.writer.pool.DexPool; //导入方法依赖的package包/类
/**
* Writes a DexFile out to disk
*
* @param path The path to write the dex file to
* @param dexFile a DexFile to write
*/
public static void writeDexFile( String path, DexFile dexFile) throws IOException {
DexPool.writeTo(path, dexFile);
}