use of com.taobao.android.dex.Dex in project atlas by alibaba.
the class MergePatch method getDexFromJar.
private Dex getDexFromJar(File file) throws IOException {
JarFile jarFile = null;
try {
jarFile = new JarFile(file);
JarEntry dexEntry = jarFile.getJarEntry("classes.dex");
return new Dex(jarFile.getInputStream(dexEntry));
} finally {
if (jarFile != null) {
jarFile.close();
}
}
}
use of com.taobao.android.dex.Dex in project atlas by alibaba.
the class Main method main.
public static void main(String[] args) throws IOException {
String dexFile = args[0];
String pattern = args[1];
Dex dex = new Dex(new File(dexFile));
int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep();
System.exit((count > 0) ? 0 : 1);
}
use of com.taobao.android.dex.Dex in project atlas by alibaba.
the class Main method main.
public static void main(String[] args) throws IOException {
String dexFile = args[0];
String declaredBy = args[1];
String memberName = args[2];
Dex dex = new Dex(new File(dexFile));
PrintWriter out = new PrintWriter(System.out);
new FindUsages(dex, declaredBy, memberName, out).findUsages();
out.flush();
}
use of com.taobao.android.dex.Dex in project atlas by alibaba.
the class DexMerger method merge.
public Dex merge() throws IOException {
long start = System.nanoTime();
Dex result = mergeDexes();
/*
* We use pessimistic sizes when merging dex files. If those sizes
* result in too many bytes wasted, compact the result. To compact,
* simply merge the result with itself.
*/
WriterSizes compactedSizes = new WriterSizes(this);
int wastedByteCount = writerSizes.size() - compactedSizes.size();
if (wastedByteCount > +compactWasteThreshold) {
DexMerger compacter = new DexMerger(ImmutableList.of(dexOut, new Dex(0)), CollisionPolicy.FAIL, compactedSizes);
result = compacter.mergeDexes();
// System.out.printf("Result compacted from %.1fKiB to %.1fKiB to save %.1fKiB%n",
// dexOut.getLength() / 1024f,
// result.getLength() / 1024f,
// wastedByteCount / 1024f);
}
int origDefs = 0;
int origSizes = 0;
for (Dex d : dexs) {
origDefs += d.getTableOfContents().classDefs.size;
origSizes += d.getLength();
}
long elapsed = System.nanoTime() - start;
return result;
}
use of com.taobao.android.dex.Dex in project atlas by alibaba.
the class DexBuilderUtils method mergeDex.
/**
* 合并dex
* @param dexs
* @param outDexFile
* @param policy
* @return
* @throws IOException
*/
public static File mergeDex(List<File> dexs, File outDexFile, CollisionPolicy policy) throws IOException {
List<Dex> dexList = new ArrayList<Dex>();
for (File dexFile : dexs) {
dexList.add(new Dex(dexFile));
}
// Dex[] dexArray = new Dex[dexList.size()];
// dexList.toArray(dexArray);
DexMerger merger = new DexMerger(dexList, policy);
Dex outDex = merger.merge();
outDex.writeTo(outDexFile);
return outDexFile;
}
Aggregations