if (!processAllFiles()) { return 1; outArray = writeDex(); outArray = mergeIncremental(outArray, incrementalOutFile); outArray = mergeLibraryDexBuffers(outArray); outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray); if (!createJar(args.outName)) { return 3; OutputStream out = openOutput(args.outName); out.write(outArray); closeOutput(out);
/** * Processes one file, which may be either a class or a resource. * * @param name {@code non-null;} name of the file * @param bytes {@code non-null;} contents of the file * @return whether processing was successful */ private static boolean processFileBytes(String name, byte[] bytes) { boolean isClass = name.endsWith(".class"); boolean keepResources = (outputResources != null); if (!isClass && !keepResources) { if (args.verbose) { DxConsole.out.println("ignored resource " + name); } return false; } if (args.verbose) { DxConsole.out.println("processing " + name + "..."); } String fixedName = fixPath(name); if (isClass) { if (keepResources && args.keepClassesInJar) { outputResources.put(fixedName, bytes); } return processClass(fixedName, bytes); } else { outputResources.put(fixedName, bytes); return true; } }
/** * Run and return a result code. * @param arguments the data + parameters for the conversion * @return 0 if success > 0 otherwise. */ public static int run(Arguments arguments) { // Reset the error/warning count to start fresh. warnings = 0; errors = 0; args = arguments; args.makeCfOptions(); if (!processAllFiles()) { return 1; } byte[] outArray = writeDex(); if (outArray == null) { return 2; } if (args.jarOutput) { // Effectively free up the (often massive) DexFile memory. outputDex = null; if (!createJar(args.outName, outArray)) { return 3; } } return 0; }
public int runDx(Arguments arguments) throws IOException { // Reset the error count to start fresh. errors.set(0); args = arguments; args.makeOptionsObjects(); OutputStream humanOutRaw = null; if (args.humanOutName != null) { humanOutRaw = openOutput(args.humanOutName); humanOutWriter = new OutputStreamWriter(humanOutRaw); } try { return runMonoDex(); } finally { closeOutput(humanOutRaw); } }
/** * Run and return a result code. * @param arguments the data + parameters for the conversion * @return 0 if success > 0 otherwise. */ public static int run(Arguments arguments) throws IOException { // Reset the error count to start fresh. errors.set(0); // empty the list, so that tools that load dx and keep it around // for multiple runs don't reuse older buffers. libraryDexBuffers.clear(); args = arguments; args.makeOptionsObjects(); OutputStream humanOutRaw = null; if (args.humanOutName != null) { humanOutRaw = openOutput(args.humanOutName); humanOutWriter = new OutputStreamWriter(humanOutRaw); } try { if (args.multiDex) { return runMultiDex(); } else { return runMonoDex(); } } finally { closeOutput(humanOutRaw); } }
classesInMainDex = readPathsFromFile(args.mainDexListFile); if (!processAllFiles()) { return 1; dexOutputArrays.add(writeDex()); outputResources.put(getDexFileName(i), dexOutputArrays.get(i)); if (!createJar(args.outName)) { return 3; assert outDir.isDirectory(); for (int i = 0; i < dexOutputArrays.size(); i++) { OutputStream out = new FileOutputStream(new File(outDir, getDexFileName(i))); try { out.write(dexOutputArrays.get(i)); } finally { closeOutput(out);
Manifest manifest = makeManifest(); OutputStream out = openOutput(fileName); JarOutputStream jarOut = new JarOutputStream(out, manifest); jarOut.finish(); jarOut.flush(); closeOutput(out);
private int runMonoDex() throws IOException { if (!processAllFiles()) { return 1; } // this array is null if no classes were defined byte[] outArray = null; if (!outputDex.isEmpty() || (args.humanOutName != null)) { outArray = writeDex(outputDex); if (outArray == null) { return 2; } } if (args.jarOutput) { // Effectively free up the (often massive) DexFile memory. outputDex = null; if (outArray != null) { outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray); } if (!createJar(args.outName)) { return 3; } } else if (outArray != null && args.outName != null) { OutputStream out = openOutput(args.outName); out.write(outArray); closeOutput(out); } return 0; }
try { if (args.humanOutName != null) { humanOutRaw = openOutput(args.humanOutName); humanOut = new OutputStreamWriter(humanOutRaw); dumpMethod(outputDex, args.methodToDump, humanOut); } else { out = openOutput(args.outName); out.write(outArray); humanOut.flush(); closeOutput(out); closeOutput(humanOutRaw);
createDexFile(); processOne(fileNames[i], mainPassFilter); rotateDexFile(); processOne(fileNames[i], new NotFilter(mainPassFilter)); processOne(fileNames[i], ClassPathOpener.acceptAll);
boolean isClassesDex = isClassesDexFile(name); boolean keepResources = (outputResources != null); String fixedName = fixPath(name); return true; processClass(fixedName, bytes);
createDexFile(); processOne(fileNames[i], ClassPathOpener.acceptAll);
/** * 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); } try { new DirectClassFileConsumer(name, bytes, null).call( new ClassParserTask(name, bytes).call()); } catch(Exception ex) { throw new RuntimeException("Exception parsing classes", ex); } return true; }
private static void readPathsFromFile(String fileName, Collection<String> paths) throws IOException { BufferedReader bfr = null; try { FileReader fr = new FileReader(fileName); bfr = new BufferedReader(fr); String line; while (null != (line = bfr.readLine())) { paths.add(fixPath(line)); } } finally { if (bfr != null) { bfr.close(); } } }
dumpMethod(outputDex, args.methodToDump, humanOutWriter); } else {
checkClassName(name); (maxFieldIdsInDex > args.maxNumberOfIdxPerDex))) { DexFile completeDex = outputDex; createDexFile(); assert (completeDex.getMethodIds().items().size() <= numMethodIds + MAX_METHOD_ADDED_DURING_DEX_CREATION) &&
if (processOne(fileNames[i])) { anyFilesProcessed = true;
readPathsFromFile(args.mainDexListFile, classesInMainDex); if (!processAllFiles()) { return 1; outputResources.put(getDexFileName(i), dexOutputArrays.get(i)); if (!createJar(args.outName)) { return 3; assert outDir.isDirectory(); for (int i = 0; i < dexOutputArrays.size(); i++) { OutputStream out = new FileOutputStream(new File(outDir, getDexFileName(i))); try { out.write(dexOutputArrays.get(i)); } finally { closeOutput(out);
Manifest manifest = makeManifest(); OutputStream out = openOutput(fileName); JarOutputStream jarOut = new JarOutputStream(out, manifest); jarOut.finish(); jarOut.flush(); closeOutput(out);
public int runDx(Arguments arguments) throws IOException { // Reset the error count to start fresh. errors.set(0); // empty the list, so that tools that load dx and keep it around // for multiple runs don't reuse older buffers. libraryDexBuffers.clear(); args = arguments; args.makeOptionsObjects(); OutputStream humanOutRaw = null; if (args.humanOutName != null) { humanOutRaw = openOutput(args.humanOutName); humanOutWriter = new OutputStreamWriter(humanOutRaw); } try { if (args.multiDex) { return runMultiDex(); } else { return runMonoDex(); } } finally { closeOutput(humanOutRaw); } }