Fix a bunch of little problems noticed by FindBugs, and cleaned up some
spacing issues that I happened to notice along the way.
diff --git a/dx/src/com/android/dx/cf/code/BasicBlocker.java b/dx/src/com/android/dx/cf/code/BasicBlocker.java
index a3370d4..d67e525 100644
--- a/dx/src/com/android/dx/cf/code/BasicBlocker.java
+++ b/dx/src/com/android/dx/cf/code/BasicBlocker.java
@@ -32,19 +32,23 @@
     /** {@code non-null;} method being converted */
     private final ConcreteMethod method;
 
-    /** {@code non-null;} work set; bits indicate offsets in need of examination */
+    /**
+     * {@code non-null;} work set; bits indicate offsets in need of
+     * examination
+     */
     private final int[] workSet;
 
     /**
-     * {@code non-null;} live set; bits indicate potentially-live opcodes; contrawise,
-     * a bit that isn't on is either in the middle of an instruction or is
-     * a definitely-dead opcode 
+     * {@code non-null;} live set; bits indicate potentially-live
+     * opcodes; contrawise, a bit that isn't on is either in the
+     * middle of an instruction or is a definitely-dead opcode
      */
     private final int[] liveSet;
 
     /**
-     * {@code non-null;} block start set; bits indicate the starts of basic blocks,
-     * including the opcodes that start blocks of definitely-dead code 
+     * {@code non-null;} block start set; bits indicate the starts of
+     * basic blocks, including the opcodes that start blocks of
+     * definitely-dead code
      */
     private final int[] blockSet;
 
@@ -265,7 +269,6 @@
      * @return {@code non-null;} the list of basic blocks
      */
     private ByteBlockList getBlockList() {
-        ByteCatchList catches = method.getCatches();
         BytecodeArray bytes = method.getCode();
         ByteBlock[] bbs = new ByteBlock[bytes.size()];
         int count = 0;
diff --git a/dx/src/com/android/dx/cf/code/LocalVariableList.java b/dx/src/com/android/dx/cf/code/LocalVariableList.java
index 9f19528..8f49a33 100644
--- a/dx/src/com/android/dx/cf/code/LocalVariableList.java
+++ b/dx/src/com/android/dx/cf/code/LocalVariableList.java
@@ -77,7 +77,6 @@
     public static LocalVariableList mergeDescriptorsAndSignatures(
             LocalVariableList descriptorList,
             LocalVariableList signatureList) {
-        int signatureSize = signatureList.size();
         int descriptorSize = descriptorList.size();
         LocalVariableList result = new LocalVariableList(descriptorSize);
 
diff --git a/dx/src/com/android/dx/cf/code/Ropper.java b/dx/src/com/android/dx/cf/code/Ropper.java
index 13e1401..6e8c328 100644
--- a/dx/src/com/android/dx/cf/code/Ropper.java
+++ b/dx/src/com/android/dx/cf/code/Ropper.java
@@ -219,8 +219,6 @@
          * @param workSet {@code non-null;} workset to update
          */
         void mergeToSuccessors(Frame frame, int[] workSet) {
-            int sz = callerBlocks.size();
-
             for (int label = callerBlocks.nextSetBit(0); label >= 0;
                  label = callerBlocks.nextSetBit(label+1)) {
                 BasicBlock subCaller = labelToBlock(label);
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 43fa183..5a9f417 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -215,8 +215,9 @@
     /**
      * Processes one pathname element.
      *
-     * @param pathname {@code non-null;} the pathname to process. May be the path of
-     * a class file, a jar file, or a directory containing class files.
+     * @param pathname {@code non-null;} the pathname to process. May
+     * be the path of a class file, a jar file, or a directory
+     * containing class files.
      * @return whether any processing actually happened
      */
     private static boolean processOne(String pathname) {
@@ -237,7 +238,8 @@
             }
             public void onProcessArchiveStart(File file) {
                 if (args.verbose) {
-                    DxConsole.out.println("processing archive " + file + "...");
+                    DxConsole.out.println("processing archive " + file +
+                            "...");
                 }
             }
         });
@@ -316,7 +318,8 @@
      * class. If there is a problem, this updates the error count and
      * throws an exception to stop processing.
      * 
-     * @param name {@code non-null;} the fully-qualified internal-form class name
+     * @param name {@code non-null;} the fully-qualified internal-form
+     * class name
      */
     private static void checkClassName(String name) {
         boolean bogus = false;
@@ -464,7 +467,8 @@
      * Creates a jar file from the resources and given dex file array.
      *
      * @param fileName {@code non-null;} name of the file
-     * @param dexArray {@code non-null;} array containing the dex file to include
+     * @param dexArray {@code non-null;} array containing the dex file
+     * to include
      * @return whether the creation was successful
      */
     private static boolean createJar(String fileName, byte[] dexArray) {
@@ -629,7 +633,8 @@
      * Dumps any method with the given name in the given file.
      *
      * @param dex {@code non-null;} the dex file
-     * @param fqName {@code non-null;} the fully-qualified name of the method(s)
+     * @param fqName {@code non-null;} the fully-qualified name of the
+     * method(s)
      * @param out {@code non-null;} where to dump to
      */
     private static void dumpMethod(DexFile dex, String fqName,
@@ -891,8 +896,6 @@
             }
 
             int fileCount = args.length - at;
-            fileNames = new String[fileCount];
-            System.arraycopy(args, at, fileNames, 0, fileCount);
 
             if (fileCount == 0) {
                 if (!emptyOk) {
@@ -901,9 +904,13 @@
                 }
             } else if (emptyOk) {
                 System.out.println("ignoring input files");
-                at = args.length;
+                at = 0;
+                fileCount = 0;
             }
 
+            fileNames = new String[fileCount];
+            System.arraycopy(args, at, fileNames, 0, fileCount);
+
             if ((humanOutName == null) && (methodToDump != null)) {
                 humanOutName = "-";
             }
diff --git a/dx/src/com/android/dx/dex/cf/OptimizerOptions.java b/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
index 0108a7f..fa606e3 100644
--- a/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
+++ b/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
@@ -31,8 +31,9 @@
  */
 public class OptimizerOptions {
     /**
-     * {@code null-ok;} hash set of class name + method names that should be optimized.
-     * null if this constraint was not specified on the command line
+     * {@code null-ok;} hash set of class name + method names that
+     * should be optimized. {@code null} if this constraint was not
+     * specified on the command line
      */
     private static HashSet<String> optimizeList;
 
@@ -97,7 +98,6 @@
 
         try {
             FileReader fr = new FileReader(filename);
-
             BufferedReader bfr = new BufferedReader(fr);
 
             String line;
@@ -105,6 +105,8 @@
             while (null != (line = bfr.readLine())) {
                 result.add(line);
             }
+
+            fr.close();
         } catch (IOException ex) {
             // Let the exception percolate up as a RuntimeException.
             throw new RuntimeException("Error with optimize list: " +
diff --git a/dx/src/com/android/dx/dex/code/ArrayData.java b/dx/src/com/android/dx/dex/code/ArrayData.java
index 30baa5a..7698de1 100644
--- a/dx/src/com/android/dx/dex/code/ArrayData.java
+++ b/dx/src/com/android/dx/dex/code/ArrayData.java
@@ -107,7 +107,6 @@
     /** {@inheritDoc} */
     @Override
     public void writeTo(AnnotatedOutput out) {
-        int baseAddress = user.getAddress();
         int sz = values.size();
 
         out.writeShort(0x300 | DalvOps.NOP);
diff --git a/dx/src/com/android/dx/dex/code/StdCatchBuilder.java b/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
index 23e25aa..6e3a169 100644
--- a/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
+++ b/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
@@ -78,7 +78,6 @@
 
     /** {@inheritDoc} */
     public boolean hasAnyCatches() {
-        HashSet<Type> result = new HashSet<Type>(20);
         BasicBlockList blocks = method.getBlocks();
         int size = blocks.size();
         
diff --git a/dx/src/com/android/dx/dex/file/CatchStructs.java b/dx/src/com/android/dx/dex/file/CatchStructs.java
index 64bf243..3412015 100644
--- a/dx/src/com/android/dx/dex/file/CatchStructs.java
+++ b/dx/src/com/android/dx/dex/file/CatchStructs.java
@@ -195,14 +195,11 @@
     public void writeTo(DexFile file, AnnotatedOutput out) {
         finishProcessingIfNecessary();
 
-        TypeIdsSection typeIds = file.getTypeIds();
-        int tableSize = table.size();
-        int handlersSize = handlerOffsets.size();
-        
         if (out.annotates()) {
             annotateEntries("  ", null, out);
         }
 
+        int tableSize = table.size();
         for (int i = 0; i < tableSize; i++) {
             CatchTable.Entry one = table.get(i);
             int start = one.getStart();
diff --git a/dx/src/com/android/dx/dex/file/ClassDataItem.java b/dx/src/com/android/dx/dex/file/ClassDataItem.java
index f437a3e..4823f9f 100644
--- a/dx/src/com/android/dx/dex/file/ClassDataItem.java
+++ b/dx/src/com/android/dx/dex/file/ClassDataItem.java
@@ -342,8 +342,6 @@
      */
     private void encodeOutput(DexFile file, AnnotatedOutput out) {
         boolean annotates = out.annotates();
-        int svSize = (staticValuesConstant == null) ? 0 :
-            staticValuesConstant.getList().size();
 
         if (annotates) {
             out.annotate(0, offsetString() + " class data for " +
diff --git a/dx/src/com/android/dx/dex/file/CodeItem.java b/dx/src/com/android/dx/dex/file/CodeItem.java
index 279e6bf..ab7abbe 100644
--- a/dx/src/com/android/dx/dex/file/CodeItem.java
+++ b/dx/src/com/android/dx/dex/file/CodeItem.java
@@ -114,7 +114,6 @@
 
     /** {@inheritDoc} */
     public void addContents(DexFile file) {
-        MixedItemSection wordData = file.getWordData();
         MixedItemSection byteData = file.getByteData();
         TypeIdsSection typeIds = file.getTypeIds();
 
diff --git a/dx/src/com/android/dx/dex/file/OffsettedItem.java b/dx/src/com/android/dx/dex/file/OffsettedItem.java
index 18bc439..c8e2d74 100644
--- a/dx/src/com/android/dx/dex/file/OffsettedItem.java
+++ b/dx/src/com/android/dx/dex/file/OffsettedItem.java
@@ -213,7 +213,8 @@
      * the given offset. It is only valid to call this method once per
      * instance.
      * 
-     * @param addedTo {@code non-null;} the section this instance has been added to
+     * @param addedTo {@code non-null;} the section this instance has
+     * been added to
      * @param offset {@code >= 0;} the desired offset from the start of the
      * section where this instance was placed
      * @return {@code >= 0;} the offset that this instance should be placed at
diff --git a/dx/src/com/android/dx/dex/file/ValueEncoder.java b/dx/src/com/android/dx/dex/file/ValueEncoder.java
index 66cd1a5..f7e364a 100644
--- a/dx/src/com/android/dx/dex/file/ValueEncoder.java
+++ b/dx/src/com/android/dx/dex/file/ValueEncoder.java
@@ -514,9 +514,6 @@
      * @param cst {@code non-null;} the constant to add contents for
      */
     public static void addContents(DexFile file, Constant cst) {
-        TypeIdsSection typeIds = file.getTypeIds();
-        StringIdsSection stringIds = file.getStringIds();
-
         if (cst instanceof CstAnnotation) {
             addContents(file, ((CstAnnotation) cst).getAnnotation());
         } else if (cst instanceof CstArray) {
diff --git a/dx/src/com/android/dx/rop/code/LocalVariableExtractor.java b/dx/src/com/android/dx/rop/code/LocalVariableExtractor.java
index 14ebbc4..db142c2 100644
--- a/dx/src/com/android/dx/rop/code/LocalVariableExtractor.java
+++ b/dx/src/com/android/dx/rop/code/LocalVariableExtractor.java
@@ -101,7 +101,6 @@
          * state *before* executing it to be what is merged into
          * exception targets.
          */
-        Insn lastInsn = insns.getLast();
         boolean canThrowDuringLastInsn = block.hasExceptionHandlers() &&
             (insns.getLast().getResult() != null);
         int freezeSecondaryStateAt = insnSz - 1;
diff --git a/dx/src/com/android/dx/rop/code/RegisterSpec.java b/dx/src/com/android/dx/rop/code/RegisterSpec.java
index 8e819bf..1f14767 100644
--- a/dx/src/com/android/dx/rop/code/RegisterSpec.java
+++ b/dx/src/com/android/dx/rop/code/RegisterSpec.java
@@ -598,15 +598,19 @@
         /** {@code non-null;} type loaded or stored */
         private TypeBearer type;
 
-        /** {@code null-ok;} local variable associated with this register, if any */
+        /**
+         * {@code null-ok;} local variable associated with this
+         * register, if any
+         */
         private LocalItem local;
 
         /**
          * Set all the instance variables.
          * 
          * @param reg {@code >= 0;} the register number
-         * @param type {@code non-null;} the type (or possibly actual value) which
-         * is loaded from or stored to the indicated register
+         * @param type {@code non-null;} the type (or possibly actual
+         * value) which is loaded from or stored to the indicated
+         * register
          * @param local {@code null-ok;} the associated local variable, if any
          * @return {@code non-null;} an appropriately-constructed instance
          */
diff --git a/dx/src/com/android/dx/ssa/SCCP.java b/dx/src/com/android/dx/ssa/SCCP.java
index 650985e..73e9b49 100644
--- a/dx/src/com/android/dx/ssa/SCCP.java
+++ b/dx/src/com/android/dx/ssa/SCCP.java
@@ -137,9 +137,6 @@
         }
     }
     
-    private boolean setLatticeValueTo(int reg, int value) {
-        return setLatticeValueTo(reg, value, null);
-    }
     /**
      * Simulates a PHI node and set the lattice for the result
      * to the approriate value.
diff --git a/dx/src/com/android/dx/ssa/SsaConverter.java b/dx/src/com/android/dx/ssa/SsaConverter.java
index 99aab3d..d5be287 100644
--- a/dx/src/com/android/dx/ssa/SsaConverter.java
+++ b/dx/src/com/android/dx/ssa/SsaConverter.java
@@ -27,7 +27,7 @@
  * Converts ROP methods to SSA Methods
  */
 public class SsaConverter {
-    public static boolean DEBUG = false;
+    public static final boolean DEBUG = false;
 
     /**
      * Returns an SSA representation, edge-split and with phi
diff --git a/dx/src/com/android/dx/ssa/back/RegisterAllocator.java b/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
index cf79301..e75eee1 100644
--- a/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
+++ b/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
@@ -176,10 +176,6 @@
          */
 
         IntSet liveOut = block.getLiveOutRegs();
-
-        RegisterSpec result = insn.getResult();
-        int resultReg = (result == null) ? -1 : result.getReg();
-
         IntIterator liveOutIter = liveOut.iterator();
 
         while (liveOutIter.hasNext()) {
diff --git a/dx/src/com/android/dx/util/BitIntSet.java b/dx/src/com/android/dx/util/BitIntSet.java
index 9baae6d..db85571 100644
--- a/dx/src/com/android/dx/util/BitIntSet.java
+++ b/dx/src/com/android/dx/util/BitIntSet.java
@@ -118,12 +118,6 @@
 
                 return ret;
             }
-
-            /** @inheritDoc */
-            public void remove() {
-                BitIntSet.this.remove(idx);
-                idx = Bits.findFirst(bits, idx+1);
-            }
         };
     }
 
diff --git a/dx/src/com/android/dx/util/IntIterator.java b/dx/src/com/android/dx/util/IntIterator.java
index 88181b5..4caa439 100644
--- a/dx/src/com/android/dx/util/IntIterator.java
+++ b/dx/src/com/android/dx/util/IntIterator.java
@@ -35,10 +35,4 @@
      * @throws java.util.NoSuchElementException if no next element exists
      */
     int next();
-
-    /**
-     * Removes a value from the collection underlying this iterator.
-     * May throw UnsupportedOperationException().
-     */
-//    void remove();
 }
diff --git a/dx/src/com/android/dx/util/Leb128Utils.java b/dx/src/com/android/dx/util/Leb128Utils.java
index dfd416f..6ed3a61 100644
--- a/dx/src/com/android/dx/util/Leb128Utils.java
+++ b/dx/src/com/android/dx/util/Leb128Utils.java
@@ -41,7 +41,6 @@
         int count = 0;
 
         while (remaining != 0) {
-            value = remaining;
             remaining >>= 7;
             count++;
         }
diff --git a/dx/src/com/android/dx/util/ListIntSet.java b/dx/src/com/android/dx/util/ListIntSet.java
index a9f79af..6d28a18 100644
--- a/dx/src/com/android/dx/util/ListIntSet.java
+++ b/dx/src/com/android/dx/util/ListIntSet.java
@@ -122,11 +122,6 @@
 
                 return ints.get(idx++);
             }
-
-            /** @inheritDoc */
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
         };
     }