FileDocCategorySizeDatePackage
Main.javaAPI DocAndroid 5.1 API4674Thu Mar 12 22:18:30 GMT 2015com.android.dx.command.dump

Main

public class Main extends Object
Main class for the class file dumper.

Fields Summary
static Args
parsedArgs
Constructors Summary
private Main()
This class is uninstantiable.


             
      
        // This space intentionally left blank.
    
Methods Summary
public static voidmain(java.lang.String[] args)
Run!

        int at = 0;

        for (/*at*/; at < args.length; at++) {
            String arg = args[at];
            if (arg.equals("--") || !arg.startsWith("--")) {
                break;
            } else if (arg.equals("--bytes")) {
                parsedArgs.rawBytes = true;
            } else if (arg.equals("--basic-blocks")) {
                parsedArgs.basicBlocks = true;
            } else if (arg.equals("--rop-blocks")) {
                parsedArgs.ropBlocks = true;
            } else if (arg.equals("--optimize")) {
                parsedArgs.optimize = true;
            } else if (arg.equals("--ssa-blocks")) {
                parsedArgs.ssaBlocks = true;
            } else if (arg.startsWith("--ssa-step=")) {
                parsedArgs.ssaStep = arg.substring(arg.indexOf('=") + 1);
            } else if (arg.equals("--debug")) {
                parsedArgs.debug = true;
            } else if (arg.equals("--dot")) {
                parsedArgs.dotDump = true;
            } else if (arg.equals("--strict")) {
                parsedArgs.strictParse = true;
            } else if (arg.startsWith("--width=")) {
                arg = arg.substring(arg.indexOf('=") + 1);
                parsedArgs.width = Integer.parseInt(arg);
            } else if (arg.startsWith("--method=")) {
                arg = arg.substring(arg.indexOf('=") + 1);
                parsedArgs.method = arg;
            } else {
                System.err.println("unknown option: " + arg);
                throw new RuntimeException("usage");
            }
        }

        if (at == args.length) {
            System.err.println("no input files specified");
            throw new RuntimeException("usage");
        }

        for (/*at*/; at < args.length; at++) {
            try {
                String name = args[at];
                System.out.println("reading " + name + "...");
                byte[] bytes = FileUtils.readFile(name);
                if (!name.endsWith(".class")) {
                    String src;
                    try {
                        src = new String(bytes, "utf-8");
                    } catch (UnsupportedEncodingException ex) {
                        throw new RuntimeException("shouldn't happen", ex);
                    }
                    bytes = HexParser.parse(src);
                }
                processOne(name, bytes);
            } catch (ParseException ex) {
                System.err.println("\ntrouble parsing:");
                if (parsedArgs.debug) {
                    ex.printStackTrace();
                } else {
                    ex.printContext(System.err);
                }
            }
        }
    
private static voidprocessOne(java.lang.String name, byte[] bytes)
Processes one file.

param
name {@code non-null;} name of the file
param
bytes {@code non-null;} contents of the file

        if (parsedArgs.dotDump) {
            DotDumper.dump(bytes, name, parsedArgs);
        } else if (parsedArgs.basicBlocks) {
            BlockDumper.dump(bytes, System.out, name, false, parsedArgs);
        } else if (parsedArgs.ropBlocks) {
            BlockDumper.dump(bytes, System.out, name, true, parsedArgs);
        } else if (parsedArgs.ssaBlocks) {
            // --optimize ignored with --ssa-blocks
            parsedArgs.optimize = false;
            SsaDumper.dump(bytes, System.out, name, parsedArgs);
        } else {
            ClassDumper.dump(bytes, System.out, name, parsedArgs);
        }