public byte[] convert(String javaFile) throws JadxException { try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream()) { DxContext context = new DxContext(out, errOut); DxArgs args = new DxArgs(context, "-", new String[]{javaFile}); int result = (new Main(context)).runDx(args); dxErrors = errOut.toString(CHARSET_NAME); if (result != 0) { throw new JadxException("Java to dex conversion error, code: " + result); } return out.toByteArray(); } catch (Exception e) { throw new JadxException("dx exception: " + e.getMessage(), e); } }
com.android.dx.dex.file.DexFile dxFile = new com.android.dx.dex.file.DexFile(dexOptions); try { CfTranslator.translate(new DxContext(), dcf, data, cfOptions, dexOptions, dxFile); } catch (ParseException e) { if ("MethodHandle not supported".equals(e.getMessage())) {
public Arguments() { this(new DxContext()); }
public Arguments() { this(new DxContext()); }
/** * 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 { return new Main(new DxContext()).runDx(arguments); }
/** * 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 { return new Main(new DxContext()).runDx(arguments); }
public static void main(String[] args) throws IOException { if (args.length < 2) { printUsage(); return; } Dex[] dexes = new Dex[args.length - 1]; for (int i = 1; i < args.length; i++) { dexes[i - 1] = new Dex(new File(args[i])); } Dex merged = new DexMerger(dexes, CollisionPolicy.KEEP_FIRST, new DxContext()).merge(); merged.writeTo(new File(args[0])); }
public static void main(String[] args) throws IOException { if (args.length < 2) { printUsage(); return; } Dex[] dexes = new Dex[args.length - 1]; for (int i = 1; i < args.length; i++) { dexes[i - 1] = new Dex(new File(args[i])); } Dex merged = new DexMerger(dexes, CollisionPolicy.KEEP_FIRST, new DxContext()).merge(); merged.writeTo(new File(args[0])); }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(context); arguments.parse(argArray); int result = new Main(context).runDx(arguments); if (result != 0) { throw new IOException(); } }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(context); arguments.parse(argArray); int result = new Main(context).runDx(arguments); if (result != 0) { System.exit(result); } }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(); arguments.parseCommandLine(argArray, context); int result = new Main(context).run(arguments); if (result != 0) { System.exit(result); } }
DxContext dxContext = new DxContext( output.getStandardOutput(), output.getErrorOutput()); Dex merged = new DexMerger(input, CollisionPolicy.KEEP_FIRST, dxContext).merge();
/** * Runs the dex command. * * @return the integer return code of com.android.dx.command.dexer.Main.run() */ public static ProcessResult run( @NonNull DexProcessBuilder processBuilder, @NonNull DexOptions dexOptions, @NonNull ProcessOutputHandler outputHandler) throws IOException, ProcessException { ProcessOutput output = outputHandler.createOutput(); int res; try { DxContext dxContext = new DxContext(output.getStandardOutput(), output.getErrorOutput()); Main.Arguments args = buildArguments(processBuilder, dexOptions, dxContext); res = new Main(dxContext).run(args); } finally { output.close(); } outputHandler.handleOutput(output); return new DexProcessResult(res); }