OSDN Git Service

Mechanical refactoring of dx into two parts.
authorJesse Wilson <jessewilson@google.com>
Sat, 17 Sep 2011 03:10:02 +0000 (23:10 -0400)
committerBrian Carlstrom <bdc@google.com>
Tue, 30 Apr 2013 17:40:28 +0000 (10:40 -0700)
This splits off a new package, com.android.dex that contains
code for parsing and modelling dex files. This code is usable
both at build time (for compilation and analysis) and at runtime
(for introspection).

The original package, com.android.dx is the tool that compiles
.class files into .dex files. That package also includes utilities
for merging and querying dex files, all visible to the dx command
line application.

In a follow up change I'll move the new com.android.dex package
into the libcore/ project, and configure build rules so that it's
included in both dx.jar and core.jar. The core.jar will then be
able to use it for annotation processing.

Change-Id: I3c58cf87e728e4dda1925a0992c1ee7b8130e81a
(cherry picked from commit bab4abb07335d162ecdb8091fc395cf84803a580)

Conflicts:
dx/junit-tests/com/android/dx/util/BitIntSetTest.java
dx/junit-tests/com/android/dx/util/BitsTest.java
dx/junit-tests/com/android/dx/util/IntListTest.java
dx/junit-tests/com/android/dx/util/ListIntSetTest.java
dx/src/com/android/dex/Dex.java
dx/src/com/android/dex/TableOfContents.java
dx/src/com/android/dx/annotations/AnnotationAccess.java
dx/src/com/android/dx/command/Main.java
dx/src/com/android/dx/dex/code/OutputFinisher.java
dx/src/com/android/dx/dex/code/form/Form32s.java
dx/src/com/android/dx/dex/code/form/Form33x.java
dx/src/com/android/dx/dex/code/form/Form41c.java
dx/src/com/android/dx/dex/code/form/Form52c.java
dx/src/com/android/dx/gen/DexGenerator.java
dx/src/com/android/dx/merge/DexMerger.java

199 files changed:
dx/junit-tests/com/android/dex/EncodedValueReaderTest.java [moved from dx/junit-tests/com/android/dx/io/EncodedValueReaderTest.java with 98% similarity]
dx/junit-tests/com/android/dx/util/BitIntSetTest.java
dx/junit-tests/com/android/dx/util/BitsTest.java
dx/junit-tests/com/android/dx/util/IntListTest.java
dx/junit-tests/com/android/dx/util/ListIntSetTest.java
dx/src/com/android/dex/Annotation.java [moved from dx/src/com/android/dx/io/Annotation.java with 79% similarity]
dx/src/com/android/dex/ClassData.java [moved from dx/src/com/android/dx/io/ClassData.java with 99% similarity]
dx/src/com/android/dex/ClassDef.java [moved from dx/src/com/android/dx/io/ClassDef.java with 95% similarity]
dx/src/com/android/dex/Code.java [moved from dx/src/com/android/dx/io/Code.java with 99% similarity]
dx/src/com/android/dex/Dex.java [moved from dx/src/com/android/dx/io/DexBuffer.java with 93% similarity]
dx/src/com/android/dex/DexException.java [moved from dx/src/com/android/dx/util/DexException.java with 92% similarity]
dx/src/com/android/dex/DexFormat.java [moved from dx/src/com/android/dx/dex/DexFormat.java with 99% similarity]
dx/src/com/android/dex/EncodedValue.java [moved from dx/src/com/android/dx/io/EncodedValue.java with 90% similarity]
dx/src/com/android/dex/EncodedValueCodec.java [moved from dx/src/com/android/dx/util/EncodedValueUtils.java with 96% similarity]
dx/src/com/android/dex/EncodedValueReader.java [moved from dx/src/com/android/dx/io/EncodedValueReader.java with 86% similarity]
dx/src/com/android/dex/FieldId.java [moved from dx/src/com/android/dx/io/FieldId.java with 82% similarity]
dx/src/com/android/dex/Leb128.java [moved from dx/src/com/android/dx/util/Leb128Utils.java with 95% similarity]
dx/src/com/android/dex/MethodId.java [moved from dx/src/com/android/dx/io/MethodId.java with 77% similarity]
dx/src/com/android/dex/Mutf8.java [moved from dx/src/com/android/dx/util/Mutf8.java with 98% similarity]
dx/src/com/android/dex/ProtoId.java [moved from dx/src/com/android/dx/io/ProtoId.java with 77% similarity]
dx/src/com/android/dex/SizeOf.java [moved from dx/src/com/android/dx/dex/SizeOf.java with 98% similarity]
dx/src/com/android/dex/TableOfContents.java [moved from dx/src/com/android/dx/dex/TableOfContents.java with 93% similarity]
dx/src/com/android/dex/TypeList.java [moved from dx/src/com/android/dx/merge/TypeList.java with 81% similarity]
dx/src/com/android/dex/util/ByteArrayByteInput.java [moved from dx/src/com/android/dx/util/ByteArrayByteInput.java with 96% similarity]
dx/src/com/android/dex/util/ByteInput.java [moved from dx/src/com/android/dx/util/ByteInput.java with 96% similarity]
dx/src/com/android/dex/util/ByteOutput.java [moved from dx/src/com/android/dx/util/ByteOutput.java with 96% similarity]
dx/src/com/android/dex/util/ExceptionWithContext.java [moved from dx/src/com/android/dx/util/ExceptionWithContext.java with 97% similarity]
dx/src/com/android/dex/util/FileUtils.java [moved from dx/src/com/android/dx/util/FileUtils.java with 95% similarity]
dx/src/com/android/dex/util/Unsigned.java [moved from dx/src/com/android/dx/util/Unsigned.java with 97% similarity]
dx/src/com/android/dx/cf/code/BaseMachine.java
dx/src/com/android/dx/cf/code/BasicBlocker.java
dx/src/com/android/dx/cf/code/ByteBlockList.java
dx/src/com/android/dx/cf/code/ExecutionStack.java
dx/src/com/android/dx/cf/code/Frame.java
dx/src/com/android/dx/cf/code/LocalVariableList.java
dx/src/com/android/dx/cf/code/LocalsArray.java
dx/src/com/android/dx/cf/code/LocalsArraySet.java
dx/src/com/android/dx/cf/code/Machine.java
dx/src/com/android/dx/cf/code/OneLocalsArray.java
dx/src/com/android/dx/cf/code/Ropper.java
dx/src/com/android/dx/cf/code/RopperMachine.java
dx/src/com/android/dx/cf/code/SimException.java
dx/src/com/android/dx/cf/code/Simulator.java
dx/src/com/android/dx/cf/direct/AnnotationParser.java
dx/src/com/android/dx/cf/direct/ClassPathOpener.java
dx/src/com/android/dx/cf/direct/CodeObserver.java
dx/src/com/android/dx/cf/direct/DirectClassFile.java
dx/src/com/android/dx/cf/direct/StdAttributeFactory.java
dx/src/com/android/dx/cf/iface/ParseException.java
dx/src/com/android/dx/command/annotool/AnnotationLister.java
dx/src/com/android/dx/command/annotool/Main.java
dx/src/com/android/dx/command/dexer/Main.java
dx/src/com/android/dx/command/dump/BaseDumper.java
dx/src/com/android/dx/command/dump/BlockDumper.java
dx/src/com/android/dx/command/dump/ClassDumper.java
dx/src/com/android/dx/command/dump/DotDumper.java
dx/src/com/android/dx/command/dump/Main.java
dx/src/com/android/dx/command/dump/SsaDumper.java
dx/src/com/android/dx/command/findusages/FindUsages.java
dx/src/com/android/dx/command/findusages/Main.java
dx/src/com/android/dx/command/grep/Grep.java
dx/src/com/android/dx/command/grep/Main.java
dx/src/com/android/dx/dex/DexOptions.java
dx/src/com/android/dx/dex/cf/AttributeTranslator.java
dx/src/com/android/dx/dex/cf/CfOptions.java
dx/src/com/android/dx/dex/cf/CfTranslator.java
dx/src/com/android/dx/dex/cf/CodeStatistics.java
dx/src/com/android/dx/dex/cf/OptimizerOptions.java
dx/src/com/android/dx/dex/code/ArrayData.java
dx/src/com/android/dx/dex/code/CatchBuilder.java
dx/src/com/android/dx/dex/code/CatchTable.java
dx/src/com/android/dx/dex/code/DalvCode.java
dx/src/com/android/dx/dex/code/DalvInsn.java
dx/src/com/android/dx/dex/code/DalvInsnList.java
dx/src/com/android/dx/dex/code/HighRegisterPrefix.java
dx/src/com/android/dx/dex/code/InsnFormat.java
dx/src/com/android/dx/dex/code/LocalList.java
dx/src/com/android/dx/dex/code/OutputCollector.java
dx/src/com/android/dx/dex/code/OutputFinisher.java
dx/src/com/android/dx/dex/code/RopToDop.java
dx/src/com/android/dx/dex/code/RopTranslator.java
dx/src/com/android/dx/dex/code/StdCatchBuilder.java
dx/src/com/android/dx/dex/code/form/Form11n.java
dx/src/com/android/dx/dex/code/form/Form11x.java
dx/src/com/android/dx/dex/code/form/Form12x.java
dx/src/com/android/dx/dex/code/form/Form21c.java
dx/src/com/android/dx/dex/code/form/Form21h.java
dx/src/com/android/dx/dex/code/form/Form21s.java
dx/src/com/android/dx/dex/code/form/Form21t.java
dx/src/com/android/dx/dex/code/form/Form22b.java
dx/src/com/android/dx/dex/code/form/Form22c.java
dx/src/com/android/dx/dex/code/form/Form22s.java
dx/src/com/android/dx/dex/code/form/Form22t.java
dx/src/com/android/dx/dex/code/form/Form22x.java
dx/src/com/android/dx/dex/code/form/Form23x.java
dx/src/com/android/dx/dex/code/form/Form31c.java
dx/src/com/android/dx/dex/code/form/Form31i.java
dx/src/com/android/dx/dex/code/form/Form31t.java
dx/src/com/android/dx/dex/code/form/Form32x.java
dx/src/com/android/dx/dex/code/form/Form35c.java
dx/src/com/android/dx/dex/code/form/Form51l.java
dx/src/com/android/dx/dex/file/AnnotationItem.java
dx/src/com/android/dx/dex/file/AnnotationSetItem.java
dx/src/com/android/dx/dex/file/AnnotationUtils.java
dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java
dx/src/com/android/dx/dex/file/CatchStructs.java
dx/src/com/android/dx/dex/file/ClassDataItem.java
dx/src/com/android/dx/dex/file/ClassDefItem.java
dx/src/com/android/dx/dex/file/ClassDefsSection.java
dx/src/com/android/dx/dex/file/CodeItem.java
dx/src/com/android/dx/dex/file/DebugInfoDecoder.java
dx/src/com/android/dx/dex/file/DebugInfoEncoder.java
dx/src/com/android/dx/dex/file/DebugInfoItem.java
dx/src/com/android/dx/dex/file/DexFile.java
dx/src/com/android/dx/dex/file/EncodedArrayItem.java
dx/src/com/android/dx/dex/file/EncodedField.java
dx/src/com/android/dx/dex/file/EncodedMember.java
dx/src/com/android/dx/dex/file/EncodedMethod.java
dx/src/com/android/dx/dex/file/FieldIdsSection.java
dx/src/com/android/dx/dex/file/HeaderItem.java
dx/src/com/android/dx/dex/file/HeaderSection.java
dx/src/com/android/dx/dex/file/MapItem.java
dx/src/com/android/dx/dex/file/MemberIdItem.java
dx/src/com/android/dx/dex/file/MemberIdsSection.java
dx/src/com/android/dx/dex/file/MethodIdsSection.java
dx/src/com/android/dx/dex/file/MixedItemSection.java
dx/src/com/android/dx/dex/file/OffsettedItem.java
dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java
dx/src/com/android/dx/dex/file/ProtoIdItem.java
dx/src/com/android/dx/dex/file/ProtoIdsSection.java
dx/src/com/android/dx/dex/file/Section.java
dx/src/com/android/dx/dex/file/Statistics.java
dx/src/com/android/dx/dex/file/StringDataItem.java
dx/src/com/android/dx/dex/file/StringIdItem.java
dx/src/com/android/dx/dex/file/StringIdsSection.java
dx/src/com/android/dx/dex/file/TypeIdItem.java
dx/src/com/android/dx/dex/file/TypeIdsSection.java
dx/src/com/android/dx/dex/file/TypeListItem.java
dx/src/com/android/dx/dex/file/UniformItemSection.java
dx/src/com/android/dx/dex/file/UniformListItem.java
dx/src/com/android/dx/dex/file/ValueEncoder.java
dx/src/com/android/dx/io/CodeReader.java
dx/src/com/android/dx/io/DexHasher.java
dx/src/com/android/dx/io/DexIndexPrinter.java
dx/src/com/android/dx/io/instructions/AddressMap.java
dx/src/com/android/dx/io/instructions/BaseCodeCursor.java
dx/src/com/android/dx/io/instructions/DecodedInstruction.java
dx/src/com/android/dx/io/instructions/InstructionCodec.java
dx/src/com/android/dx/merge/DexMerger.java
dx/src/com/android/dx/merge/IndexMap.java
dx/src/com/android/dx/merge/InstructionTransformer.java
dx/src/com/android/dx/merge/SortableType.java
dx/src/com/android/dx/rop/annotation/Annotation.java
dx/src/com/android/dx/rop/annotation/Annotations.java
dx/src/com/android/dx/rop/code/FillArrayDataInsn.java
dx/src/com/android/dx/rop/code/LocalVariableInfo.java
dx/src/com/android/dx/rop/code/PlainInsn.java
dx/src/com/android/dx/rop/code/RegisterSpec.java
dx/src/com/android/dx/rop/code/RegisterSpecList.java
dx/src/com/android/dx/rop/code/RopMethod.java
dx/src/com/android/dx/rop/cst/CstArray.java
dx/src/com/android/dx/rop/cst/StdConstantPool.java
dx/src/com/android/dx/rop/type/Type.java
dx/src/com/android/dx/ssa/BasicRegisterMapper.java
dx/src/com/android/dx/ssa/DeadCodeRemover.java
dx/src/com/android/dx/ssa/DomFront.java
dx/src/com/android/dx/ssa/EscapeAnalysis.java
dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java
dx/src/com/android/dx/ssa/LiteralOpUpgrader.java
dx/src/com/android/dx/ssa/LocalVariableExtractor.java
dx/src/com/android/dx/ssa/LocalVariableInfo.java
dx/src/com/android/dx/ssa/MoveParamCombiner.java
dx/src/com/android/dx/ssa/NormalSsaInsn.java
dx/src/com/android/dx/ssa/Optimizer.java
dx/src/com/android/dx/ssa/PhiInsn.java
dx/src/com/android/dx/ssa/PhiTypeResolver.java
dx/src/com/android/dx/ssa/RegisterMapper.java
dx/src/com/android/dx/ssa/SCCP.java
dx/src/com/android/dx/ssa/SsaBasicBlock.java
dx/src/com/android/dx/ssa/SsaConverter.java
dx/src/com/android/dx/ssa/SsaInsn.java
dx/src/com/android/dx/ssa/SsaMethod.java
dx/src/com/android/dx/ssa/SsaRenamer.java
dx/src/com/android/dx/ssa/back/FirstFitAllocator.java
dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java
dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java
dx/src/com/android/dx/ssa/back/InterferenceGraph.java
dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java
dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java
dx/src/com/android/dx/ssa/back/RegisterAllocator.java
dx/src/com/android/dx/ssa/back/SsaToRop.java
dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java
dx/src/com/android/dx/util/MutabilityException.java
dx/src/com/android/dx/util/Output.java
dx/src/com/android/dx/util/Uint.java [deleted file]
dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java
dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java
dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java
dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java

@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.ByteArrayByteInput;
+import com.android.dex.util.ByteArrayByteInput;
 import junit.framework.TestCase;
 
 public final class EncodedValueReaderTest extends TestCase {
index d46d14f..6d1b9e8 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dx.util._tests;
 
+import com.android.dx.util.BitIntSet;
+import com.android.dx.util.IntIterator;
+import com.android.dx.util.ListIntSet;
 import java.util.NoSuchElementException;
 import junit.framework.TestCase;
 
index e427513..5cf2b6f 100644 (file)
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dx.util._tests;
 
+import com.android.dx.util.Bits;
 import junit.framework.TestCase;
 
 public final class BitsTest extends TestCase {
index 7a53a67..8b72da1 100644 (file)
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dx.util._tests;
 
+import com.android.dx.util.IntList;
 import junit.framework.TestCase;
 
 public final class IntListTest extends TestCase {
index 868e630..dd72b6b 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dx.util._tests;
 
+import com.android.dx.util.BitIntSet;
+import com.android.dx.util.IntIterator;
+import com.android.dx.util.ListIntSet;
 import java.util.NoSuchElementException;
 import junit.framework.TestCase;
 
similarity index 79%
rename from dx/src/com/android/dx/io/Annotation.java
rename to dx/src/com/android/dex/Annotation.java
index ed2446e..e5ef978 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import static com.android.dx.io.EncodedValueReader.ENCODED_ANNOTATION;
+import static com.android.dex.EncodedValueReader.ENCODED_ANNOTATION;
 
 /**
  * An annotation.
  */
 public final class Annotation implements Comparable<Annotation> {
-    private final DexBuffer buffer;
+    private final Dex dex;
     private final byte visibility;
     private final EncodedValue encodedAnnotation;
 
-    public Annotation(DexBuffer dexBuffer, byte visibility, EncodedValue encodedAnnotation) {
-        this.buffer = dexBuffer;
+    public Annotation(Dex dex, byte visibility, EncodedValue encodedAnnotation) {
+        this.dex = dex;
         this.visibility = visibility;
         this.encodedAnnotation = encodedAnnotation;
     }
@@ -46,7 +46,7 @@ public final class Annotation implements Comparable<Annotation> {
         return reader.getAnnotationType();
     }
 
-    public void writeTo(DexBuffer.Section out) {
+    public void writeTo(Dex.Section out) {
         out.writeByte(visibility);
         encodedAnnotation.writeTo(out);
     }
@@ -56,8 +56,8 @@ public final class Annotation implements Comparable<Annotation> {
     }
 
     @Override public String toString() {
-        return buffer == null
+        return dex == null
                 ? visibility + " " + getTypeIndex()
-                : visibility + " " + buffer.typeNames().get(getTypeIndex());
+                : visibility + " " + dex.typeNames().get(getTypeIndex());
     }
 }
similarity index 99%
rename from dx/src/com/android/dx/io/ClassData.java
rename to dx/src/com/android/dex/ClassData.java
index 5da7ddd..840756c 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
 public final class ClassData {
     private final Field[] staticFields;
similarity index 95%
rename from dx/src/com/android/dx/io/ClassDef.java
rename to dx/src/com/android/dex/ClassDef.java
index 5c8d10b..b3225ec 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
 /**
  * A type definition.
  */
 public final class ClassDef {
     public static final int NO_INDEX = -1;
-    private final DexBuffer buffer;
+    private final Dex buffer;
     private final int offset;
     private final int typeIndex;
     private final int accessFlags;
@@ -32,7 +32,7 @@ public final class ClassDef {
     private final int classDataOffset;
     private final int staticValuesOffset;
 
-    public ClassDef(DexBuffer buffer, int offset, int typeIndex, int accessFlags,
+    public ClassDef(Dex buffer, int offset, int typeIndex, int accessFlags,
             int supertypeIndex, int interfacesOffset, int sourceFileIndex,
             int annotationsOffset, int classDataOffset, int staticValuesOffset) {
         this.buffer = buffer;
similarity index 99%
rename from dx/src/com/android/dx/io/Code.java
rename to dx/src/com/android/dex/Code.java
index 82da862..9258af7 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
 public final class Code {
     private final int registersSize;
similarity index 93%
rename from dx/src/com/android/dx/io/DexBuffer.java
rename to dx/src/com/android/dex/Dex.java
index 2ea597e..2395e50 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
-
-import com.android.dx.dex.DexFormat;
-import com.android.dx.dex.SizeOf;
-import com.android.dx.dex.TableOfContents;
-import com.android.dx.io.Code.CatchHandler;
-import com.android.dx.io.Code.Try;
-import com.android.dx.merge.TypeList;
-import com.android.dx.util.ByteInput;
-import com.android.dx.util.ByteOutput;
-import com.android.dx.util.DexException;
-import com.android.dx.util.FileUtils;
-import com.android.dx.util.Leb128Utils;
-import com.android.dx.util.Mutf8;
+package com.android.dex;
+
+import com.android.dex.Code.CatchHandler;
+import com.android.dex.Code.Try;
+import com.android.dex.util.ByteInput;
+import com.android.dex.util.ByteOutput;
+import com.android.dex.util.FileUtils;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -49,7 +43,7 @@ import java.util.zip.ZipFile;
  * The bytes of a dex file in memory for reading and writing. All int offsets
  * are unsigned.
  */
-public final class DexBuffer {
+public final class Dex {
     private byte[] data;
     private final TableOfContents tableOfContents = new TableOfContents();
     private int length = 0;
@@ -121,7 +115,7 @@ public final class DexBuffer {
     /**
      * Creates a new dex buffer defining no classes.
      */
-    public DexBuffer() {
+    public Dex() {
         this.data = new byte[0];
     }
 
@@ -129,7 +123,7 @@ public final class DexBuffer {
      * Creates a new dex buffer that reads from {@code data}. It is an error to
      * modify {@code data} after using it to create a dex buffer.
      */
-    public DexBuffer(byte[] data) throws IOException {
+    public Dex(byte[] data) throws IOException {
         this.data = data;
         this.length = data.length;
         this.tableOfContents.readFrom(this);
@@ -138,14 +132,14 @@ public final class DexBuffer {
     /**
      * Creates a new dex buffer of the dex in {@code in}, and closes {@code in}.
      */
-    public DexBuffer(InputStream in) throws IOException {
+    public Dex(InputStream in) throws IOException {
         loadFrom(in);
     }
 
     /**
      * Creates a new dex buffer from the dex file {@code file}.
      */
-    public DexBuffer(File file) throws IOException {
+    public Dex(File file) throws IOException {
         if (FileUtils.hasArchiveSuffix(file.getName())) {
             ZipFile zipFile = new ZipFile(file);
             ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME);
@@ -258,7 +252,7 @@ public final class DexBuffer {
                     return Collections.<ClassDef>emptySet().iterator();
                 }
                 return new Iterator<ClassDef>() {
-                    private DexBuffer.Section in = open(tableOfContents.classDefs.off);
+                    private Dex.Section in = open(tableOfContents.classDefs.off);
                     private int count = 0;
 
                     public boolean hasNext() {
@@ -361,15 +355,15 @@ public final class DexBuffer {
         }
 
         public int readUleb128() {
-            return Leb128Utils.readUnsignedLeb128(this);
+            return Leb128.readUnsignedLeb128(this);
         }
 
         public int readUleb128p1() {
-            return Leb128Utils.readUnsignedLeb128(this) - 1;
+            return Leb128.readUnsignedLeb128(this) - 1;
         }
 
         public int readSleb128() {
-            return Leb128Utils.readSignedLeb128(this);
+            return Leb128.readSignedLeb128(this);
         }
 
         public TypeList readTypeList() {
@@ -379,7 +373,7 @@ public final class DexBuffer {
                 types[i] = readShort();
             }
             alignToFourBytes();
-            return new TypeList(DexBuffer.this, types);
+            return new TypeList(Dex.this, types);
         }
 
         public String readString() {
@@ -405,21 +399,21 @@ public final class DexBuffer {
             int declaringClassIndex = readUnsignedShort();
             int typeIndex = readUnsignedShort();
             int nameIndex = readInt();
-            return new FieldId(DexBuffer.this, declaringClassIndex, typeIndex, nameIndex);
+            return new FieldId(Dex.this, declaringClassIndex, typeIndex, nameIndex);
         }
 
         public MethodId readMethodId() {
             int declaringClassIndex = readUnsignedShort();
             int protoIndex = readUnsignedShort();
             int nameIndex = readInt();
-            return new MethodId(DexBuffer.this, declaringClassIndex, protoIndex, nameIndex);
+            return new MethodId(Dex.this, declaringClassIndex, protoIndex, nameIndex);
         }
 
         public ProtoId readProtoId() {
             int shortyIndex = readInt();
             int returnTypeIndex = readInt();
             int parametersOffset = readInt();
-            return new ProtoId(DexBuffer.this, shortyIndex, returnTypeIndex, parametersOffset);
+            return new ProtoId(Dex.this, shortyIndex, returnTypeIndex, parametersOffset);
         }
 
         public ClassDef readClassDef() {
@@ -432,7 +426,7 @@ public final class DexBuffer {
             int annotationsOffset = readInt();
             int classDataOffset = readInt();
             int staticValuesOffset = readInt();
-            return new ClassDef(DexBuffer.this, offset, type, accessFlags, supertype,
+            return new ClassDef(Dex.this, offset, type, accessFlags, supertype,
                     interfacesOffset, sourceFileIndex, annotationsOffset, classDataOffset,
                     staticValuesOffset);
         }
@@ -555,7 +549,7 @@ public final class DexBuffer {
             int start = position;
             new EncodedValueReader(this, EncodedValueReader.ENCODED_ANNOTATION).skipValue();
             int end = position;
-            return new Annotation(DexBuffer.this, visibility,
+            return new Annotation(Dex.this, visibility,
                     new EncodedValue(Arrays.copyOfRange(data, start, end)));
         }
 
@@ -585,7 +579,7 @@ public final class DexBuffer {
          */
         public void alignToFourBytes() {
             int unalignedCount = position;
-            position = DexBuffer.fourByteAlign(position);
+            position = Dex.fourByteAlign(position);
             for (int i = unalignedCount; i < position; i++) {
                 data[i] = 0;
             }
@@ -640,7 +634,7 @@ public final class DexBuffer {
 
         public void writeUleb128(int i) {
             try {
-                Leb128Utils.writeUnsignedLeb128(this, i);
+                Leb128.writeUnsignedLeb128(this, i);
                 ensureCapacity(0);
             } catch (ArrayIndexOutOfBoundsException e) {
                 throw new DexException("Section limit " + limit + " exceeded by " + name);
@@ -653,7 +647,7 @@ public final class DexBuffer {
 
         public void writeSleb128(int i) {
             try {
-                Leb128Utils.writeSignedLeb128(this, i);
+                Leb128.writeSignedLeb128(this, i);
                 ensureCapacity(0);
             } catch (ArrayIndexOutOfBoundsException e) {
                 throw new DexException("Section limit " + limit + " exceeded by " + name);
similarity index 92%
rename from dx/src/com/android/dx/util/DexException.java
rename to dx/src/com/android/dex/DexException.java
index 527b0b9..a30a46f 100644 (file)
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex;
+
+import com.android.dex.util.ExceptionWithContext;
 
 /**
  * Thrown when there's a format problem reading, writing, or generally
similarity index 99%
rename from dx/src/com/android/dx/dex/DexFormat.java
rename to dx/src/com/android/dex/DexFormat.java
index 3543b35..85941fd 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.dex;
+package com.android.dex;
 
 /**
  * Constants that show up in and are otherwise related to {@code .dex}
similarity index 90%
rename from dx/src/com/android/dx/io/EncodedValue.java
rename to dx/src/com/android/dex/EncodedValue.java
index c83c364..8d0c3ad 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.ByteArrayByteInput;
-import com.android.dx.util.ByteInput;
+import com.android.dex.util.ByteArrayByteInput;
+import com.android.dex.util.ByteInput;
 
 /**
  * An encoded value or array.
@@ -37,7 +37,7 @@ public final class EncodedValue implements Comparable<EncodedValue> {
         return data;
     }
 
-    public void writeTo(DexBuffer.Section out) {
+    public void writeTo(Dex.Section out) {
         out.write(data);
     }
 
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex;
+
+import com.android.dex.util.ByteInput;
+import com.android.dex.util.ByteOutput;
 
 /**
- * Helpers for {@code encoded_values} and parts thereof.
+ * Read and write {@code encoded_value} primitives.
  */
-public final class EncodedValueUtils {
-    private EncodedValueUtils() {
+public final class EncodedValueCodec {
+    private EncodedValueCodec() {
     }
 
     /**
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.ByteInput;
-import com.android.dx.util.DexException;
-import com.android.dx.util.EncodedValueUtils;
-import com.android.dx.util.Leb128Utils;
+import com.android.dex.util.ByteInput;
 
 /**
  * Pull parser for encoded values.
@@ -98,7 +95,7 @@ public final class EncodedValueReader {
     public int readArray() {
         checkType(ENCODED_ARRAY);
         type = MUST_READ;
-        return Leb128Utils.readUnsignedLeb128(in);
+        return Leb128.readUnsignedLeb128(in);
     }
 
     /**
@@ -117,8 +114,8 @@ public final class EncodedValueReader {
     public int readAnnotation() {
         checkType(ENCODED_ANNOTATION);
         type = MUST_READ;
-        annotationType = Leb128Utils.readUnsignedLeb128(in);
-        return Leb128Utils.readUnsignedLeb128(in);
+        annotationType = Leb128.readUnsignedLeb128(in);
+        return Leb128.readUnsignedLeb128(in);
     }
 
     /**
@@ -131,79 +128,79 @@ public final class EncodedValueReader {
     }
 
     public int readAnnotationName() {
-        return Leb128Utils.readUnsignedLeb128(in);
+        return Leb128.readUnsignedLeb128(in);
     }
 
     public byte readByte() {
         checkType(ENCODED_BYTE);
         type = MUST_READ;
-        return (byte) EncodedValueUtils.readSignedInt(in, arg);
+        return (byte) EncodedValueCodec.readSignedInt(in, arg);
     }
 
     public short readShort() {
         checkType(ENCODED_SHORT);
         type = MUST_READ;
-        return (short) EncodedValueUtils.readSignedInt(in, arg);
+        return (short) EncodedValueCodec.readSignedInt(in, arg);
     }
 
     public char readChar() {
         checkType(ENCODED_CHAR);
         type = MUST_READ;
-        return (char) EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return (char) EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public int readInt() {
         checkType(ENCODED_INT);
         type = MUST_READ;
-        return EncodedValueUtils.readSignedInt(in, arg);
+        return EncodedValueCodec.readSignedInt(in, arg);
     }
 
     public long readLong() {
         checkType(ENCODED_LONG);
         type = MUST_READ;
-        return EncodedValueUtils.readSignedLong(in, arg);
+        return EncodedValueCodec.readSignedLong(in, arg);
     }
 
     public float readFloat() {
         checkType(ENCODED_FLOAT);
         type = MUST_READ;
-        return Float.intBitsToFloat(EncodedValueUtils.readUnsignedInt(in, arg, true));
+        return Float.intBitsToFloat(EncodedValueCodec.readUnsignedInt(in, arg, true));
     }
 
     public double readDouble() {
         checkType(ENCODED_DOUBLE);
         type = MUST_READ;
-        return Double.longBitsToDouble(EncodedValueUtils.readUnsignedLong(in, arg, true));
+        return Double.longBitsToDouble(EncodedValueCodec.readUnsignedLong(in, arg, true));
     }
 
     public int readString() {
         checkType(ENCODED_STRING);
         type = MUST_READ;
-        return EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public int readType() {
         checkType(ENCODED_TYPE);
         type = MUST_READ;
-        return EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public int readField() {
         checkType(ENCODED_FIELD);
         type = MUST_READ;
-        return EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public int readEnum() {
         checkType(ENCODED_ENUM);
         type = MUST_READ;
-        return EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public int readMethod() {
         checkType(ENCODED_METHOD);
         type = MUST_READ;
-        return EncodedValueUtils.readUnsignedInt(in, arg, false);
+        return EncodedValueCodec.readUnsignedInt(in, arg, false);
     }
 
     public void readNull() {
similarity index 82%
rename from dx/src/com/android/dx/io/FieldId.java
rename to dx/src/com/android/dex/FieldId.java
index da409fa..2f41708 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.Unsigned;
+import com.android.dex.util.Unsigned;
 
 public final class FieldId implements Comparable<FieldId> {
-    private final DexBuffer buffer;
+    private final Dex dex;
     private final int declaringClassIndex;
     private final int typeIndex;
     private final int nameIndex;
 
-    public FieldId(DexBuffer buffer, int declaringClassIndex, int typeIndex, int nameIndex) {
-        this.buffer = buffer;
+    public FieldId(Dex dex, int declaringClassIndex, int typeIndex, int nameIndex) {
+        this.dex = dex;
         this.declaringClassIndex = declaringClassIndex;
         this.typeIndex = typeIndex;
         this.nameIndex = nameIndex;
@@ -53,16 +53,16 @@ public final class FieldId implements Comparable<FieldId> {
         return Unsigned.compare(typeIndex, other.typeIndex); // should always be 0
     }
 
-    public void writeTo(DexBuffer.Section out) {
+    public void writeTo(Dex.Section out) {
         out.writeUnsignedShort(declaringClassIndex);
         out.writeUnsignedShort(typeIndex);
         out.writeInt(nameIndex);
     }
 
     @Override public String toString() {
-        if (buffer == null) {
+        if (dex == null) {
             return declaringClassIndex + " " + typeIndex + " " + nameIndex;
         }
-        return buffer.typeNames().get(typeIndex) + "." + buffer.strings().get(nameIndex);
+        return dex.typeNames().get(typeIndex) + "." + dex.strings().get(nameIndex);
     }
 }
similarity index 95%
rename from dx/src/com/android/dx/util/Leb128Utils.java
rename to dx/src/com/android/dex/Leb128.java
index 1037463..1a82e38 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex;
+
+import com.android.dex.util.ByteInput;
+import com.android.dex.util.ByteOutput;
 
 /**
  * Reads and writes DWARFv3 LEB 128 signed and unsigned integers. See DWARF v3
  * section 7.6.
  */
-public final class Leb128Utils {
-    /**
-     * This class is uninstantiable.
-     */
-    private Leb128Utils() {
-        // This space intentionally left blank.
+public final class Leb128 {
+    private Leb128() {
     }
 
     /**
similarity index 77%
rename from dx/src/com/android/dx/io/MethodId.java
rename to dx/src/com/android/dex/MethodId.java
index e653661..e518740 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.Unsigned;
+import com.android.dex.util.Unsigned;
 
 public final class MethodId implements Comparable<MethodId> {
-    private final DexBuffer buffer;
+    private final Dex dex;
     private final int declaringClassIndex;
     private final int protoIndex;
     private final int nameIndex;
 
-    public MethodId(DexBuffer buffer, int declaringClassIndex, int protoIndex, int nameIndex) {
-        this.buffer = buffer;
+    public MethodId(Dex dex, int declaringClassIndex, int protoIndex, int nameIndex) {
+        this.dex = dex;
         this.declaringClassIndex = declaringClassIndex;
         this.protoIndex = protoIndex;
         this.nameIndex = nameIndex;
@@ -53,18 +53,18 @@ public final class MethodId implements Comparable<MethodId> {
         return Unsigned.compare(protoIndex, other.protoIndex);
     }
 
-    public void writeTo(DexBuffer.Section out) {
+    public void writeTo(Dex.Section out) {
         out.writeUnsignedShort(declaringClassIndex);
         out.writeUnsignedShort(protoIndex);
         out.writeInt(nameIndex);
     }
 
     @Override public String toString() {
-        if (buffer == null) {
+        if (dex == null) {
             return declaringClassIndex + " " + protoIndex + " " + nameIndex;
         }
-        return buffer.typeNames().get(declaringClassIndex)
-                + "." + buffer.strings().get(nameIndex)
-                + buffer.readTypeList(buffer.protoIds().get(protoIndex).getParametersOffset());
+        return dex.typeNames().get(declaringClassIndex)
+                + "." + dex.strings().get(nameIndex)
+                + dex.readTypeList(dex.protoIds().get(protoIndex).getParametersOffset());
     }
 }
similarity index 98%
rename from dx/src/com/android/dx/util/Mutf8.java
rename to dx/src/com/android/dex/Mutf8.java
index fe55724..c64da33 100644 (file)
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex;
 
+import com.android.dex.util.ByteInput;
 import java.io.UTFDataFormatException;
 
 /**
similarity index 77%
rename from dx/src/com/android/dx/io/ProtoId.java
rename to dx/src/com/android/dex/ProtoId.java
index 98c0777..9d9f484 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.io;
+package com.android.dex;
 
-import com.android.dx.util.Unsigned;
+import com.android.dex.util.Unsigned;
 
 public final class ProtoId implements Comparable<ProtoId> {
-    private final DexBuffer buffer;
+    private final Dex dex;
     private final int shortyIndex;
     private final int returnTypeIndex;
     private final int parametersOffset;
 
-    public ProtoId(DexBuffer buffer, int shortyIndex, int returnTypeIndex, int parametersOffset) {
-        this.buffer = buffer;
+    public ProtoId(Dex dex, int shortyIndex, int returnTypeIndex, int parametersOffset) {
+        this.dex = dex;
         this.shortyIndex = shortyIndex;
         this.returnTypeIndex = returnTypeIndex;
         this.parametersOffset = parametersOffset;
@@ -50,19 +50,19 @@ public final class ProtoId implements Comparable<ProtoId> {
         return parametersOffset;
     }
 
-    public void writeTo(DexBuffer.Section out) {
+    public void writeTo(Dex.Section out) {
         out.writeInt(shortyIndex);
         out.writeInt(returnTypeIndex);
         out.writeInt(parametersOffset);
     }
 
     @Override public String toString() {
-        if (buffer == null) {
+        if (dex == null) {
             return shortyIndex + " " + returnTypeIndex + " " + parametersOffset;
         }
 
-        return buffer.strings().get(shortyIndex)
-                + ": " + buffer.typeNames().get(returnTypeIndex)
-                + " " + buffer.readTypeList(parametersOffset);
+        return dex.strings().get(shortyIndex)
+                + ": " + dex.typeNames().get(returnTypeIndex)
+                + " " + dex.readTypeList(parametersOffset);
     }
 }
similarity index 98%
rename from dx/src/com/android/dx/dex/SizeOf.java
rename to dx/src/com/android/dex/SizeOf.java
index 6ded782..65fab56 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.dex;
+package com.android.dex;
 
 public final class SizeOf {
     private SizeOf() {}
similarity index 93%
rename from dx/src/com/android/dx/dex/TableOfContents.java
rename to dx/src/com/android/dex/TableOfContents.java
index fbe4626..d1b87ac 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.dex;
+package com.android.dex;
 
-import com.android.dx.io.DexBuffer;
-import com.android.dx.util.DexException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
@@ -67,13 +65,13 @@ public final class TableOfContents {
         signature = new byte[20];
     }
 
-    public void readFrom(DexBuffer buffer) throws IOException {
-        readHeader(buffer.open(0));
-        readMap(buffer.open(mapList.off));
+    public void readFrom(Dex dex) throws IOException {
+        readHeader(dex.open(0));
+        readMap(dex.open(mapList.off));
         computeSizesFromOffsets();
     }
 
-    private void readHeader(DexBuffer.Section headerIn) throws UnsupportedEncodingException {
+    private void readHeader(Dex.Section headerIn) throws UnsupportedEncodingException {
         byte[] magic = headerIn.readByteArray(8);
         int apiTarget = DexFormat.magicToApi(magic);
 
@@ -114,7 +112,7 @@ public final class TableOfContents {
         dataOff = headerIn.readInt();
     }
 
-    private void readMap(DexBuffer.Section in) throws IOException {
+    private void readMap(Dex.Section in) throws IOException {
         int mapSize = in.readInt();
         Section previous = null;
         for (int i = 0; i < mapSize; i++) {
@@ -165,7 +163,7 @@ public final class TableOfContents {
         throw new IllegalArgumentException("No such map item: " + type);
     }
 
-    public void writeHeader(DexBuffer.Section out) throws IOException {
+    public void writeHeader(Dex.Section out) throws IOException {
         out.write(DexFormat.apiToMagic(DexFormat.API_NO_EXTENDED_OPCODES).getBytes("UTF-8"));
         out.writeInt(checksum);
         out.write(signature);
@@ -191,7 +189,7 @@ public final class TableOfContents {
         out.writeInt(dataOff);
     }
 
-    public void writeMap(DexBuffer.Section out) throws IOException {
+    public void writeMap(Dex.Section out) throws IOException {
         int count = 0;
         for (Section section : sections) {
             if (section.exists()) {
similarity index 81%
rename from dx/src/com/android/dx/merge/TypeList.java
rename to dx/src/com/android/dex/TypeList.java
index 62984e2..aa1bf58 100644 (file)
  * limitations under the License.
  */
 
-package com.android.dx.merge;
+package com.android.dex;
 
-import com.android.dx.io.DexBuffer;
-import com.android.dx.util.Unsigned;
-import java.util.Arrays;
+import com.android.dex.util.Unsigned;
 
 public final class TypeList implements Comparable<TypeList> {
 
     public static final TypeList EMPTY = new TypeList(null, new short[0]);
 
-    private final DexBuffer buffer;
+    private final Dex dex;
     private final short[] types;
 
-    public TypeList(DexBuffer buffer, short[] types) {
-        this.buffer = buffer;
+    public TypeList(Dex dex, short[] types) {
+        this.dex = dex;
         this.types = types;
     }
 
@@ -49,7 +47,7 @@ public final class TypeList implements Comparable<TypeList> {
         StringBuilder result = new StringBuilder();
         result.append("(");
         for (int i = 0, typesLength = types.length; i < typesLength; i++) {
-            result.append(buffer != null ? buffer.typeNames().get(types[i]) : types[i]);
+            result.append(dex != null ? dex.typeNames().get(types[i]) : types[i]);
         }
         result.append(")");
         return result.toString();
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 public final class ByteArrayByteInput implements ByteInput {
 
similarity index 96%
rename from dx/src/com/android/dx/util/ByteInput.java
rename to dx/src/com/android/dex/util/ByteInput.java
index 8181e3e..f1a7196 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 /**
  * A byte source.
similarity index 96%
rename from dx/src/com/android/dx/util/ByteOutput.java
rename to dx/src/com/android/dex/util/ByteOutput.java
index 512dcf8..eb77040 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 /**
  * A byte sink.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 import java.io.PrintStream;
 import java.io.PrintWriter;
@@ -22,8 +22,7 @@ import java.io.PrintWriter;
 /**
  * Exception which carries around structured context.
  */
-public class ExceptionWithContext
-        extends RuntimeException {
+public class ExceptionWithContext extends RuntimeException {
     /** {@code non-null;} human-oriented context of the exception */
     private StringBuffer context;
 
similarity index 95%
rename from dx/src/com/android/dx/util/FileUtils.java
rename to dx/src/com/android/dex/util/FileUtils.java
index bcf6729..4cea95c 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -24,11 +24,7 @@ import java.io.IOException;
  * File I/O utilities.
  */
 public final class FileUtils {
-    /**
-     * This class is uninstantiable.
-     */
     private FileUtils() {
-        // This space intentionally left blank.
     }
 
     /**
similarity index 97%
rename from dx/src/com/android/dx/util/Unsigned.java
rename to dx/src/com/android/dex/util/Unsigned.java
index f15bd86..cb50d0a 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.dx.util;
+package com.android.dex.util;
 
 /**
  * Unsigned arithmetic over Java's signed types.
index c56dd3e..7bff2ff 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.cf.code;
 
-import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.StdTypeList;
index 56d3991..8fb9560 100644 (file)
@@ -18,8 +18,8 @@ package com.android.dx.cf.code;
 
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstMemberRef;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.Bits;
 import com.android.dx.util.IntList;
index 412dfc3..5370c95 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.cf.code;
 
-import com.android.dx.util.FixedSizeList;
 import com.android.dx.util.Hex;
 import com.android.dx.util.LabeledList;
 
index 51f6334..696abc8 100644 (file)
@@ -16,9 +16,9 @@
 
 package com.android.dx.cf.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
 import com.android.dx.util.MutabilityControl;
 
index 002a4fb..cb32b92 100644 (file)
 
 package com.android.dx.cf.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.IntList;
 
 /**
index 2962698..4a0bae1 100644 (file)
@@ -16,9 +16,9 @@
 
 package com.android.dx.cf.code;
 
+import com.android.dx.rop.code.LocalItem;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.type.Type;
-import com.android.dx.rop.code.LocalItem;
 import com.android.dx.util.FixedSizeList;
 
 /**
index 75af047..07ca96d 100644 (file)
 
 package com.android.dx.cf.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-import com.android.dx.util.ExceptionWithContext;
-import com.android.dx.util.Hex;
 import com.android.dx.util.MutabilityControl;
 import com.android.dx.util.ToHuman;
 
index 5d03055..c4b7da9 100644 (file)
 
 package com.android.dx.cf.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
-import com.android.dx.util.MutabilityControl;
-
 import java.util.ArrayList;
 
 /**
index a81feaf..a190505 100644 (file)
 
 package com.android.dx.cf.code;
 
+import com.android.dx.rop.code.LocalItem;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.Type;
-import com.android.dx.rop.code.LocalItem;
 import java.util.ArrayList;
 
 /**
index cafd177..0286a70 100644 (file)
 
 package com.android.dx.cf.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
-import com.android.dx.util.MutabilityControl;
 
 /**
  * Representation of an array of local variables, with Java semantics.
index 715cfd8..c318b4c 100644 (file)
 
 package com.android.dx.cf.code;
 
-import com.android.dx.rop.code.*;
+import com.android.dx.rop.code.AccessFlags;
+import com.android.dx.rop.code.BasicBlock;
+import com.android.dx.rop.code.BasicBlockList;
+import com.android.dx.rop.code.Insn;
+import com.android.dx.rop.code.InsnList;
+import com.android.dx.rop.code.PlainCstInsn;
+import com.android.dx.rop.code.PlainInsn;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
+import com.android.dx.rop.code.Rop;
+import com.android.dx.rop.code.RopMethod;
+import com.android.dx.rop.code.Rops;
+import com.android.dx.rop.code.SourcePosition;
+import com.android.dx.rop.code.ThrowingCstInsn;
+import com.android.dx.rop.code.ThrowingInsn;
+import com.android.dx.rop.code.TranslationAdvice;
 import com.android.dx.rop.cst.CstInteger;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Prototype;
@@ -26,7 +41,6 @@ import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.Bits;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashMap;
index f45bc1f..f1b8db4 100644 (file)
@@ -41,7 +41,6 @@ import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 
 /**
index 220f281..7cbab04 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.cf.code;
 
-import com.android.dx.util.ExceptionWithContext;
+import com.android.dex.util.ExceptionWithContext;
 
 /**
  * Exception from simulation.
index c097831..35e6228 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.dx.cf.code;
 
+import com.android.dx.rop.code.LocalItem;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstInteger;
@@ -24,9 +25,7 @@ import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.Type;
-import com.android.dx.rop.code.LocalItem;
 import com.android.dx.util.Hex;
-
 import java.util.ArrayList;
 
 /**
index fdbc990..f766694 100644 (file)
@@ -42,7 +42,6 @@ import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
-
 import java.io.IOException;
 
 /**
index 7621bf7..e2e2cfb 100644 (file)
 
 package com.android.dx.cf.direct;
 
-import com.android.dx.util.FileUtils;
-
+import com.android.dex.util.FileUtils;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipEntry;
-import java.util.Arrays;
-import java.util.Comparator;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 /**
  * Opens all the class files found in a class path element. Path elements
index efcc80b..4262cf8 100644 (file)
@@ -30,9 +30,6 @@ import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
-import com.android.dx.util.IntList;
-
-import java.util.List;
 import java.util.ArrayList;
 
 /**
index 4f1c85d..a7bb073 100644 (file)
@@ -28,8 +28,8 @@ import com.android.dx.cf.iface.ParseObserver;
 import com.android.dx.cf.iface.StdAttributeList;
 import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.cst.ConstantPool;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.StdConstantPool;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
index ae04a13..992809a 100644 (file)
@@ -55,7 +55,6 @@ import com.android.dx.rop.cst.TypedConstant;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
-
 import java.io.IOException;
 
 /**
index 18a9d0e..6ed6d3b 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.cf.iface;
 
-import com.android.dx.util.ExceptionWithContext;
+import com.android.dex.util.ExceptionWithContext;
 
 /**
  * Exception from parsing.
index 6584b60..2de899c 100644 (file)
 
 package com.android.dx.command.annotool;
 
+import com.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations;
+import com.android.dx.cf.attrib.AttRuntimeVisibleAnnotations;
+import com.android.dx.cf.attrib.BaseAnnotations;
 import com.android.dx.cf.direct.ClassPathOpener;
 import com.android.dx.cf.direct.DirectClassFile;
 import com.android.dx.cf.direct.StdAttributeFactory;
-import com.android.dx.cf.iface.AttributeList;
 import com.android.dx.cf.iface.Attribute;
-import com.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations;
-import com.android.dx.cf.attrib.BaseAnnotations;
-import com.android.dx.cf.attrib.AttRuntimeVisibleAnnotations;
-import com.android.dx.util.ByteArray;
+import com.android.dx.cf.iface.AttributeList;
 import com.android.dx.rop.annotation.Annotation;
-
+import com.android.dx.util.ByteArray;
 import java.io.File;
 import java.lang.annotation.ElementType;
 import java.util.HashSet;
index 7661c3d..14d7373 100644 (file)
 
 package com.android.dx.command.annotool;
 
-import com.android.dx.cf.direct.ClassPathOpener;
-import com.android.dx.cf.direct.DirectClassFile;
-import com.android.dx.cf.direct.StdAttributeFactory;
-import com.android.dx.cf.iface.AttributeList;
-import com.android.dx.cf.iface.Attribute;
-import com.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations;
-import com.android.dx.cf.attrib.BaseAnnotations;
-import com.android.dx.cf.attrib.AttRuntimeVisibleAnnotations;
-import com.android.dx.util.ByteArray;
-import com.android.dx.rop.annotation.Annotation;
-
-import java.io.File;
 import java.lang.annotation.ElementType;
 import java.util.EnumSet;
-import java.util.Arrays;
 
 
 public class Main {
index 87f152a..8f1a3e8 100644 (file)
 
 package com.android.dx.command.dexer;
 
+import com.android.dex.Dex;
+import com.android.dex.DexFormat;
+import com.android.dex.util.FileUtils;
 import com.android.dx.Version;
 import com.android.dx.cf.code.SimException;
 import com.android.dx.cf.direct.ClassPathOpener;
 import com.android.dx.cf.iface.ParseException;
 import com.android.dx.command.DxConsole;
 import com.android.dx.command.UsageException;
-import com.android.dx.dex.DexFormat;
 import com.android.dx.dex.DexOptions;
 import com.android.dx.dex.cf.CfOptions;
 import com.android.dx.dex.cf.CfTranslator;
@@ -31,7 +33,6 @@ import com.android.dx.dex.code.PositionList;
 import com.android.dx.dex.file.ClassDefItem;
 import com.android.dx.dex.file.DexFile;
 import com.android.dx.dex.file.EncodedMethod;
-import com.android.dx.io.DexBuffer;
 import com.android.dx.merge.CollisionPolicy;
 import com.android.dx.merge.DexMerger;
 import com.android.dx.rop.annotation.Annotation;
@@ -39,7 +40,6 @@ import com.android.dx.rop.annotation.Annotations;
 import com.android.dx.rop.annotation.AnnotationsList;
 import com.android.dx.rop.cst.CstNat;
 import com.android.dx.rop.cst.CstString;
-import com.android.dx.util.FileUtils;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -257,18 +257,18 @@ public class Main {
      *     and the base dex do not exist.
      */
     private static byte[] mergeIncremental(byte[] update, File base) throws IOException {
-        DexBuffer dexA = null;
-        DexBuffer dexB = null;
+        Dex dexA = null;
+        Dex dexB = null;
 
         if (update != null) {
-            dexA = new DexBuffer(update);
+            dexA = new Dex(update);
         }
 
         if (base.exists()) {
-            dexB = new DexBuffer(base);
+            dexB = new Dex(base);
         }
 
-        DexBuffer result;
+        Dex result;
         if (dexA == null && dexB == null) {
             return null;
         } else if (dexA == null) {
@@ -289,15 +289,15 @@ public class Main {
      * same type, this fails with an exception.
      */
     private static byte[] mergeLibraryDexBuffers(byte[] outArray) throws IOException {
-        for (byte[] libraryDexBuffer : libraryDexBuffers) {
+        for (byte[] libraryDex : libraryDexBuffers) {
             if (outArray == null) {
-                outArray = libraryDexBuffer;
+                outArray = libraryDex;
                 continue;
             }
 
-            DexBuffer a = new DexBuffer(outArray);
-            DexBuffer b = new DexBuffer(libraryDexBuffer);
-            DexBuffer ab = new DexMerger(a, b, CollisionPolicy.FAIL).merge();
+            Dex a = new Dex(outArray);
+            Dex b = new Dex(libraryDex);
+            Dex ab = new DexMerger(a, b, CollisionPolicy.FAIL).merge();
             outArray = ab.getBytes();
         }
 
index ad6540b..b71be47 100644 (file)
@@ -19,12 +19,10 @@ package com.android.dx.command.dump;
 import com.android.dx.cf.code.ConcreteMethod;
 import com.android.dx.cf.iface.Member;
 import com.android.dx.cf.iface.ParseObserver;
-import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IndentingWriter;
 import com.android.dx.util.TwoColumnOutput;
-
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.StringWriter;
index 6919b09..b670cd7 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.command.dump;
 
-import com.android.dx.cf.attrib.AttCode;
 import com.android.dx.cf.code.BasicBlocker;
 import com.android.dx.cf.code.ByteBlock;
 import com.android.dx.cf.code.ByteBlockList;
@@ -29,20 +28,19 @@ import com.android.dx.cf.direct.DirectClassFile;
 import com.android.dx.cf.direct.StdAttributeFactory;
 import com.android.dx.cf.iface.Member;
 import com.android.dx.cf.iface.Method;
+import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.code.BasicBlock;
 import com.android.dx.rop.code.BasicBlockList;
+import com.android.dx.rop.code.DexTranslationAdvice;
 import com.android.dx.rop.code.Insn;
 import com.android.dx.rop.code.InsnList;
 import com.android.dx.rop.code.RopMethod;
-import com.android.dx.rop.code.DexTranslationAdvice;
 import com.android.dx.rop.code.TranslationAdvice;
-import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.ssa.Optimizer;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
-
 import java.io.PrintStream;
 
 /**
index e98b6d6..9723c62 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.command.dump;
 import com.android.dx.cf.direct.DirectClassFile;
 import com.android.dx.cf.direct.StdAttributeFactory;
 import com.android.dx.util.ByteArray;
-
 import java.io.PrintStream;
 
 /**
index 9de48fc..1c4c74b 100644 (file)
@@ -23,12 +23,12 @@ import com.android.dx.cf.direct.StdAttributeFactory;
 import com.android.dx.cf.iface.Member;
 import com.android.dx.cf.iface.Method;
 import com.android.dx.cf.iface.ParseObserver;
+import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.code.BasicBlock;
 import com.android.dx.rop.code.BasicBlockList;
-import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.DexTranslationAdvice;
+import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.TranslationAdvice;
-import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.ssa.Optimizer;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
index d6ba374..59c10b0 100644 (file)
 
 package com.android.dx.command.dump;
 
+import com.android.dex.util.FileUtils;
 import com.android.dx.cf.iface.ParseException;
-import com.android.dx.util.FileUtils;
 import com.android.dx.util.HexParser;
-
 import java.io.UnsupportedEncodingException;
 
 /**
index 0572a30..80953c1 100644 (file)
@@ -20,25 +20,17 @@ import com.android.dx.cf.code.ConcreteMethod;
 import com.android.dx.cf.code.Ropper;
 import com.android.dx.cf.iface.Member;
 import com.android.dx.cf.iface.Method;
+import com.android.dx.rop.code.AccessFlags;
+import com.android.dx.rop.code.DexTranslationAdvice;
 import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.TranslationAdvice;
-import com.android.dx.rop.code.DexTranslationAdvice;
-import com.android.dx.rop.code.AccessFlags;
-import com.android.dx.ssa.DeadCodeRemover;
-import com.android.dx.ssa.PhiTypeResolver;
+import com.android.dx.ssa.Optimizer;
 import com.android.dx.ssa.SsaBasicBlock;
-import com.android.dx.ssa.SsaConverter;
 import com.android.dx.ssa.SsaInsn;
 import com.android.dx.ssa.SsaMethod;
-import com.android.dx.ssa.Optimizer;
-import com.android.dx.ssa.ConstCollector;
-import com.android.dx.ssa.SCCP;
-import com.android.dx.ssa.LiteralOpUpgrader;
-import com.android.dx.ssa.back.SsaToRop;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
-
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.BitSet;
index 6651f53..f84d87d 100644 (file)
 
 package com.android.dx.command.findusages;
 
-import com.android.dx.io.ClassData;
-import com.android.dx.io.ClassDef;
+import com.android.dex.ClassData;
+import com.android.dex.ClassDef;
+import com.android.dex.Dex;
+import com.android.dex.FieldId;
+import com.android.dex.MethodId;
 import com.android.dx.io.CodeReader;
-import com.android.dx.io.DexBuffer;
-import com.android.dx.io.FieldId;
-import com.android.dx.io.MethodId;
 import com.android.dx.io.OpcodeInfo;
 import com.android.dx.io.instructions.DecodedInstruction;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.util.Collections;
 import java.util.HashSet;
@@ -33,7 +32,7 @@ import java.util.Set;
 import java.util.regex.Pattern;
 
 public final class FindUsages {
-    private final DexBuffer dex;
+    private final Dex dex;
     private final Set<Integer> methodIds;
     private final Set<Integer> fieldIds;
     private final CodeReader codeReader = new CodeReader();
@@ -42,7 +41,7 @@ public final class FindUsages {
     private ClassDef currentClass;
     private ClassData.Method currentMethod;
 
-    public FindUsages(final DexBuffer dex, String declaredBy, String memberName, final PrintWriter out) {
+    public FindUsages(final Dex dex, String declaredBy, String memberName, final PrintWriter out) {
         this.dex = dex;
         this.out = out;
 
@@ -152,7 +151,7 @@ public final class FindUsages {
      * Returns the fields with {@code memberNameIndex} declared by {@code
      * declaringType}.
      */
-    private Set<Integer> getFieldIds(DexBuffer dex, Set<Integer> memberNameIndexes, int declaringType) {
+    private Set<Integer> getFieldIds(Dex dex, Set<Integer> memberNameIndexes, int declaringType) {
         Set<Integer> fields = new HashSet<Integer>();
         int fieldIndex = 0;
         for (FieldId fieldId : dex.fieldIds()) {
@@ -169,7 +168,7 @@ public final class FindUsages {
      * Returns the methods with {@code memberNameIndex} declared by {@code
      * declaringType} and its subtypes.
      */
-    private Set<Integer> getMethodIds(DexBuffer dex, Set<Integer> memberNameIndexes, int declaringType) {
+    private Set<Integer> getMethodIds(Dex dex, Set<Integer> memberNameIndexes, int declaringType) {
         Set<Integer> subtypes = findAssignableTypes(dex, declaringType);
 
         Set<Integer> methods = new HashSet<Integer>();
@@ -187,7 +186,7 @@ public final class FindUsages {
     /**
      * Returns the set of types that can be assigned to {@code typeIndex}.
      */
-    private Set<Integer> findAssignableTypes(DexBuffer dex, int typeIndex) {
+    private Set<Integer> findAssignableTypes(Dex dex, int typeIndex) {
         Set<Integer> assignableTypes = new HashSet<Integer>();
         assignableTypes.add(typeIndex);
 
index ba29787..b0eeb69 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.command.findusages;
 
-import com.android.dx.io.DexBuffer;
+import com.android.dex.Dex;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -27,7 +27,7 @@ public final class Main {
         String declaredBy = args[1];
         String memberName = args[2];
 
-        DexBuffer dex = new DexBuffer(new File(dexFile));
+        Dex dex = new Dex(new File(dexFile));
         PrintWriter out = new PrintWriter(System.out);
         new FindUsages(dex, declaredBy, memberName, out).findUsages();
         out.flush();
index 14c46d7..5972fa1 100644 (file)
 
 package com.android.dx.command.grep;
 
-import com.android.dx.io.ClassData;
-import com.android.dx.io.ClassDef;
+import com.android.dex.ClassData;
+import com.android.dex.ClassDef;
+import com.android.dex.Dex;
+import com.android.dex.EncodedValueReader;
+import com.android.dex.MethodId;
 import com.android.dx.io.CodeReader;
-import com.android.dx.io.DexBuffer;
-import com.android.dx.io.EncodedValueReader;
-import com.android.dx.io.MethodId;
 import com.android.dx.io.instructions.DecodedInstruction;
 import java.io.PrintWriter;
 import java.util.HashSet;
@@ -29,7 +29,7 @@ import java.util.Set;
 import java.util.regex.Pattern;
 
 public final class Grep {
-    private final DexBuffer dex;
+    private final Dex dex;
     private final CodeReader codeReader = new CodeReader();
     private final Set<Integer> stringIds;
 
@@ -39,7 +39,7 @@ public final class Grep {
     private ClassDef currentClass;
     private ClassData.Method currentMethod;
 
-    public Grep(final DexBuffer dex, Pattern pattern, final PrintWriter out) {
+    public Grep(final Dex dex, Pattern pattern, final PrintWriter out) {
         this.dex = dex;
         this.out = out;
 
@@ -116,7 +116,7 @@ public final class Grep {
         return count;
     }
 
-    private Set<Integer> getStringIds(DexBuffer dex, Pattern pattern) {
+    private Set<Integer> getStringIds(Dex dex, Pattern pattern) {
         Set<Integer> stringIds = new HashSet<Integer>();
         int stringIndex = 0;
         for (String s : dex.strings()) {
index e3b119a..08920f7 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.command.grep;
 
-import com.android.dx.io.DexBuffer;
+import com.android.dex.Dex;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -27,7 +27,7 @@ public final class Main {
         String dexFile = args[0];
         String pattern = args[1];
 
-        DexBuffer dex = new DexBuffer(new File(dexFile));
+        Dex dex = new Dex(new File(dexFile));
         int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep();
         System.exit((count > 0) ? 0 : 1);
     }
index 0a07451..db0c7a2 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.dx.dex;
 
+import com.android.dex.DexFormat;
+
 /**
  * Container for options used to control details of dex file generation.
  */
index 8dc8b92..90e32c3 100644 (file)
@@ -44,7 +44,6 @@ import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.Warning;
-
 import java.util.ArrayList;
 
 /**
index 468f0be..03d1d29 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.cf;
 
 import com.android.dx.dex.code.PositionList;
-
 import java.io.PrintStream;
 
 /**
index 8b94f91..d4cda2a 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.dx.dex.cf;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.cf.code.ConcreteMethod;
 import com.android.dx.cf.code.Ropper;
 import com.android.dx.cf.direct.DirectClassFile;
@@ -34,10 +35,10 @@ import com.android.dx.dex.file.EncodedMethod;
 import com.android.dx.rop.annotation.Annotations;
 import com.android.dx.rop.annotation.AnnotationsList;
 import com.android.dx.rop.code.AccessFlags;
+import com.android.dx.rop.code.DexTranslationAdvice;
 import com.android.dx.rop.code.LocalVariableExtractor;
 import com.android.dx.rop.code.LocalVariableInfo;
 import com.android.dx.rop.code.RopMethod;
-import com.android.dx.rop.code.DexTranslationAdvice;
 import com.android.dx.rop.code.TranslationAdvice;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstBoolean;
@@ -53,7 +54,6 @@ import com.android.dx.rop.cst.TypedConstant;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.ssa.Optimizer;
-import com.android.dx.util.ExceptionWithContext;
 
 /**
  * Static method that turns {@code byte[]}s containing Java
index 33d03fd..618fe2c 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.dex.cf;
 
 import com.android.dx.dex.code.DalvCode;
 import com.android.dx.rop.code.RopMethod;
-
 import java.io.PrintStream;
 
 /**
index a66421e..151d54c 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.dex.cf;
 import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.TranslationAdvice;
 import com.android.dx.ssa.Optimizer;
-
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
index 6674b75..fd28712 100644 (file)
@@ -19,10 +19,12 @@ package com.android.dx.dex.code;
 import com.android.dx.io.Opcodes;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.code.SourcePosition;
-import com.android.dx.rop.cst.*;
+import com.android.dx.rop.cst.Constant;
+import com.android.dx.rop.cst.CstLiteral32;
+import com.android.dx.rop.cst.CstLiteral64;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-import com.android.dx.rop.type.Type;
 import java.util.ArrayList;
 
 /**
index 90d2e8d..059091e 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.code;
 
 import com.android.dx.rop.type.Type;
-
 import java.util.HashSet;
 
 /**
index 0ee890f..8470789 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.dex.code;
 
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.FixedSizeList;
 
 /**
index 58f191b..ebaf288 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.dex.code;
 
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.type.Type;
-
 import java.util.HashSet;
 
 /**
index d0cf395..41fcbdc 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
 import com.android.dx.util.TwoColumnOutput;
-
 import java.util.BitSet;
 
 /**
index e856cb4..ace0e8f 100644 (file)
 
 package com.android.dx.dex.code;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.io.Opcodes;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstBaseMethodRef;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.FixedSizeList;
 import com.android.dx.util.IndentingWriter;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
index 6fab094..4f81949 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.dex.code;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.code.SourcePosition;
-import com.android.dx.rop.type.Type;
 import com.android.dx.util.AnnotatedOutput;
 
 /**
index c866fec..63fcea9 100644 (file)
@@ -26,7 +26,6 @@ import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.BitSet;
 
 /**
index ab8343a..45764c7 100644 (file)
@@ -18,11 +18,10 @@ package com.android.dx.dex.code;
 
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecSet;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.FixedSizeList;
-
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
index a5e54a8..46f096b 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.code;
 
 import com.android.dx.dex.DexOptions;
-
 import java.util.ArrayList;
 
 /**
index c9387fa..2140eb6 100644 (file)
@@ -25,11 +25,11 @@ import com.android.dx.rop.code.RegisterSpecSet;
 import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstMemberRef;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 
-import com.android.dx.util.DexException;
+import com.android.dex.DexException;
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashSet;
index 0330113..fbfb0db 100644 (file)
@@ -18,16 +18,15 @@ package com.android.dx.dex.code;
 
 import com.android.dx.rop.code.Insn;
 import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.Rop;
 import com.android.dx.rop.code.Rops;
 import com.android.dx.rop.code.ThrowingCstInsn;
-import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstFieldRef;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
-
 import java.util.HashMap;
 
 /**
index 46ed811..d81fd4b 100644 (file)
@@ -39,7 +39,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstInteger;
 import com.android.dx.util.Bits;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 
 /**
index 1e7612e..afac946 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.HashSet;
 
index 479af6e..f83f331 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 82dda65..cb1fd0d 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.SimpleInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index aabab8a..b4d5b4a 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.dex.code.SimpleInsn;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 0335dc7..1c381d3 100644 (file)
@@ -26,7 +26,6 @@ import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 02cc0fd..ea51cb8 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 9264ec0..76f9824 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 8adb668..9d31dc5 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.TargetInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index e5a8b5d..006308b 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 5ffdb86..98cba4b 100644 (file)
@@ -24,7 +24,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 03d180a..a48c367 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 15ce0f8..f67608f 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.TargetInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 01eec0b..fedc911 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.SimpleInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 9164482..4e11ab8 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.SimpleInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 3295fda..9e082fa 100644 (file)
@@ -26,7 +26,6 @@ import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index b52341d..a059111 100644 (file)
@@ -23,7 +23,6 @@ import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 1999bba..77dc077 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.TargetInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index abed0e9..a653619 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.dex.code.InsnFormat;
 import com.android.dx.dex.code.SimpleInsn;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index b9c12c6..82b4631 100644 (file)
@@ -26,7 +26,6 @@ import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 4dc7bcd..2a31dea 100644 (file)
@@ -24,7 +24,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteral64;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.BitSet;
 
 /**
index 1d92247..e42f74c 100644 (file)
@@ -21,9 +21,8 @@ import com.android.dx.rop.annotation.AnnotationVisibility;
 import com.android.dx.rop.annotation.NameValuePair;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstString;
-import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.AnnotatedOutput;
-
+import com.android.dx.util.ByteArrayAnnotatedOutput;
 import java.util.Arrays;
 import java.util.Comparator;
 
index 2187700..1d00622 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.rop.annotation.Annotations;
 import com.android.dx.rop.annotation.Annotation;
+import com.android.dx.rop.annotation.Annotations;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
 
index 350ed9a..935c250 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.dx.dex.file;
 
 import com.android.dx.rop.annotation.Annotation;
+import static com.android.dx.rop.annotation.AnnotationVisibility.SYSTEM;
 import com.android.dx.rop.annotation.NameValuePair;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstAnnotation;
@@ -28,11 +29,8 @@ import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
-
 import java.util.ArrayList;
 
-import static com.android.dx.rop.annotation.AnnotationVisibility.*;
-
 /**
  * Utility class for dealing with annotations.
  */
index 972d4e6..b9e8204 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collections;
index 8b0f1bd..1e02452 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.dex.code.DalvCode;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.io.PrintWriter;
 import java.util.Map;
 import java.util.TreeMap;
index e9ae18b..c3bd0c1 100644 (file)
@@ -21,10 +21,9 @@ import com.android.dx.rop.cst.CstArray;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.Zeroes;
-import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.AnnotatedOutput;
+import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.Writers;
-
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.util.ArrayList;
index df3945a..0b4c92b 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.SizeOf;
+import com.android.dex.SizeOf;
 import com.android.dx.rop.annotation.Annotations;
 import com.android.dx.rop.annotation.AnnotationsList;
 import com.android.dx.rop.code.AccessFlags;
@@ -31,7 +31,6 @@ import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
 import com.android.dx.util.Writers;
-
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.util.ArrayList;
index 1ca391f..4db056b 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.TreeMap;
index a47f68a..9e3ae74 100644 (file)
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.code.CstInsn;
-import com.android.dx.dex.code.CatchTable;
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.dex.code.DalvCode;
-import com.android.dx.dex.code.DalvInsn;
 import com.android.dx.dex.code.DalvInsnList;
-import com.android.dx.dex.code.LocalList;
-import com.android.dx.dex.code.PositionList;
 import com.android.dx.rop.cst.Constant;
-import com.android.dx.rop.cst.CstMemberRef;
 import com.android.dx.rop.cst.CstMethodRef;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
-
 import java.io.PrintWriter;
-import java.util.HashSet;
 
 /**
  * Representation of all the parts needed for concrete methods in a
index 9fb4845..203b0f8 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.util.ByteArrayByteInput;
+import com.android.dex.util.ByteInput;
+import com.android.dex.util.ExceptionWithContext;
+import com.android.dex.Leb128;
 import com.android.dx.dex.code.DalvCode;
 import com.android.dx.dex.code.DalvInsnList;
 import com.android.dx.dex.code.LocalList;
 import com.android.dx.dex.code.PositionList;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_ADVANCE_LINE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_ADVANCE_PC;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_END_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_END_SEQUENCE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_FIRST_SPECIAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_LINE_BASE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_LINE_RANGE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_RESTART_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_SET_EPILOGUE_BEGIN;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_SET_FILE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_SET_PROLOGUE_END;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_START_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_START_LOCAL_EXTENDED;
 import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
-import com.android.dx.util.ByteArrayByteInput;
-import com.android.dx.util.ByteInput;
-import com.android.dx.util.ExceptionWithContext;
-
-import com.android.dx.util.Leb128Utils;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.android.dx.dex.file.DebugInfoConstants.*;
-
 /**
  * A decoder for the dex debug info state machine format.
  * This code exists mostly as a reference implementation and test for
@@ -219,7 +229,7 @@ public class DebugInfoDecoder {
      * @throws IOException
      */
     private int readStringIndex(ByteInput bs) throws IOException {
-        int offsetIndex = Leb128Utils.readUnsignedLeb128(bs);
+        int offsetIndex = Leb128.readUnsignedLeb128(bs);
 
         return offsetIndex - 1;
     }
@@ -239,8 +249,8 @@ public class DebugInfoDecoder {
     private void decode0() throws IOException {
         ByteInput bs = new ByteArrayByteInput(encoded);
 
-        line = Leb128Utils.readUnsignedLeb128(bs);
-        int szParams = Leb128Utils.readUnsignedLeb128(bs);
+        line = Leb128.readUnsignedLeb128(bs);
+        int szParams = Leb128.readUnsignedLeb128(bs);
         StdTypeList params = desc.getParameterTypes();
         int curReg = getParamBase();
 
@@ -285,7 +295,7 @@ public class DebugInfoDecoder {
 
             switch (opcode) {
                 case DBG_START_LOCAL: {
-                    int reg = Leb128Utils.readUnsignedLeb128(bs);
+                    int reg = Leb128.readUnsignedLeb128(bs);
                     int nameIdx = readStringIndex(bs);
                     int typeIdx = readStringIndex(bs);
                     LocalEntry le = new LocalEntry(
@@ -297,7 +307,7 @@ public class DebugInfoDecoder {
                 break;
 
                 case DBG_START_LOCAL_EXTENDED: {
-                    int reg = Leb128Utils.readUnsignedLeb128(bs);
+                    int reg = Leb128.readUnsignedLeb128(bs);
                     int nameIdx = readStringIndex(bs);
                     int typeIdx = readStringIndex(bs);
                     int sigIdx = readStringIndex(bs);
@@ -310,7 +320,7 @@ public class DebugInfoDecoder {
                 break;
 
                 case DBG_RESTART_LOCAL: {
-                    int reg = Leb128Utils.readUnsignedLeb128(bs);
+                    int reg = Leb128.readUnsignedLeb128(bs);
                     LocalEntry prevle;
                     LocalEntry le;
 
@@ -336,7 +346,7 @@ public class DebugInfoDecoder {
                 break;
 
                 case DBG_END_LOCAL: {
-                    int reg = Leb128Utils.readUnsignedLeb128(bs);
+                    int reg = Leb128.readUnsignedLeb128(bs);
                     LocalEntry prevle;
                     LocalEntry le;
 
@@ -366,11 +376,11 @@ public class DebugInfoDecoder {
                 return;
 
                 case DBG_ADVANCE_PC:
-                    address += Leb128Utils.readUnsignedLeb128(bs);
+                    address += Leb128.readUnsignedLeb128(bs);
                 break;
 
                 case DBG_ADVANCE_LINE:
-                    line += Leb128Utils.readSignedLeb128(bs);
+                    line += Leb128.readSignedLeb128(bs);
                 break;
 
                 case DBG_SET_PROLOGUE_END:
index ae87fc3..9f57b6b 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.dex.code.LocalList;
 import com.android.dx.dex.code.PositionList;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_ADVANCE_LINE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_ADVANCE_PC;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_END_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_END_SEQUENCE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_FIRST_SPECIAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_LINE_BASE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_LINE_RANGE;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_RESTART_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_SET_PROLOGUE_END;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_START_LOCAL;
+import static com.android.dx.dex.file.DebugInfoConstants.DBG_START_LOCAL_EXTENDED;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.rop.cst.CstMethodRef;
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
-import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
-
+import com.android.dx.util.ByteArrayAnnotatedOutput;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.BitSet;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.BitSet;
-
-import static com.android.dx.dex.file.DebugInfoConstants.*;
 
 /**
  * An encoder for the dex debug info state machine format. The format
index 09b2712..2fd864a 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.dex.code.DalvCode;
 import com.android.dx.dex.code.DalvInsnList;
 import com.android.dx.dex.code.LocalList;
 import com.android.dx.dex.code.PositionList;
 import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
-
 import java.io.PrintWriter;
 
 public class DebugInfoItem extends OffsettedItem {
index 6a9882c..0d5b110 100644 (file)
@@ -16,8 +16,9 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.DexFormat;
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.dex.DexOptions;
+import static com.android.dx.dex.file.MixedItemSection.SortType;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstBaseMethodRef;
 import com.android.dx.rop.cst.CstEnumRef;
@@ -26,8 +27,6 @@ import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.ByteArrayAnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
@@ -36,8 +35,6 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.zip.Adler32;
 
-import static com.android.dx.dex.file.MixedItemSection.SortType;
-
 /**
  * Representation of an entire {@code .dex} (Dalvik EXecutable)
  * file, which itself consists of a set of Dalvik classes.
index 3d05ab3..12d4b17 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.dx.dex.file;
 
 import com.android.dx.rop.cst.CstArray;
-import com.android.dx.util.ByteArrayAnnotatedOutput;
 import com.android.dx.util.AnnotatedOutput;
+import com.android.dx.util.ByteArrayAnnotatedOutput;
 
 /**
  * Encoded array of constant values.
index fdfa5d2..317c979 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.Leb128;
 import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-import com.android.dx.util.Leb128Utils;
-
 import java.io.PrintWriter;
 
 /**
@@ -139,9 +138,9 @@ public final class EncodedField extends EncodedMember
         if (out.annotates()) {
             out.annotate(0, String.format("  [%x] %s", dumpSeq,
                             field.toHuman()));
-            out.annotate(Leb128Utils.unsignedLeb128Size(diff),
+            out.annotate(Leb128.unsignedLeb128Size(diff),
                     "    field_idx:    " + Hex.u4(fieldIdx));
-            out.annotate(Leb128Utils.unsignedLeb128Size(accessFlags),
+            out.annotate(Leb128.unsignedLeb128Size(accessFlags),
                     "    access_flags: " +
                     AccessFlags.fieldString(accessFlags));
         }
index 6277646..a681d82 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.dex.file;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.ToHuman;
-
 import java.io.PrintWriter;
 
 /**
index c3f71b7..0a177e6 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.dx.dex.file;
 
+import com.android.dex.Leb128;
 import com.android.dx.dex.code.DalvCode;
 import com.android.dx.rop.code.AccessFlags;
 import com.android.dx.rop.cst.CstMethodRef;
@@ -23,8 +24,6 @@ import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-import com.android.dx.util.Leb128Utils;
-
 import java.io.PrintWriter;
 
 /**
@@ -178,12 +177,12 @@ public final class EncodedMethod extends EncodedMember
         if (out.annotates()) {
             out.annotate(0, String.format("  [%x] %s", dumpSeq,
                             method.toHuman()));
-            out.annotate(Leb128Utils.unsignedLeb128Size(diff),
+            out.annotate(Leb128.unsignedLeb128Size(diff),
                     "    method_idx:   " + Hex.u4(methodIdx));
-            out.annotate(Leb128Utils.unsignedLeb128Size(accessFlags),
+            out.annotate(Leb128.unsignedLeb128Size(accessFlags),
                     "    access_flags: " +
                     AccessFlags.methodString(accessFlags));
-            out.annotate(Leb128Utils.unsignedLeb128Size(codeOff),
+            out.annotate(Leb128.unsignedLeb128Size(codeOff),
                     "    code_off:     " + Hex.u4(codeOff));
         }
 
index c320731..27d946d 100644 (file)
@@ -20,7 +20,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstFieldRef;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.Collection;
 import java.util.TreeMap;
 
index 3816eb8..f404c3e 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.DexFormat;
-import com.android.dx.dex.SizeOf;
+import com.android.dex.DexFormat;
+import com.android.dex.SizeOf;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
index 21da488..e3de356 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.file;
 
 import com.android.dx.rop.cst.Constant;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
index d78dc91..f68cd94 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.dex.file;
 
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.ArrayList;
 
 /**
index 08a3123..ffe4c6c 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.SizeOf;
 import com.android.dx.rop.cst.CstMemberRef;
 import com.android.dx.rop.cst.CstNat;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-import com.android.dx.dex.SizeOf;
 
 /**
  * Representation of a member (field or method) reference inside a
index ee844d9..9f82f41 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.util.DexException;
+import com.android.dex.DexException;
 import java.util.Formatter;
 import java.util.Map;
 import java.util.TreeMap;
index fa0cd3c..d99198b 100644 (file)
@@ -20,7 +20,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstBaseMethodRef;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.Collection;
 import java.util.TreeMap;
 
index b885306..4edc6b6 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
index 7721470..02787f9 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.dex.file;
 
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.ExceptionWithContext;
 
 /**
  * An item in a Dalvik file which is referenced by absolute offset.
index 078c219..1fc4365 100644 (file)
@@ -22,7 +22,6 @@ import com.android.dx.rop.cst.CstMethodRef;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
 import com.android.dx.util.ToHuman;
-
 import java.util.ArrayList;
 
 /**
index 235a8c8..19eb3d2 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.SizeOf;
+import com.android.dex.SizeOf;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.rop.type.StdTypeList;
index dc6e8ad..4b1303b 100644 (file)
@@ -20,7 +20,6 @@ import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.type.Prototype;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.Collection;
 import java.util.TreeMap;
 
index 3f04216..bde714c 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.file;
 
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.Collection;
 
 /**
index 62e1832..42f5b49 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.dex.file;
 
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.TreeMap;
index e85a823..38be344 100644 (file)
 
 package com.android.dx.dex.file;
 
+import com.android.dex.Leb128;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.ByteArray;
 import com.android.dx.util.Hex;
-import com.android.dx.util.Leb128Utils;
 
 /**
  * Representation of string data for a particular string, in a Dalvik file.
@@ -50,7 +50,7 @@ public final class StringDataItem extends OffsettedItem {
         int utf16Size = value.getUtf16Size();
 
         // The +1 is for the '\0' termination byte.
-        return Leb128Utils.unsignedLeb128Size(utf16Size)
+        return Leb128.unsignedLeb128Size(utf16Size)
             + value.getUtf8Size() + 1;
     }
 
@@ -73,7 +73,7 @@ public final class StringDataItem extends OffsettedItem {
         int utf16Size = value.getUtf16Size();
 
         if (out.annotates()) {
-            out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size),
+            out.annotate(Leb128.unsignedLeb128Size(utf16Size),
                     "utf16_size: " + Hex.u4(utf16Size));
             out.annotate(bytes.size() + 1, value.toQuoted());
         }
index 533427d..b3e7d02 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.SizeOf;
+import com.android.dex.SizeOf;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
index 2f7c40b..7aff82e 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.rop.cst.CstNat;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.Collection;
 import java.util.TreeMap;
 
index 04be2a1..e585f1f 100644 (file)
@@ -16,9 +16,9 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.dex.SizeOf;
-import com.android.dx.rop.cst.CstType;
+import com.android.dex.SizeOf;
 import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
 
index bcc8250..1df4b46 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
 import java.util.Collection;
 import java.util.TreeMap;
 
index b815dd3..1f9b6a8 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.dex.file;
 
-import com.android.dx.rop.cst.CstType;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
index d8c09ab..ade268f 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.dex.file;
 
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.util.AnnotatedOutput;
-
 import java.util.Collection;
 
 /**
index 88919c7..0196ca1 100644 (file)
@@ -18,8 +18,6 @@ package com.android.dx.dex.file;
 
 import com.android.dx.util.AnnotatedOutput;
 import com.android.dx.util.Hex;
-
-import java.util.HashMap;
 import java.util.List;
 
 /**
index aafb429..fa807a7 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.dx.dex.file;
 
+import com.android.dex.EncodedValueCodec;
 import com.android.dx.rop.annotation.Annotation;
 import com.android.dx.rop.annotation.NameValuePair;
 import com.android.dx.rop.cst.Constant;
@@ -37,7 +38,6 @@ import com.android.dx.rop.cst.CstShort;
 import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.AnnotatedOutput;
-import com.android.dx.util.EncodedValueUtils;
 import com.android.dx.util.Hex;
 import java.util.Collection;
 
@@ -134,49 +134,49 @@ public final class ValueEncoder {
             case VALUE_INT:
             case VALUE_LONG: {
                 long value = ((CstLiteralBits) cst).getLongBits();
-                EncodedValueUtils.writeSignedIntegralValue(out, type, value);
+                EncodedValueCodec.writeSignedIntegralValue(out, type, value);
                 break;
             }
             case VALUE_CHAR: {
                 long value = ((CstLiteralBits) cst).getLongBits();
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, value);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, value);
                 break;
             }
             case VALUE_FLOAT: {
                 // Shift value left 32 so that right-zero-extension works.
                 long value = ((CstFloat) cst).getLongBits() << 32;
-                EncodedValueUtils.writeRightZeroExtendedValue(out, type, value);
+                EncodedValueCodec.writeRightZeroExtendedValue(out, type, value);
                 break;
             }
             case VALUE_DOUBLE: {
                 long value = ((CstDouble) cst).getLongBits();
-                EncodedValueUtils.writeRightZeroExtendedValue(out, type, value);
+                EncodedValueCodec.writeRightZeroExtendedValue(out, type, value);
                 break;
             }
             case VALUE_STRING: {
                 int index = file.getStringIds().indexOf((CstString) cst);
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, (long) index);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, (long) index);
                 break;
             }
             case VALUE_TYPE: {
                 int index = file.getTypeIds().indexOf((CstType) cst);
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, (long) index);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, (long) index);
                 break;
             }
             case VALUE_FIELD: {
                 int index = file.getFieldIds().indexOf((CstFieldRef) cst);
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, (long) index);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, (long) index);
                 break;
             }
             case VALUE_METHOD: {
                 int index = file.getMethodIds().indexOf((CstMethodRef) cst);
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, (long) index);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, (long) index);
                 break;
             }
             case VALUE_ENUM: {
                 CstFieldRef fieldRef = ((CstEnumRef) cst).getFieldRef();
                 int index = file.getFieldIds().indexOf(fieldRef);
-                EncodedValueUtils.writeUnsignedIntegralValue(out, type, (long) index);
+                EncodedValueCodec.writeUnsignedIntegralValue(out, type, (long) index);
                 break;
             }
             case VALUE_ARRAY: {
index cab1063..5fd5cf6 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.io;
 
+import com.android.dex.DexException;
 import com.android.dx.io.instructions.DecodedInstruction;
-import com.android.dx.util.DexException;
 
 /**
  * Walks through a block of code and calls visitor call backs.
index 416b3e2..4259259 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.dx.io;
 
+import com.android.dex.Dex;
 import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -35,7 +36,7 @@ public final class DexHasher {
      * first 32 bytes of dex files are not specified to be included in the
      * signature.
      */
-    public byte[] computeSignature(DexBuffer dex) throws IOException {
+    public byte[] computeSignature(Dex dex) throws IOException {
         MessageDigest digest;
         try {
             digest = MessageDigest.getInstance("SHA-1");
@@ -52,7 +53,7 @@ public final class DexHasher {
     /**
      * Returns the checksum of all but the first 12 bytes of {@code dex}.
      */
-    public int computeChecksum(DexBuffer dex) throws IOException {
+    public int computeChecksum(Dex dex) throws IOException {
         Adler32 adler32 = new Adler32();
         int offset = CHECKSUM_OFFSET + CHECKSUM_SIZE;
 
@@ -65,7 +66,7 @@ public final class DexHasher {
      * Generates the signature and checksum of the dex file {@code out} and
      * writes them to the file.
      */
-    public void writeHashes(DexBuffer dex) throws IOException {
+    public void writeHashes(Dex dex) throws IOException {
         byte[] signature = computeSignature(dex);
         dex.open(SIGNATURE_OFFSET).write(signature);
 
index 85c2015..2b89d44 100644 (file)
 
 package com.android.dx.io;
 
-import com.android.dx.dex.TableOfContents;
+import com.android.dex.ClassDef;
+import com.android.dex.Dex;
+import com.android.dex.FieldId;
+import com.android.dex.MethodId;
+import com.android.dex.ProtoId;
+import com.android.dex.TableOfContents;
 import java.io.File;
 import java.io.IOException;
 
@@ -24,12 +29,12 @@ import java.io.IOException;
  * Executable that prints all indices of a dex file.
  */
 public final class DexIndexPrinter {
-    private final DexBuffer dexBuffer;
+    private final Dex dex;
     private final TableOfContents tableOfContents;
 
     public DexIndexPrinter(File file) throws IOException {
-        this.dexBuffer = new DexBuffer(file);
-        this.tableOfContents = dexBuffer.getTableOfContents();
+        this.dex = new Dex(file);
+        this.tableOfContents = dex.getTableOfContents();
     }
 
     private void printMap() {
@@ -45,7 +50,7 @@ public final class DexIndexPrinter {
 
     private void printStrings() throws IOException {
         int index = 0;
-        for (String string : dexBuffer.strings()) {
+        for (String string : dex.strings()) {
             System.out.println("string " + index + ": " + string);
             index++;
         }
@@ -53,15 +58,15 @@ public final class DexIndexPrinter {
 
     private void printTypeIds() throws IOException {
         int index = 0;
-        for (Integer type : dexBuffer.typeIds()) {
-            System.out.println("type " + index + ": " + dexBuffer.strings().get(type));
+        for (Integer type : dex.typeIds()) {
+            System.out.println("type " + index + ": " + dex.strings().get(type));
             index++;
         }
     }
 
     private void printProtoIds() throws IOException {
         int index = 0;
-        for (ProtoId protoId : dexBuffer.protoIds()) {
+        for (ProtoId protoId : dex.protoIds()) {
             System.out.println("proto " + index + ": " + protoId);
             index++;
         }
@@ -69,7 +74,7 @@ public final class DexIndexPrinter {
 
     private void printFieldIds() throws IOException {
         int index = 0;
-        for (FieldId fieldId : dexBuffer.fieldIds()) {
+        for (FieldId fieldId : dex.fieldIds()) {
             System.out.println("field " + index + ": " + fieldId);
             index++;
         }
@@ -77,7 +82,7 @@ public final class DexIndexPrinter {
 
     private void printMethodIds() throws IOException {
         int index = 0;
-        for (MethodId methodId : dexBuffer.methodIds()) {
+        for (MethodId methodId : dex.methodIds()) {
             System.out.println("methodId " + index + ": " + methodId);
             index++;
         }
@@ -88,12 +93,12 @@ public final class DexIndexPrinter {
             System.out.println("No type lists");
             return;
         }
-        DexBuffer.Section in = dexBuffer.open(tableOfContents.typeLists.off);
+        Dex.Section in = dex.open(tableOfContents.typeLists.off);
         for (int i = 0; i < tableOfContents.typeLists.size; i++) {
             int size = in.readInt();
             System.out.print("Type list i=" + i + ", size=" + size + ", elements=");
             for (int t = 0; t < size; t++) {
-                System.out.print(" " + dexBuffer.typeNames().get((int) in.readShort()));
+                System.out.print(" " + dex.typeNames().get((int) in.readShort()));
             }
             if (size % 2 == 1) {
                 in.readShort(); // retain alignment
@@ -104,7 +109,7 @@ public final class DexIndexPrinter {
 
     private void printClassDefs() {
         int index = 0;
-        for (ClassDef classDef : dexBuffer.classDefs()) {
+        for (ClassDef classDef : dex.classDefs()) {
             System.out.println("class def " + index + ": " + classDef);
             index++;
         }
index a8dbe0b..953bdc9 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.io.instructions;
 
-import java.io.EOFException;
 import java.util.HashMap;
 
 /**
index 6915fa8..5cf1142 100644 (file)
@@ -16,8 +16,6 @@
 
 package com.android.dx.io.instructions;
 
-import java.io.EOFException;
-
 /**
  * Base implementation of {@link CodeCursor}.
  */
index a8bc859..e5b7073 100644 (file)
 
 package com.android.dx.io.instructions;
 
+import com.android.dex.DexException;
 import com.android.dx.io.IndexType;
 import com.android.dx.io.OpcodeInfo;
 import com.android.dx.io.Opcodes;
-import com.android.dx.util.DexException;
 import com.android.dx.util.Hex;
 import java.io.EOFException;
 
index 2e803ed..228352f 100644 (file)
 
 package com.android.dx.io.instructions;
 
+import com.android.dex.DexException;
 import com.android.dx.io.IndexType;
 import com.android.dx.io.OpcodeInfo;
 import com.android.dx.io.Opcodes;
-import com.android.dx.util.DexException;
 import com.android.dx.util.Hex;
-
 import java.io.EOFException;
 
 /**
index 319153f..329920e 100644 (file)
 
 package com.android.dx.merge;
 
-import com.android.dx.dex.SizeOf;
-import com.android.dx.dex.TableOfContents;
-import com.android.dx.io.Annotation;
-import com.android.dx.io.ClassData;
-import com.android.dx.io.ClassDef;
-import com.android.dx.io.Code;
-import com.android.dx.io.DexBuffer;
+import com.android.dex.Annotation;
+import com.android.dex.ClassData;
+import com.android.dex.ClassDef;
+import com.android.dex.Code;
+import com.android.dex.Dex;
+import com.android.dex.DexException;
+import com.android.dex.FieldId;
+import com.android.dex.MethodId;
+import com.android.dex.ProtoId;
+import com.android.dex.SizeOf;
+import com.android.dex.TableOfContents;
+import com.android.dex.TypeList;
 import com.android.dx.io.DexHasher;
-import com.android.dx.io.FieldId;
-import com.android.dx.io.MethodId;
-import com.android.dx.io.ProtoId;
-import com.android.dx.util.DexException;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -39,43 +40,43 @@ import java.util.List;
  * Combine two dex files into one.
  */
 public final class DexMerger {
-    private final DexBuffer dexA;
-    private final DexBuffer dexB;
+    private final Dex dexA;
+    private final Dex dexB;
     private final CollisionPolicy collisionPolicy;
     private final WriterSizes writerSizes;
 
-    private final DexBuffer dexOut = new DexBuffer();
+    private final Dex dexOut = new Dex();
 
-    private final DexBuffer.Section headerOut;
+    private final Dex.Section headerOut;
 
     /** All IDs and definitions sections */
-    private final DexBuffer.Section idsDefsOut;
+    private final Dex.Section idsDefsOut;
 
-    private final DexBuffer.Section mapListOut;
+    private final Dex.Section mapListOut;
 
-    private final DexBuffer.Section typeListOut;
+    private final Dex.Section typeListOut;
 
-    private final DexBuffer.Section classDataOut;
+    private final Dex.Section classDataOut;
 
-    private final DexBuffer.Section codeOut;
+    private final Dex.Section codeOut;
 
-    private final DexBuffer.Section stringDataOut;
+    private final Dex.Section stringDataOut;
 
-    private final DexBuffer.Section debugInfoOut;
+    private final Dex.Section debugInfoOut;
 
-    private final DexBuffer.Section encodedArrayOut;
+    private final Dex.Section encodedArrayOut;
 
     /** annotations directory on a type */
-    private final DexBuffer.Section annotationsDirectoryOut;
+    private final Dex.Section annotationsDirectoryOut;
 
     /** sets of annotations on a member, parameter or type */
-    private final DexBuffer.Section annotationSetOut;
+    private final Dex.Section annotationSetOut;
 
     /** parameter lists */
-    private final DexBuffer.Section annotationSetRefListOut;
+    private final Dex.Section annotationSetRefListOut;
 
     /** individual annotations, each containing zero or more fields */
-    private final DexBuffer.Section annotationOut;
+    private final Dex.Section annotationOut;
 
     private final TableOfContents contentsOut;
 
@@ -87,12 +88,12 @@ public final class DexMerger {
     /** minimum number of wasted bytes before it's worthwhile to compact the result */
     private int compactWasteThreshold = 1024 * 1024; // 1MiB
 
-    public DexMerger(DexBuffer dexA, DexBuffer dexB, CollisionPolicy collisionPolicy)
+    public DexMerger(Dex dexA, Dex dexB, CollisionPolicy collisionPolicy)
             throws IOException {
         this(dexA, dexB, collisionPolicy, new WriterSizes(dexA, dexB));
     }
 
-    private DexMerger(DexBuffer dexA, DexBuffer dexB, CollisionPolicy collisionPolicy,
+    private DexMerger(Dex dexA, Dex dexB, CollisionPolicy collisionPolicy,
             WriterSizes writerSizes) throws IOException {
         this.dexA = dexA;
         this.dexB = dexB;
@@ -156,7 +157,7 @@ public final class DexMerger {
         this.compactWasteThreshold = compactWasteThreshold;
     }
 
-    private DexBuffer mergeDexBuffers() throws IOException {
+    private Dex mergeDexes() throws IOException {
         mergeStringIds();
         mergeTypeIds();
         mergeTypeLists();
@@ -181,9 +182,9 @@ public final class DexMerger {
         return dexOut;
     }
 
-    public DexBuffer merge() throws IOException {
+    public Dex merge() throws IOException {
         long start = System.nanoTime();
-        DexBuffer result = mergeDexBuffers();
+        Dex result = mergeDexes();
 
         /*
          * We use pessimistic sizes when merging dex files. If those sizes
@@ -194,8 +195,8 @@ public final class DexMerger {
         int wastedByteCount = writerSizes.size() - compactedSizes.size();
         if (wastedByteCount >  + compactWasteThreshold) {
             DexMerger compacter = new DexMerger(
-                    dexOut, new DexBuffer(), CollisionPolicy.FAIL, compactedSizes);
-            result = compacter.mergeDexBuffers();
+                    dexOut, new Dex(), CollisionPolicy.FAIL, compactedSizes);
+            result = compacter.mergeDexes();
             System.out.printf("Result compacted from %.1fKiB to %.1fKiB to save %.1fKiB%n",
                     dexOut.getLength() / 1024f,
                     result.getLength() / 1024f,
@@ -221,9 +222,9 @@ public final class DexMerger {
      * merged dex file. Populates maps from old to new indices in the process.
      */
     abstract class IdMerger<T extends Comparable<T>> {
-        private final DexBuffer.Section out;
+        private final Dex.Section out;
 
-        protected IdMerger(DexBuffer.Section out) {
+        protected IdMerger(Dex.Section out) {
             this.out = out;
         }
 
@@ -236,8 +237,8 @@ public final class DexMerger {
             TableOfContents.Section bSection = getSection(dexB.getTableOfContents());
             getSection(contentsOut).off = out.getPosition();
 
-            DexBuffer.Section inA = aSection.exists() ? dexA.open(aSection.off) : null;
-            DexBuffer.Section inB = bSection.exists() ? dexB.open(bSection.off) : null;
+            Dex.Section inA = aSection.exists() ? dexA.open(aSection.off) : null;
+            Dex.Section inB = bSection.exists() ? dexB.open(bSection.off) : null;
             int aOffset = -1;
             int bOffset = -1;
             int aIndex = 0;
@@ -320,14 +321,14 @@ public final class DexMerger {
             getSection(contentsOut).size = outCount;
         }
 
-        private List<UnsortedValue> readUnsortedValues(DexBuffer source, IndexMap indexMap) {
+        private List<UnsortedValue> readUnsortedValues(Dex source, IndexMap indexMap) {
             TableOfContents.Section section = getSection(source.getTableOfContents());
             if (!section.exists()) {
                 return Collections.emptyList();
             }
 
             List<UnsortedValue> result = new ArrayList<UnsortedValue>();
-            DexBuffer.Section in = source.open(section.off);
+            Dex.Section in = source.open(section.off);
             for (int i = 0; i < section.size; i++) {
                 int offset = in.getPosition();
                 T value = read(in, indexMap, 0);
@@ -337,18 +338,18 @@ public final class DexMerger {
         }
 
         abstract TableOfContents.Section getSection(TableOfContents tableOfContents);
-        abstract T read(DexBuffer.Section in, IndexMap indexMap, int index);
+        abstract T read(Dex.Section in, IndexMap indexMap, int index);
         abstract void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex);
         abstract void write(T value);
 
         class UnsortedValue implements Comparable<UnsortedValue> {
-            final DexBuffer source;
+            final Dex source;
             final IndexMap indexMap;
             final T value;
             final int index;
             final int offset;
 
-            UnsortedValue(DexBuffer source, IndexMap indexMap, T value, int index, int offset) {
+            UnsortedValue(Dex source, IndexMap indexMap, T value, int index, int offset) {
                 this.source = source;
                 this.indexMap = indexMap;
                 this.value = value;
@@ -362,10 +363,10 @@ public final class DexMerger {
         }
     }
 
-    private IndexMap getIndexMap(DexBuffer dexBuffer) {
-        if (dexBuffer == dexA) {
+    private IndexMap getIndexMap(Dex dex) {
+        if (dex == dexA) {
             return aIndexMap;
-        } else if (dexBuffer == dexB) {
+        } else if (dex == dexB) {
             return bIndexMap;
         } else {
             throw new IllegalArgumentException();
@@ -378,7 +379,7 @@ public final class DexMerger {
                 return tableOfContents.stringIds;
             }
 
-            @Override String read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override String read(Dex.Section in, IndexMap indexMap, int index) {
                 return in.readString();
             }
 
@@ -400,7 +401,7 @@ public final class DexMerger {
                 return tableOfContents.typeIds;
             }
 
-            @Override Integer read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override Integer read(Dex.Section in, IndexMap indexMap, int index) {
                 int stringIndex = in.readInt();
                 return indexMap.adjustString(stringIndex);
             }
@@ -424,7 +425,7 @@ public final class DexMerger {
                 return tableOfContents.typeLists;
             }
 
-            @Override TypeList read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override TypeList read(Dex.Section in, IndexMap indexMap, int index) {
                 return indexMap.adjustTypeList(in.readTypeList());
             }
 
@@ -444,7 +445,7 @@ public final class DexMerger {
                 return tableOfContents.protoIds;
             }
 
-            @Override ProtoId read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override ProtoId read(Dex.Section in, IndexMap indexMap, int index) {
                 return indexMap.adjust(in.readProtoId());
             }
 
@@ -467,7 +468,7 @@ public final class DexMerger {
                 return tableOfContents.fieldIds;
             }
 
-            @Override FieldId read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override FieldId read(Dex.Section in, IndexMap indexMap, int index) {
                 return indexMap.adjust(in.readFieldId());
             }
 
@@ -490,7 +491,7 @@ public final class DexMerger {
                 return tableOfContents.methodIds;
             }
 
-            @Override MethodId read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override MethodId read(Dex.Section in, IndexMap indexMap, int index) {
                 return indexMap.adjust(in.readMethodId());
             }
 
@@ -513,7 +514,7 @@ public final class DexMerger {
                 return tableOfContents.annotations;
             }
 
-            @Override Annotation read(DexBuffer.Section in, IndexMap indexMap, int index) {
+            @Override Annotation read(Dex.Section in, IndexMap indexMap, int index) {
                 return indexMap.adjust(in.readAnnotation());
             }
 
@@ -533,7 +534,7 @@ public final class DexMerger {
         contentsOut.classDefs.size = types.length;
 
         for (SortableType type : types) {
-            DexBuffer in = type.getBuffer();
+            Dex in = type.getDex();
             IndexMap indexMap = (in == dexA) ? aIndexMap : bIndexMap;
             transformClassDef(in, type.getClassDef(), indexMap);
         }
@@ -581,7 +582,7 @@ public final class DexMerger {
      * Reads just enough data on each class so that we can sort it and then find
      * it later.
      */
-    private void readSortableTypes(SortableType[] sortableTypes, DexBuffer buffer,
+    private void readSortableTypes(SortableType[] sortableTypes, Dex buffer,
             IndexMap indexMap) {
         for (ClassDef classDef : buffer.classDefs()) {
             SortableType sortableType = indexMap.adjust(new SortableType(buffer, classDef));
@@ -612,40 +613,40 @@ public final class DexMerger {
         transformStaticValues(dexB, bIndexMap);
     }
 
-    private void transformAnnotationSets(DexBuffer in, IndexMap indexMap) {
+    private void transformAnnotationSets(Dex in, IndexMap indexMap) {
         TableOfContents.Section section = in.getTableOfContents().annotationSets;
         if (section.exists()) {
-            DexBuffer.Section setIn = in.open(section.off);
+            Dex.Section setIn = in.open(section.off);
             for (int i = 0; i < section.size; i++) {
                 transformAnnotationSet(indexMap, setIn);
             }
         }
     }
 
-    private void transformAnnotationSetRefLists(DexBuffer in, IndexMap indexMap) {
+    private void transformAnnotationSetRefLists(Dex in, IndexMap indexMap) {
         TableOfContents.Section section = in.getTableOfContents().annotationSetRefLists;
         if (section.exists()) {
-            DexBuffer.Section setIn = in.open(section.off);
+            Dex.Section setIn = in.open(section.off);
             for (int i = 0; i < section.size; i++) {
                 transformAnnotationSetRefList(indexMap, setIn);
             }
         }
     }
 
-    private void transformAnnotationDirectories(DexBuffer in, IndexMap indexMap) {
+    private void transformAnnotationDirectories(Dex in, IndexMap indexMap) {
         TableOfContents.Section section = in.getTableOfContents().annotationsDirectories;
         if (section.exists()) {
-            DexBuffer.Section directoryIn = in.open(section.off);
+            Dex.Section directoryIn = in.open(section.off);
             for (int i = 0; i < section.size; i++) {
                 transformAnnotationDirectory(directoryIn, indexMap);
             }
         }
     }
 
-    private void transformStaticValues(DexBuffer in, IndexMap indexMap) {
+    private void transformStaticValues(Dex in, IndexMap indexMap) {
         TableOfContents.Section section = in.getTableOfContents().encodedArrays;
         if (section.exists()) {
-            DexBuffer.Section staticValuesIn = in.open(section.off);
+            Dex.Section staticValuesIn = in.open(section.off);
             for (int i = 0; i < section.size; i++) {
                 transformStaticValues(staticValuesIn, indexMap);
             }
@@ -656,7 +657,7 @@ public final class DexMerger {
      * Reads a class_def_item beginning at {@code in} and writes the index and
      * data.
      */
-    private void transformClassDef(DexBuffer in, ClassDef classDef, IndexMap indexMap) {
+    private void transformClassDef(Dex in, ClassDef classDef, IndexMap indexMap) {
         idsDefsOut.assertFourByteAligned();
         idsDefsOut.writeInt(classDef.getTypeIndex());
         idsDefsOut.writeInt(classDef.getAccessFlags());
@@ -686,7 +687,7 @@ public final class DexMerger {
      * Transform all annotations on a class.
      */
     private void transformAnnotationDirectory(
-            DexBuffer.Section directoryIn, IndexMap indexMap) {
+            Dex.Section directoryIn, IndexMap indexMap) {
         contentsOut.annotationsDirectories.size++;
         annotationsDirectoryOut.assertFourByteAligned();
         indexMap.putAnnotationDirectoryOffset(
@@ -734,7 +735,7 @@ public final class DexMerger {
     /**
      * Transform all annotations on a single type, member or parameter.
      */
-    private void transformAnnotationSet(IndexMap indexMap, DexBuffer.Section setIn) {
+    private void transformAnnotationSet(IndexMap indexMap, Dex.Section setIn) {
         contentsOut.annotationSets.size++;
         annotationSetOut.assertFourByteAligned();
         indexMap.putAnnotationSetOffset(setIn.getPosition(), annotationSetOut.getPosition());
@@ -750,7 +751,7 @@ public final class DexMerger {
     /**
      * Transform all annotation set ref lists.
      */
-    private void transformAnnotationSetRefList(IndexMap indexMap, DexBuffer.Section refListIn) {
+    private void transformAnnotationSetRefList(IndexMap indexMap, Dex.Section refListIn) {
         contentsOut.annotationSetRefLists.size++;
         annotationSetRefListOut.assertFourByteAligned();
         indexMap.putAnnotationSetRefListOffset(
@@ -763,7 +764,7 @@ public final class DexMerger {
         }
     }
 
-    private void transformClassData(DexBuffer in, ClassData classData, IndexMap indexMap) {
+    private void transformClassData(Dex in, ClassData classData, IndexMap indexMap) {
         contentsOut.classDatas.size++;
 
         ClassData.Field[] staticFields = classData.getStaticFields();
@@ -792,7 +793,7 @@ public final class DexMerger {
         }
     }
 
-    private void transformMethods(DexBuffer in, IndexMap indexMap, ClassData.Method[] methods) {
+    private void transformMethods(Dex in, IndexMap indexMap, ClassData.Method[] methods) {
         int lastOutMethodIndex = 0;
         for (ClassData.Method method : methods) {
             int outMethodIndex = indexMap.adjustMethod(method.getMethodIndex());
@@ -811,7 +812,7 @@ public final class DexMerger {
         }
     }
 
-    private void transformCode(DexBuffer in, Code code, IndexMap indexMap) {
+    private void transformCode(Dex in, Code code, IndexMap indexMap) {
         contentsOut.codes.size++;
         codeOut.assertFourByteAligned();
 
@@ -849,7 +850,7 @@ public final class DexMerger {
              * Unfortunately they're in the opposite order in the dex file so we
              * need to transform them out-of-order.
              */
-            DexBuffer.Section triesSection = dexOut.open(codeOut.getPosition());
+            Dex.Section triesSection = dexOut.open(codeOut.getPosition());
             codeOut.skip(tries.length * SizeOf.TRY_ITEM);
             int[] offsets = transformCatchHandlers(indexMap, catchHandlers);
             transformTries(triesSection, tries, offsets);
@@ -870,7 +871,7 @@ public final class DexMerger {
         return offsets;
     }
 
-    private void transformTries(DexBuffer.Section out, Code.Try[] tries,
+    private void transformTries(Dex.Section out, Code.Try[] tries,
             int[] catchHandlerOffsets) {
         for (Code.Try tryItem : tries) {
             out.writeInt(tryItem.getStartAddress());
@@ -890,7 +891,7 @@ public final class DexMerger {
     private static final byte DBG_SET_EPILOGUE_BEGIN = 0x08;
     private static final byte DBG_SET_FILE = 0x09;
 
-    private void transformDebugInfoItem(DexBuffer.Section in, IndexMap indexMap) {
+    private void transformDebugInfoItem(Dex.Section in, IndexMap indexMap) {
         contentsOut.debugInfos.size++;
         int lineStart = in.readUleb128();
         debugInfoOut.writeUleb128(lineStart);
@@ -982,7 +983,7 @@ public final class DexMerger {
         }
     }
 
-    private void transformStaticValues(DexBuffer.Section in, IndexMap indexMap) {
+    private void transformStaticValues(Dex.Section in, IndexMap indexMap) {
         contentsOut.encodedArrays.size++;
         indexMap.putStaticValuesOffset(in.getPosition(), encodedArrayOut.getPosition());
         indexMap.adjustEncodedArray(in.readEncodedArray()).writeTo(encodedArrayOut);
@@ -1017,7 +1018,7 @@ public final class DexMerger {
         /**
          * Compute sizes for merging a and b.
          */
-        public WriterSizes(DexBuffer a, DexBuffer b) {
+        public WriterSizes(Dex a, Dex b) {
             plus(a.getTableOfContents(), false);
             plus(b.getTableOfContents(), false);
         }
@@ -1071,8 +1072,8 @@ public final class DexMerger {
                 debugInfo += contents.debugInfos.byteCount * 2;
             }
 
-            typeList = DexBuffer.fourByteAlign(typeList);
-            code = DexBuffer.fourByteAlign(code);
+            typeList = Dex.fourByteAlign(typeList);
+            code = Dex.fourByteAlign(code);
         }
 
         public int size() {
@@ -1088,9 +1089,9 @@ public final class DexMerger {
             return;
         }
 
-        DexBuffer dexA = new DexBuffer(new File(args[1]));
-        DexBuffer dexB = new DexBuffer(new File(args[2]));
-        DexBuffer merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
+        Dex dexA = new Dex(new File(args[1]));
+        Dex dexB = new Dex(new File(args[2]));
+        Dex merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
         merged.writeTo(new File(args[0]));
     }
 
index 9d6ef7a..739238a 100644 (file)
 
 package com.android.dx.merge;
 
-import com.android.dx.dex.TableOfContents;
-import com.android.dx.io.Annotation;
-import com.android.dx.io.ClassDef;
-import com.android.dx.io.DexBuffer;
-import com.android.dx.io.EncodedValue;
-import com.android.dx.io.EncodedValueReader;
-import static com.android.dx.io.EncodedValueReader.ENCODED_ANNOTATION;
-import static com.android.dx.io.EncodedValueReader.ENCODED_ARRAY;
-import static com.android.dx.io.EncodedValueReader.ENCODED_BOOLEAN;
-import static com.android.dx.io.EncodedValueReader.ENCODED_BYTE;
-import static com.android.dx.io.EncodedValueReader.ENCODED_CHAR;
-import static com.android.dx.io.EncodedValueReader.ENCODED_DOUBLE;
-import static com.android.dx.io.EncodedValueReader.ENCODED_ENUM;
-import static com.android.dx.io.EncodedValueReader.ENCODED_FIELD;
-import static com.android.dx.io.EncodedValueReader.ENCODED_FLOAT;
-import static com.android.dx.io.EncodedValueReader.ENCODED_INT;
-import static com.android.dx.io.EncodedValueReader.ENCODED_LONG;
-import static com.android.dx.io.EncodedValueReader.ENCODED_METHOD;
-import static com.android.dx.io.EncodedValueReader.ENCODED_NULL;
-import static com.android.dx.io.EncodedValueReader.ENCODED_SHORT;
-import static com.android.dx.io.EncodedValueReader.ENCODED_STRING;
-import static com.android.dx.io.EncodedValueReader.ENCODED_TYPE;
-import com.android.dx.io.FieldId;
-import com.android.dx.io.MethodId;
-import com.android.dx.io.ProtoId;
+import com.android.dex.Annotation;
+import com.android.dex.util.ByteOutput;
+import com.android.dex.ClassDef;
+import com.android.dex.Dex;
+import com.android.dex.DexException;
+import com.android.dex.EncodedValue;
+import com.android.dex.EncodedValueReader;
+import static com.android.dex.EncodedValueReader.ENCODED_ANNOTATION;
+import static com.android.dex.EncodedValueReader.ENCODED_ARRAY;
+import static com.android.dex.EncodedValueReader.ENCODED_BOOLEAN;
+import static com.android.dex.EncodedValueReader.ENCODED_BYTE;
+import static com.android.dex.EncodedValueReader.ENCODED_CHAR;
+import static com.android.dex.EncodedValueReader.ENCODED_DOUBLE;
+import static com.android.dex.EncodedValueReader.ENCODED_ENUM;
+import static com.android.dex.EncodedValueReader.ENCODED_FIELD;
+import static com.android.dex.EncodedValueReader.ENCODED_FLOAT;
+import static com.android.dex.EncodedValueReader.ENCODED_INT;
+import static com.android.dex.EncodedValueReader.ENCODED_LONG;
+import static com.android.dex.EncodedValueReader.ENCODED_METHOD;
+import static com.android.dex.EncodedValueReader.ENCODED_NULL;
+import static com.android.dex.EncodedValueReader.ENCODED_SHORT;
+import static com.android.dex.EncodedValueReader.ENCODED_STRING;
+import static com.android.dex.EncodedValueReader.ENCODED_TYPE;
+import com.android.dex.EncodedValueCodec;
+import com.android.dex.FieldId;
+import com.android.dex.Leb128;
+import com.android.dex.MethodId;
+import com.android.dex.ProtoId;
+import com.android.dex.TableOfContents;
+import com.android.dex.TypeList;
 import com.android.dx.util.ByteArrayAnnotatedOutput;
-import com.android.dx.util.ByteOutput;
-import com.android.dx.util.DexException;
-import com.android.dx.util.EncodedValueUtils;
-import com.android.dx.util.Leb128Utils;
 import java.util.HashMap;
 
 /**
@@ -54,7 +55,7 @@ import java.util.HashMap;
  * {@code strings[5]}.
  */
 public final class IndexMap {
-    private final DexBuffer target;
+    private final Dex target;
     public final int[] stringIds;
     public final short[] typeIds;
     public final short[] protoIds;
@@ -67,7 +68,7 @@ public final class IndexMap {
     private final HashMap<Integer, Integer> annotationDirectoryOffsets;
     private final HashMap<Integer, Integer> staticValuesOffsets;
 
-    public IndexMap(DexBuffer target, TableOfContents tableOfContents) {
+    public IndexMap(Dex target, TableOfContents tableOfContents) {
         this.target = target;
         this.stringIds = new int[tableOfContents.stringIds.size];
         this.typeIds = new short[tableOfContents.typeIds.size];
@@ -219,7 +220,7 @@ public final class IndexMap {
     }
 
     public SortableType adjust(SortableType sortableType) {
-        return new SortableType(sortableType.getBuffer(), adjust(sortableType.getClassDef()));
+        return new SortableType(sortableType.getDex(), adjust(sortableType.getClassDef()));
     }
 
     public EncodedValue adjustEncodedValue(EncodedValue encodedValue) {
@@ -257,47 +258,47 @@ public final class IndexMap {
             // TODO: extract this into a helper class, EncodedValueWriter
             switch (reader.peek()) {
             case ENCODED_BYTE:
-                EncodedValueUtils.writeSignedIntegralValue(out, ENCODED_BYTE, reader.readByte());
+                EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_BYTE, reader.readByte());
                 break;
             case ENCODED_SHORT:
-                EncodedValueUtils.writeSignedIntegralValue(out, ENCODED_SHORT, reader.readShort());
+                EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_SHORT, reader.readShort());
                 break;
             case ENCODED_INT:
-                EncodedValueUtils.writeSignedIntegralValue(out, ENCODED_INT, reader.readInt());
+                EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_INT, reader.readInt());
                 break;
             case ENCODED_LONG:
-                EncodedValueUtils.writeSignedIntegralValue(out, ENCODED_LONG, reader.readLong());
+                EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_LONG, reader.readLong());
                 break;
             case ENCODED_CHAR:
-                EncodedValueUtils.writeUnsignedIntegralValue(out, ENCODED_CHAR, reader.readChar());
+                EncodedValueCodec.writeUnsignedIntegralValue(out, ENCODED_CHAR, reader.readChar());
                 break;
             case ENCODED_FLOAT:
                 // Shift value left 32 so that right-zero-extension works.
                 long longBits = ((long) Float.floatToIntBits(reader.readFloat())) << 32;
-                EncodedValueUtils.writeRightZeroExtendedValue(out, ENCODED_FLOAT, longBits);
+                EncodedValueCodec.writeRightZeroExtendedValue(out, ENCODED_FLOAT, longBits);
                 break;
             case ENCODED_DOUBLE:
-                EncodedValueUtils.writeRightZeroExtendedValue(
+                EncodedValueCodec.writeRightZeroExtendedValue(
                         out, ENCODED_DOUBLE, Double.doubleToLongBits(reader.readDouble()));
                 break;
             case ENCODED_STRING:
-                EncodedValueUtils.writeUnsignedIntegralValue(
+                EncodedValueCodec.writeUnsignedIntegralValue(
                         out, ENCODED_STRING, adjustString(reader.readString()));
                 break;
             case ENCODED_TYPE:
-                EncodedValueUtils.writeUnsignedIntegralValue(
+                EncodedValueCodec.writeUnsignedIntegralValue(
                         out, ENCODED_TYPE, adjustType(reader.readType()));
                 break;
             case ENCODED_FIELD:
-                EncodedValueUtils.writeUnsignedIntegralValue(
+                EncodedValueCodec.writeUnsignedIntegralValue(
                         out, ENCODED_FIELD, adjustField(reader.readField()));
                 break;
             case ENCODED_ENUM:
-                EncodedValueUtils.writeUnsignedIntegralValue(
+                EncodedValueCodec.writeUnsignedIntegralValue(
                         out, ENCODED_ENUM, adjustField(reader.readEnum()));
                 break;
             case ENCODED_METHOD:
-                EncodedValueUtils.writeUnsignedIntegralValue(
+                EncodedValueCodec.writeUnsignedIntegralValue(
                         out, ENCODED_METHOD, adjustMethod(reader.readMethod()));
                 break;
             case ENCODED_ARRAY:
@@ -323,17 +324,17 @@ public final class IndexMap {
 
         private void transformAnnotation(EncodedValueReader reader) {
             int fieldCount = reader.readAnnotation();
-            Leb128Utils.writeUnsignedLeb128(out, adjustType(reader.getAnnotationType()));
-            Leb128Utils.writeUnsignedLeb128(out, fieldCount);
+            Leb128.writeUnsignedLeb128(out, adjustType(reader.getAnnotationType()));
+            Leb128.writeUnsignedLeb128(out, fieldCount);
             for (int i = 0; i < fieldCount; i++) {
-                Leb128Utils.writeUnsignedLeb128(out, adjustString(reader.readAnnotationName()));
+                Leb128.writeUnsignedLeb128(out, adjustString(reader.readAnnotationName()));
                 transform(reader);
             }
         }
 
         private void transformArray(EncodedValueReader reader) {
             int size = reader.readArray();
-            Leb128Utils.writeUnsignedLeb128(out, size);
+            Leb128.writeUnsignedLeb128(out, size);
             for (int i = 0; i < size; i++) {
                 transform(reader);
             }
index 6051e17..aa67a88 100644 (file)
 
 package com.android.dx.merge;
 
+import com.android.dex.DexException;
 import com.android.dx.io.CodeReader;
 import com.android.dx.io.Opcodes;
 import com.android.dx.io.instructions.DecodedInstruction;
 import com.android.dx.io.instructions.ShortArrayCodeOutput;
-import com.android.dx.util.DexException;
 
 final class InstructionTransformer {
     private final IndexMap indexMap;
index 838ea28..2ae68fb 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.android.dx.merge;
 
-import com.android.dx.io.ClassDef;
-import com.android.dx.io.DexBuffer;
+import com.android.dex.ClassDef;
+import com.android.dex.Dex;
 import java.util.Comparator;
 
 /**
@@ -43,17 +43,17 @@ final class SortableType {
         }
     };
 
-    private final DexBuffer buffer;
+    private final Dex dex;
     private ClassDef classDef;
     private int depth = -1;
 
-    public SortableType(DexBuffer buffer, ClassDef classDef) {
-        this.buffer = buffer;
+    public SortableType(Dex dex, ClassDef classDef) {
+        this.dex = dex;
         this.classDef = classDef;
     }
 
-    public DexBuffer getBuffer() {
-        return buffer;
+    public Dex getDex() {
+        return dex;
     }
 
     public ClassDef getClassDef() {
index 8f9e976..e4af15d 100644 (file)
@@ -20,7 +20,6 @@ import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.MutabilityControl;
 import com.android.dx.util.ToHuman;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
index 807d5d4..aea4f24 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.rop.annotation;
 
 import com.android.dx.rop.cst.CstType;
 import com.android.dx.util.MutabilityControl;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
index ed9345d..248c2a6 100644 (file)
 package com.android.dx.rop.code;
 
 import com.android.dx.rop.cst.Constant;
+import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
-import com.android.dx.rop.type.StdTypeList;
-
 import java.util.ArrayList;
 
 /**
index 5d2b995..4376a2e 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.rop.code;
 
 import com.android.dx.rop.type.TypeBearer;
 import com.android.dx.util.MutabilityControl;
-
 import java.util.HashMap;
 
 /**
index 3b52efa..8c7d5d5 100644 (file)
 
 package com.android.dx.rop.code;
 
+import com.android.dx.rop.cst.Constant;
+import com.android.dx.rop.cst.CstInteger;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
-import com.android.dx.rop.type.TypeList;
 import com.android.dx.rop.type.TypeBearer;
-import com.android.dx.rop.cst.Constant;
-import com.android.dx.rop.cst.CstInteger;
+import com.android.dx.rop.type.TypeList;
 
 /**
  * Plain instruction, which has no embedded data and which cannot possibly
index e5f908b..cb02ea9 100644 (file)
@@ -21,7 +21,6 @@ import com.android.dx.rop.cst.CstString;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
 import com.android.dx.util.ToHuman;
-
 import java.util.HashMap;
 
 /**
index 3d891fd..7448d3d 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.rop.code;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeList;
 import com.android.dx.util.FixedSizeList;
-
 import java.util.BitSet;
 
 /**
index 591d325..f1643c1 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.rop.code;
 
-import com.android.dx.util.Bits;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
 
index 2766b5f..5644b2f 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.android.dx.rop.cst;
 
-import com.android.dx.rop.type.Type;
 import com.android.dx.util.FixedSizeList;
 
 /**
index 244395d..bb975e4 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.rop.cst;
 
-import com.android.dx.util.ExceptionWithContext;
+import com.android.dex.util.ExceptionWithContext;
 import com.android.dx.util.Hex;
 import com.android.dx.util.MutabilityControl;
 
index c564fab..4bf29ba 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.rop.type;
 
 import com.android.dx.util.Hex;
-
 import java.util.HashMap;
 
 /**
index 83045b2..45e93c3 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.dx.ssa;
 
 import com.android.dx.rop.code.RegisterSpec;
-import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.util.IntList;
 
 /**
index 07fb553..4a2f59d 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.RegOps;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
-import com.android.dx.rop.code.Rop;
-import com.android.dx.rop.code.PlainInsn;
-import com.android.dx.rop.code.Rops;
-import com.android.dx.rop.code.SourcePosition;
-import com.android.dx.rop.code.Insn;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashSet;
index 941a317..c3e65ac 100644 (file)
 package com.android.dx.ssa;
 
 import com.android.dx.util.IntSet;
-import com.android.dx.util.BitIntSet;
-import com.android.dx.util.ListIntSet;
-
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.BitSet;
 
 /**
index b02c929..8533de8 100644 (file)
@@ -39,7 +39,6 @@ import com.android.dx.rop.cst.Zeroes;
 import com.android.dx.rop.type.StdTypeList;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashSet;
index 851249b..446888d 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.ssa.back.InterferenceGraph;
-import com.android.dx.util.IntSet;
 import com.android.dx.util.BitIntSet;
-
+import com.android.dx.util.IntSet;
 import java.util.ArrayList;
-import java.util.BitSet;
 
 /**
  * A register mapper that keeps track of the accumulated interference
index f3976f2..ad017e2 100644 (file)
 
 package com.android.dx.ssa;
 
+import com.android.dx.rop.code.Insn;
 import com.android.dx.rop.code.PlainCstInsn;
-import com.android.dx.rop.code.TranslationAdvice;
+import com.android.dx.rop.code.PlainInsn;
+import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
-import com.android.dx.rop.code.Insn;
 import com.android.dx.rop.code.Rop;
-import com.android.dx.rop.code.RegisterSpec;
-import com.android.dx.rop.code.PlainInsn;
 import com.android.dx.rop.code.Rops;
-import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.TranslationAdvice;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstLiteralBits;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-
 import java.util.ArrayList;
 import java.util.List;
 
index 11d53cf..b86bed6 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.RegisterSpecSet;
 import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecSet;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.List;
index 8845270..1520531 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.util.MutabilityControl;
-import com.android.dx.rop.code.RegisterSpecSet;
 import com.android.dx.rop.code.RegisterSpec;
-
+import com.android.dx.rop.code.RegisterSpecSet;
+import com.android.dx.util.MutabilityControl;
 import java.util.HashMap;
 import java.util.List;
 
index 41660d2..fe3ac97 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.RegisterSpec;
-import com.android.dx.rop.code.RegOps;
 import com.android.dx.rop.code.CstInsn;
 import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.cst.CstInteger;
-
 import java.util.HashSet;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
index cfef400..61c12e5 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.*;
+import com.android.dx.rop.code.Insn;
+import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
+import com.android.dx.rop.code.Rop;
 
 /**
  * A "normal" (non-phi) instruction in SSA form. Always wraps a rop insn.
index 42ae166..8c2e284 100644 (file)
@@ -20,7 +20,6 @@ import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.TranslationAdvice;
 import com.android.dx.ssa.back.LivenessAnalyzer;
 import com.android.dx.ssa.back.SsaToRop;
-
 import java.util.EnumSet;
 
 /**
index bc9c4b0..0a39864 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.*;
+import com.android.dx.rop.code.Insn;
+import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
+import com.android.dx.rop.code.Rop;
+import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
 import com.android.dx.util.Hex;
-
 import java.util.ArrayList;
 import java.util.List;
 
index 4b8b4e3..1b2ce9f 100644 (file)
 package com.android.dx.ssa;
 
 import com.android.dx.cf.code.Merger;
+import com.android.dx.rop.code.LocalItem;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
-import com.android.dx.rop.code.LocalItem;
 import com.android.dx.rop.type.Type;
 import com.android.dx.rop.type.TypeBearer;
-
 import java.util.BitSet;
 import java.util.List;
 
index bef941f..3099000 100644 (file)
@@ -18,7 +18,6 @@ package com.android.dx.ssa;
 
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
-import com.android.dx.util.ToHuman;
 
 /**
  * Represents a mapping between two register numbering schemes.
index 1c869e1..a6dee34 100644 (file)
@@ -20,16 +20,15 @@ import com.android.dx.rop.code.CstInsn;
 import com.android.dx.rop.code.Insn;
 import com.android.dx.rop.code.PlainInsn;
 import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.code.Rop;
-import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.Rops;
 import com.android.dx.rop.cst.Constant;
 import com.android.dx.rop.cst.CstInteger;
 import com.android.dx.rop.cst.TypedConstant;
-import com.android.dx.rop.type.TypeBearer;
 import com.android.dx.rop.type.Type;
-
+import com.android.dx.rop.type.TypeBearer;
 import java.util.ArrayList;
 import java.util.BitSet;
 
index 499f59f..56d8c8c 100644 (file)
@@ -30,7 +30,6 @@ import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
 import com.android.dx.util.IntSet;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collections;
index 5cd8b6f..1fd6f78 100644 (file)
@@ -19,7 +19,6 @@ package com.android.dx.ssa;
 import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.rop.code.RopMethod;
 import com.android.dx.util.IntIterator;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 
index ca7a1a2..fb82f2d 100644 (file)
 
 package com.android.dx.ssa;
 
-import com.android.dx.rop.code.*;
+import com.android.dx.rop.code.Insn;
+import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
+import com.android.dx.rop.code.Rop;
 import com.android.dx.util.ToHuman;
 
 /**
index 4c2bd85..7d7b565 100644 (file)
@@ -27,7 +27,6 @@ import com.android.dx.rop.code.RopMethod;
 import com.android.dx.rop.code.Rops;
 import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collections;
index 58e4142..66391a0 100644 (file)
@@ -24,7 +24,6 @@ import com.android.dx.rop.code.Rops;
 import com.android.dx.rop.code.SourcePosition;
 import com.android.dx.rop.type.Type;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashMap;
index 6416e84..a9043c2 100644 (file)
@@ -18,15 +18,13 @@ package com.android.dx.ssa.back;
 
 import com.android.dx.rop.code.CstInsn;
 import com.android.dx.rop.cst.CstInteger;
-import com.android.dx.ssa.NormalSsaInsn;
 import com.android.dx.ssa.BasicRegisterMapper;
+import com.android.dx.ssa.NormalSsaInsn;
 import com.android.dx.ssa.RegisterMapper;
 import com.android.dx.ssa.SsaMethod;
-import com.android.dx.util.IntSet;
 import com.android.dx.util.BitIntSet;
-
+import com.android.dx.util.IntSet;
 import java.util.BitSet;
-import java.util.ArrayList;
 
 /**
  * Allocates registers via a naive n^2 register allocator.
index 9ef95a7..743955e 100644 (file)
 
 package com.android.dx.ssa.back;
 
-import com.android.dx.rop.code.*;
+import com.android.dx.rop.code.CstInsn;
+import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.code.RegOps;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.RegisterSpecList;
+import com.android.dx.rop.code.Rop;
 import com.android.dx.rop.cst.CstInteger;
 import com.android.dx.ssa.InterferenceRegisterMapper;
-import com.android.dx.ssa.RegisterMapper;
-import com.android.dx.ssa.SsaInsn;
-import com.android.dx.ssa.SsaMethod;
 import com.android.dx.ssa.NormalSsaInsn;
-import com.android.dx.ssa.PhiInsn;
 import com.android.dx.ssa.Optimizer;
+import com.android.dx.ssa.PhiInsn;
+import com.android.dx.ssa.RegisterMapper;
 import com.android.dx.ssa.SsaBasicBlock;
-import com.android.dx.util.IntSet;
+import com.android.dx.ssa.SsaInsn;
+import com.android.dx.ssa.SsaMethod;
 import com.android.dx.util.IntIterator;
-
+import com.android.dx.util.IntSet;
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Map;
index 515b04f..b2be1dd 100644 (file)
@@ -18,14 +18,9 @@ package com.android.dx.ssa.back;
 
 import com.android.dx.rop.code.BasicBlock;
 import com.android.dx.rop.code.BasicBlockList;
-import com.android.dx.rop.code.CstInsn;
-import com.android.dx.rop.code.Insn;
-import com.android.dx.rop.code.InsnList;
 import com.android.dx.rop.code.RegOps;
 import com.android.dx.rop.code.RopMethod;
-import com.android.dx.rop.code.SwitchInsn;
 import com.android.dx.util.IntList;
-
 import java.util.BitSet;
 
 /**
index e6cde62..5ed2f82 100644 (file)
 
 package com.android.dx.ssa.back;
 
-import com.android.dx.ssa.SsaMethod;
-import com.android.dx.ssa.SsaBasicBlock;
-import com.android.dx.ssa.SsaInsn;
-import com.android.dx.ssa.PhiInsn;
 import com.android.dx.ssa.SetFactory;
-import com.android.dx.rop.code.RegisterSpec;
 import com.android.dx.util.IntSet;
-import com.android.dx.util.BitIntSet;
-import com.android.dx.util.ListIntSet;
-
-import java.util.BitSet;
-import java.util.List;
 import java.util.ArrayList;
 
 /**
index a293e6f..0ea195a 100644 (file)
 
 package com.android.dx.ssa.back;
 
-import com.android.dx.ssa.SsaMethod;
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.ssa.PhiInsn;
 import com.android.dx.ssa.SsaBasicBlock;
 import com.android.dx.ssa.SsaInsn;
-import com.android.dx.ssa.PhiInsn;
-import com.android.dx.rop.code.RegisterSpec;
-
+import com.android.dx.ssa.SsaMethod;
+import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.List;
-import java.util.ArrayList;
 
 /**
  * From Appel "Modern Compiler Implementation in Java" algorithm 19.17
index 0205c11..adacdda 100644 (file)
@@ -20,9 +20,6 @@ import com.android.dx.ssa.BasicRegisterMapper;
 import com.android.dx.ssa.RegisterMapper;
 import com.android.dx.ssa.SsaMethod;
 
-import java.util.BitSet;
-import java.util.ArrayList;
-
 /**
  * A register allocator that maps SSA register n to Rop register 2*n,
  * essentially preserving the original mapping and remaining agnostic
index 1f9f70f..9d53798 100644 (file)
 
 package com.android.dx.ssa.back;
 
+import com.android.dx.rop.code.PlainInsn;
 import com.android.dx.rop.code.RegOps;
 import com.android.dx.rop.code.RegisterSpec;
-import com.android.dx.rop.code.PlainInsn;
+import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.rop.code.Rops;
 import com.android.dx.rop.code.SourcePosition;
-import com.android.dx.rop.code.RegisterSpecList;
 import com.android.dx.ssa.NormalSsaInsn;
 import com.android.dx.ssa.RegisterMapper;
+import com.android.dx.ssa.SsaBasicBlock;
 import com.android.dx.ssa.SsaInsn;
 import com.android.dx.ssa.SsaMethod;
-import com.android.dx.ssa.SsaBasicBlock;
-import com.android.dx.util.IntSet;
 import com.android.dx.util.IntIterator;
-
-import java.util.BitSet;
+import com.android.dx.util.IntSet;
 import java.util.ArrayList;
 
 /**
index 0e30250..401c67f 100644 (file)
@@ -32,7 +32,6 @@ import com.android.dx.ssa.SsaInsn;
 import com.android.dx.ssa.SsaMethod;
 import com.android.dx.util.Hex;
 import com.android.dx.util.IntList;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
index 05ec733..187d886 100644 (file)
@@ -16,6 +16,9 @@
 
 package com.android.dx.util;
 
+import com.android.dex.util.ByteOutput;
+import com.android.dex.util.ExceptionWithContext;
+import com.android.dex.Leb128;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
@@ -238,7 +241,7 @@ public final class ByteArrayAnnotatedOutput
             ensureCapacity(cursor + 5); // pessimistic
         }
         int cursorBefore = cursor;
-        Leb128Utils.writeUnsignedLeb128(this, value);
+        Leb128.writeUnsignedLeb128(this, value);
         return (cursor - cursorBefore);
     }
 
@@ -248,7 +251,7 @@ public final class ByteArrayAnnotatedOutput
             ensureCapacity(cursor + 5); // pessimistic
         }
         int cursorBefore = cursor;
-        Leb128Utils.writeSignedLeb128(this, value);
+        Leb128.writeSignedLeb128(this, value);
         return (cursor - cursorBefore);
     }
 
index bd21651..6e029df 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.dx.util;
 
+import com.android.dex.util.ExceptionWithContext;
+
 /**
  * Exception due to a mutability problem.
  */
index e5956a2..8ddec2e 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.dx.util;
 
+import com.android.dex.util.ByteOutput;
+
 /**
  * Interface for a sink for binary output. This is similar to
  * {@code java.util.DataOutput}, but no {@code IOExceptions}
diff --git a/dx/src/com/android/dx/util/Uint.java b/dx/src/com/android/dx/util/Uint.java
deleted file mode 100644 (file)
index 039756a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dx.util;
-
-/**
- * An unsigned integer.
- */
-public final class Uint implements Comparable<Uint> {
-    public final int intValue;
-
-    public Uint(int value) {
-        this.intValue = value;
-    }
-
-    public int compareTo(Uint uint) {
-        return Unsigned.compare(intValue, uint.intValue);
-    }
-}
index c6ffbdc..f51e251 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.dx.merge;
 
-import com.android.dx.io.DexBuffer;
+import com.android.dex.Dex;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -139,9 +139,9 @@ public final class DexMergeTest extends TestCase {
         int steps = 100;
         int compactWasteThreshold = 1024;
 
-        DexBuffer dexA = resourceToDexBuffer("/testdata/Basic.dex");
-        DexBuffer dexB = resourceToDexBuffer("/testdata/TryCatchFinally.dex");
-        DexBuffer merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
+        Dex dexA = resourceToDexBuffer("/testdata/Basic.dex");
+        Dex dexB = resourceToDexBuffer("/testdata/TryCatchFinally.dex");
+        Dex merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
 
         int maxLength = 0;
         for (int i = 0; i < steps; i++) {
@@ -156,9 +156,9 @@ public final class DexMergeTest extends TestCase {
     }
 
     public ClassLoader mergeAndLoad(String dexAResource, String dexBResource) throws Exception {
-        DexBuffer dexA = resourceToDexBuffer(dexAResource);
-        DexBuffer dexB = resourceToDexBuffer(dexBResource);
-        DexBuffer merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
+        Dex dexA = resourceToDexBuffer(dexAResource);
+        Dex dexB = resourceToDexBuffer(dexBResource);
+        Dex merged = new DexMerger(dexA, dexB, CollisionPolicy.KEEP_FIRST).merge();
         File mergedDex = File.createTempFile("DexMergeTest", ".classes.dex");
         merged.writeTo(mergedDex);
         File mergedJar = dexToJar(mergedDex);
@@ -168,8 +168,8 @@ public final class DexMergeTest extends TestCase {
                 .newInstance(mergedJar.getPath(), getClass().getClassLoader());
     }
 
-    private DexBuffer resourceToDexBuffer(String resource) throws IOException {
-        return new DexBuffer(getClass().getResourceAsStream(resource));
+    private Dex resourceToDexBuffer(String resource) throws IOException {
+        return new Dex(getClass().getResourceAsStream(resource));
     }
 
     private File dexToJar(File dex) throws IOException {
index dbc0ea3..13d0cb8 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.dx.util;
 
+import com.android.dex.util.ByteArrayByteInput;
+import com.android.dex.Leb128;
 import java.io.IOException;
 import java.util.Arrays;
 import junit.framework.TestCase;
@@ -23,10 +25,10 @@ import junit.framework.TestCase;
 public final class Leb128UtilsTest extends TestCase {
 
     public void testDecodeUnsignedLeb() throws IOException {
-        assertEquals(0, Leb128Utils.readUnsignedLeb128(new ByteArrayByteInput((byte) 0)));
-        assertEquals(1, Leb128Utils.readUnsignedLeb128(new ByteArrayByteInput((byte) 1)));
-        assertEquals(127, Leb128Utils.readUnsignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
-        assertEquals(16256, Leb128Utils.readUnsignedLeb128(
+        assertEquals(0, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 0)));
+        assertEquals(1, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 1)));
+        assertEquals(127, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
+        assertEquals(16256, Leb128.readUnsignedLeb128(
                 new ByteArrayByteInput((byte) 0x80, (byte) 0x7f)));
     }
 
@@ -42,11 +44,11 @@ public final class Leb128UtilsTest extends TestCase {
     }
 
     public void testDecodeSignedLeb() throws IOException {
-        assertEquals(0, Leb128Utils.readSignedLeb128(new ByteArrayByteInput((byte) 0)));
-        assertEquals(1, Leb128Utils.readSignedLeb128(new ByteArrayByteInput((byte) 1)));
-        assertEquals(-1, Leb128Utils.readSignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
-        assertEquals(0x3c, Leb128Utils.readSignedLeb128(new ByteArrayByteInput((byte) 0x3c)));
-        assertEquals(-128, Leb128Utils.readSignedLeb128(
+        assertEquals(0, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0)));
+        assertEquals(1, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 1)));
+        assertEquals(-1, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
+        assertEquals(0x3c, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0x3c)));
+        assertEquals(-128, Leb128.readSignedLeb128(
                 new ByteArrayByteInput((byte) 0x80, (byte) 0x7f)));
     }
 
@@ -59,13 +61,13 @@ public final class Leb128UtilsTest extends TestCase {
 
     private byte[] encodeSignedLeb(int value) {
         ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(5);
-        Leb128Utils.writeSignedLeb128(out, value);
+        Leb128.writeSignedLeb128(out, value);
         return out.toByteArray();
     }
 
     private byte[] encodeUnsignedLeb(int value) {
         ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(5);
-        Leb128Utils.writeUnsignedLeb128(out, value);
+        Leb128.writeUnsignedLeb128(out, value);
         return out.toByteArray();
     }
 
index 8e6188d..db92a96 100644 (file)
@@ -16,6 +16,9 @@
 
 package com.android.dx.util;
 
+import com.android.dex.util.ByteArrayByteInput;
+import com.android.dex.util.ByteInput;
+import com.android.dex.Mutf8;
 import java.io.IOException;
 import java.util.Arrays;
 import junit.framework.TestCase;
index 421d332..0248e96 100644 (file)
 
 package com.android.dx.merge;
 
-import com.android.dx.io.DexBuffer;
-import com.android.dx.util.DexException;
+import com.android.dex.Dex;
+import com.android.dex.DexException;
 import java.io.IOException;
 import junit.framework.TestCase;
 
 public final class MergeConflictTest extends TestCase {
 
     public void testMergeConflict() throws IOException {
-        DexBuffer a = resourceToDexBuffer("/testdata/A.dex");
-        DexBuffer b = resourceToDexBuffer("/testdata/B.dex");
+        Dex a = resourceToDexBuffer("/testdata/A.dex");
+        Dex b = resourceToDexBuffer("/testdata/B.dex");
 
         // a and b don't overlap; this should succeed
-        DexBuffer ab = new DexMerger(a, b, CollisionPolicy.FAIL).merge();
+        Dex ab = new DexMerger(a, b, CollisionPolicy.FAIL).merge();
 
         // a and ab overlap; this should fail
         DexMerger dexMerger = new DexMerger(a, ab, CollisionPolicy.FAIL);
@@ -40,7 +40,7 @@ public final class MergeConflictTest extends TestCase {
         }
     }
 
-    private DexBuffer resourceToDexBuffer(String resource) throws IOException {
-        return new DexBuffer(getClass().getResourceAsStream(resource));
+    private Dex resourceToDexBuffer(String resource) throws IOException {
+        return new Dex(getClass().getResourceAsStream(resource));
     }
 }