Merge "Bump dx version to 1.10" into lmp-dev
diff --git a/dx/src/com/android/dx/cf/code/RopperMachine.java b/dx/src/com/android/dx/cf/code/RopperMachine.java
index ea7d6ff..530295b 100644
--- a/dx/src/com/android/dx/cf/code/RopperMachine.java
+++ b/dx/src/com/android/dx/cf/code/RopperMachine.java
@@ -940,7 +940,7 @@
                 // NOTE: This is a slow O(n) loop, and can be replaced with a
                 // faster implementation (at the cost of higher memory usage)
                 // if it proves to be a hot area of code.
-                if (ref.getDefiningClass() == method.getDefiningClass()) {
+                if (ref.getDefiningClass().equals(method.getDefiningClass())) {
                     for (int i = 0; i < methods.size(); ++i) {
                         final Method m = methods.get(i);
                         if (AccessFlags.isPrivate(m.getAccessFlags()) &&
@@ -960,7 +960,7 @@
                  */
                 CstMethodRef ref = (CstMethodRef) cst;
                 if (ref.isInstanceInit() ||
-                    (ref.getDefiningClass() == method.getDefiningClass()) ||
+                    (ref.getDefiningClass().equals(method.getDefiningClass())) ||
                     !method.getAccSuper()) {
                     return RegOps.INVOKE_DIRECT;
                 }
diff --git a/dx/src/com/android/dx/command/Main.java b/dx/src/com/android/dx/command/Main.java
index 1132edb..9834987 100644
--- a/dx/src/com/android/dx/command/Main.java
+++ b/dx/src/com/android/dx/command/Main.java
@@ -35,6 +35,7 @@
         "[--core-library]\n" +
         "  [--num-threads=<n>] [--incremental] [--force-jumbo]\n" +
         "  [--multi-dex [--main-dex-list=<file> [--minimal-main-dex]]\n" +
+        "  [--input-list=<file>]\n" +
         "  [<file>.class | <file>.{zip,jar,apk} | <directory>] ...\n" +
         "    Convert a set of classfiles into a dex file, optionally " +
         "embedded in a\n" +
@@ -52,6 +53,8 @@
         "    --minimal-main-dex: only classes selected by --main-dex-list are " +
         "to be put in\n" +
         "    the main dex.\n" +
+        "    --input-list: <file> is a list of inputs.\n" +
+        "    Each line in <file> must end with one of: .class .jar .zip .apk or be a directory.\n" +
         "  dx --annotool --annotation=<class> [--element=<element types>]\n" +
         "  [--print=<print types>]\n" +
         "  dx --dump [--debug] [--strict] [--bytes] [--optimize]\n" +
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index c5f9c94..4670372 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -326,7 +326,7 @@
         assert args.numThreads == 1;
 
         if (args.mainDexListFile != null) {
-            classesInMainDex = loadMainDexListFile(args.mainDexListFile);
+            classesInMainDex = readPathsFromFile(args.mainDexListFile);
         }
 
         if (!processAllFiles()) {
@@ -380,17 +380,17 @@
         }
     }
 
-    private static Set<String> loadMainDexListFile(String mainDexListFile) throws IOException {
-        Set<String> mainDexList = new HashSet<String>();
+    private static Set<String> readPathsFromFile(String fileName) throws IOException {
+        Set<String> paths = new HashSet<String>();
         BufferedReader bfr = null;
         try {
-            FileReader fr = new FileReader(mainDexListFile);
+            FileReader fr = new FileReader(fileName);
             bfr = new BufferedReader(fr);
 
             String line;
 
             while (null != (line = bfr.readLine())) {
-                mainDexList.add(fixPath(line));
+                paths.add(fixPath(line));
             }
 
         } finally {
@@ -398,7 +398,7 @@
                 bfr.close();
             }
         }
-        return mainDexList;
+        return paths;
     }
 
     /**
@@ -1194,6 +1194,8 @@
 
         private static final String INCREMENTAL_OPTION = "--incremental";
 
+        private static final String INPUT_LIST_OPTION = "--input-list";
+
         /** whether to run in debug mode */
         public boolean debug = false;
 
@@ -1287,6 +1289,9 @@
          * mainDexListFile is specified and non empty. */
         public boolean minimalMainDex = false;
 
+        /** Optional list containing inputs read in from a file. */
+        private Set<String> inputList = null;
+
         private int maxNumberOfIdxPerDex = DexFormat.MAX_MEMBER_IDX + 1;
 
         private static class ArgumentsParser {
@@ -1488,13 +1493,29 @@
                     minimalMainDex = true;
                 } else if (parser.isArg("--set-max-idx-number=")) { // undocumented test option
                     maxNumberOfIdxPerDex = Integer.parseInt(parser.getLastValue());
-              } else {
+                } else if(parser.isArg(INPUT_LIST_OPTION + "=")) {
+                    File inputListFile = new File(parser.getLastValue());
+                    try{
+                        inputList = readPathsFromFile(inputListFile.getAbsolutePath());
+                    } catch(IOException e) {
+                        System.err.println(
+                            "Unable to read input list file: " + inputListFile.getName());
+                        // problem reading the file so we should halt execution
+                        throw new UsageException();
+                    }
+                } else {
                     System.err.println("unknown option: " + parser.getCurrent());
                     throw new UsageException();
                 }
             }
 
             fileNames = parser.getRemaining();
+            if(inputList != null && !inputList.isEmpty()) {
+                // append the file names to the end of the input list
+                inputList.addAll(Arrays.asList(fileNames));
+                fileNames = inputList.toArray(new String[inputList.size()]);
+            }
+
             if (fileNames.length == 0) {
                 if (!emptyOk) {
                     System.err.println("no input files specified");