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

Main

public class Main extends Object
Main class for dx. It recognizes enough options to be able to dispatch to the right "actual" main.

Fields Summary
private static String
USAGE_MESSAGE
Constructors Summary
private Main()
This class is uninstantiable.


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

        boolean gotCmd = false;
        boolean showUsage = false;

        try {
            for (int i = 0; i < args.length; i++) {
                String arg = args[i];
                if (arg.equals("--") || !arg.startsWith("--")) {
                    gotCmd = false;
                    showUsage = true;
                    break;
                }

                gotCmd = true;
                if (arg.equals("--dex")) {
                    com.android.dx.command.dexer.Main.main(without(args, i));
                    break;
                } else if (arg.equals("--dump")) {
                    com.android.dx.command.dump.Main.main(without(args, i));
                    break;
                } else if (arg.equals("--annotool")) {
                    com.android.dx.command.annotool.Main.main(
                            without(args, i));
                    break;
                } else if (arg.equals("--find-usages")) {
                    com.android.dx.command.findusages.Main.main(without(args, i));
                    break;
                } else if (arg.equals("--version")) {
                    version();
                    break;
                } else if (arg.equals("--help")) {
                    showUsage = true;
                    break;
                } else {
                    gotCmd = false;
                }
            }
        } catch (UsageException ex) {
            showUsage = true;
        } catch (RuntimeException ex) {
            System.err.println("\nUNEXPECTED TOP-LEVEL EXCEPTION:");
            ex.printStackTrace();
            System.exit(2);
        } catch (Throwable ex) {
            System.err.println("\nUNEXPECTED TOP-LEVEL ERROR:");
            ex.printStackTrace();
            if ((ex instanceof NoClassDefFoundError)
                    || (ex instanceof NoSuchMethodError)) {
                System.err.println(
                        "Note: You may be using an incompatible " +
                        "virtual machine or class library.\n" +
                        "(This program is known to be incompatible " +
                        "with recent releases of GCJ.)");
            }
            System.exit(3);
        }

        if (!gotCmd) {
            System.err.println("error: no command specified");
            showUsage = true;
        }

        if (showUsage) {
            usage();
            System.exit(1);
        }
    
private static voidusage()
Prints the usage message.

        System.err.println(USAGE_MESSAGE);
    
private static voidversion()
Prints the version message.

        System.err.println("dx version " + Version.VERSION);
        System.exit(0);
    
private static java.lang.String[]without(java.lang.String[] orig, int n)
Returns a copy of the given args array, but without the indicated element.

param
orig {@code non-null;} original array
param
n which element to omit
return
{@code non-null;} new array

        int len = orig.length - 1;
        String[] newa = new String[len];
        System.arraycopy(orig, 0, newa, 0, n);
        System.arraycopy(orig, n + 1, newa, n, len - n);
        return newa;