summaryrefslogtreecommitdiffstats
path: root/dx
diff options
context:
space:
mode:
Diffstat (limited to 'dx')
-rw-r--r--dx/junit-tests/com/android/dex/EncodedValueReaderTest.java (renamed from dx/junit-tests/com/android/dx/io/EncodedValueReaderTest.java)4
-rw-r--r--dx/junit-tests/com/android/dx/util/BitIntSetTest.java5
-rw-r--r--dx/junit-tests/com/android/dx/util/BitsTest.java3
-rw-r--r--dx/junit-tests/com/android/dx/util/IntListTest.java3
-rw-r--r--dx/junit-tests/com/android/dx/util/ListIntSetTest.java5
-rw-r--r--dx/src/com/android/dex/Annotation.java (renamed from dx/src/com/android/dx/io/Annotation.java)16
-rw-r--r--dx/src/com/android/dex/ClassData.java (renamed from dx/src/com/android/dx/io/ClassData.java)2
-rw-r--r--dx/src/com/android/dex/ClassDef.java (renamed from dx/src/com/android/dx/io/ClassDef.java)6
-rw-r--r--dx/src/com/android/dex/Code.java (renamed from dx/src/com/android/dx/io/Code.java)2
-rw-r--r--dx/src/com/android/dex/Dex.java (renamed from dx/src/com/android/dx/io/DexBuffer.java)58
-rw-r--r--dx/src/com/android/dex/DexException.java (renamed from dx/src/com/android/dx/util/DexException.java)4
-rw-r--r--dx/src/com/android/dex/DexFormat.java (renamed from dx/src/com/android/dx/dex/DexFormat.java)2
-rw-r--r--dx/src/com/android/dex/EncodedValue.java (renamed from dx/src/com/android/dx/io/EncodedValue.java)8
-rw-r--r--dx/src/com/android/dex/EncodedValueCodec.java (renamed from dx/src/com/android/dx/util/EncodedValueUtils.java)11
-rw-r--r--dx/src/com/android/dex/EncodedValueReader.java (renamed from dx/src/com/android/dx/io/EncodedValueReader.java)39
-rw-r--r--dx/src/com/android/dex/FieldId.java (renamed from dx/src/com/android/dx/io/FieldId.java)16
-rw-r--r--dx/src/com/android/dex/Leb128.java (renamed from dx/src/com/android/dx/util/Leb128Utils.java)13
-rw-r--r--dx/src/com/android/dex/MethodId.java (renamed from dx/src/com/android/dx/io/MethodId.java)20
-rw-r--r--dx/src/com/android/dex/Mutf8.java (renamed from dx/src/com/android/dx/util/Mutf8.java)3
-rw-r--r--dx/src/com/android/dex/ProtoId.java (renamed from dx/src/com/android/dx/io/ProtoId.java)20
-rw-r--r--dx/src/com/android/dex/SizeOf.java (renamed from dx/src/com/android/dx/dex/SizeOf.java)2
-rw-r--r--dx/src/com/android/dex/TableOfContents.java (renamed from dx/src/com/android/dx/dex/TableOfContents.java)18
-rw-r--r--dx/src/com/android/dex/TypeList.java (renamed from dx/src/com/android/dx/merge/TypeList.java)14
-rw-r--r--dx/src/com/android/dex/util/ByteArrayByteInput.java (renamed from dx/src/com/android/dx/util/ByteArrayByteInput.java)2
-rw-r--r--dx/src/com/android/dex/util/ByteInput.java (renamed from dx/src/com/android/dx/util/ByteInput.java)2
-rw-r--r--dx/src/com/android/dex/util/ByteOutput.java (renamed from dx/src/com/android/dx/util/ByteOutput.java)2
-rw-r--r--dx/src/com/android/dex/util/ExceptionWithContext.java (renamed from dx/src/com/android/dx/util/ExceptionWithContext.java)5
-rw-r--r--dx/src/com/android/dex/util/FileUtils.java (renamed from dx/src/com/android/dx/util/FileUtils.java)6
-rw-r--r--dx/src/com/android/dex/util/Unsigned.java (renamed from dx/src/com/android/dx/util/Unsigned.java)2
-rw-r--r--dx/src/com/android/dx/cf/code/BaseMachine.java2
-rw-r--r--dx/src/com/android/dx/cf/code/BasicBlocker.java2
-rw-r--r--dx/src/com/android/dx/cf/code/ByteBlockList.java1
-rw-r--r--dx/src/com/android/dx/cf/code/ExecutionStack.java2
-rw-r--r--dx/src/com/android/dx/cf/code/Frame.java2
-rw-r--r--dx/src/com/android/dx/cf/code/LocalVariableList.java2
-rw-r--r--dx/src/com/android/dx/cf/code/LocalsArray.java3
-rw-r--r--dx/src/com/android/dx/cf/code/LocalsArraySet.java4
-rw-r--r--dx/src/com/android/dx/cf/code/Machine.java2
-rw-r--r--dx/src/com/android/dx/cf/code/OneLocalsArray.java3
-rw-r--r--dx/src/com/android/dx/cf/code/Ropper.java18
-rw-r--r--dx/src/com/android/dx/cf/code/RopperMachine.java1
-rw-r--r--dx/src/com/android/dx/cf/code/SimException.java2
-rw-r--r--dx/src/com/android/dx/cf/code/Simulator.java3
-rw-r--r--dx/src/com/android/dx/cf/direct/AnnotationParser.java1
-rw-r--r--dx/src/com/android/dx/cf/direct/ClassPathOpener.java13
-rw-r--r--dx/src/com/android/dx/cf/direct/CodeObserver.java3
-rw-r--r--dx/src/com/android/dx/cf/direct/DirectClassFile.java2
-rw-r--r--dx/src/com/android/dx/cf/direct/StdAttributeFactory.java1
-rw-r--r--dx/src/com/android/dx/cf/iface/ParseException.java2
-rw-r--r--dx/src/com/android/dx/command/annotool/AnnotationLister.java11
-rw-r--r--dx/src/com/android/dx/command/annotool/Main.java13
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java26
-rw-r--r--dx/src/com/android/dx/command/dump/BaseDumper.java2
-rw-r--r--dx/src/com/android/dx/command/dump/BlockDumper.java6
-rw-r--r--dx/src/com/android/dx/command/dump/ClassDumper.java1
-rw-r--r--dx/src/com/android/dx/command/dump/DotDumper.java4
-rw-r--r--dx/src/com/android/dx/command/dump/Main.java3
-rw-r--r--dx/src/com/android/dx/command/dump/SsaDumper.java14
-rw-r--r--dx/src/com/android/dx/command/findusages/FindUsages.java21
-rw-r--r--dx/src/com/android/dx/command/findusages/Main.java4
-rw-r--r--dx/src/com/android/dx/command/grep/Grep.java16
-rw-r--r--dx/src/com/android/dx/command/grep/Main.java4
-rw-r--r--dx/src/com/android/dx/dex/DexOptions.java2
-rw-r--r--dx/src/com/android/dx/dex/cf/AttributeTranslator.java1
-rw-r--r--dx/src/com/android/dx/dex/cf/CfOptions.java1
-rw-r--r--dx/src/com/android/dx/dex/cf/CfTranslator.java4
-rw-r--r--dx/src/com/android/dx/dex/cf/CodeStatistics.java1
-rw-r--r--dx/src/com/android/dx/dex/cf/OptimizerOptions.java1
-rw-r--r--dx/src/com/android/dx/dex/code/ArrayData.java6
-rw-r--r--dx/src/com/android/dx/dex/code/CatchBuilder.java1
-rw-r--r--dx/src/com/android/dx/dex/code/CatchTable.java1
-rw-r--r--dx/src/com/android/dx/dex/code/DalvCode.java1
-rw-r--r--dx/src/com/android/dx/dex/code/DalvInsn.java1
-rw-r--r--dx/src/com/android/dx/dex/code/DalvInsnList.java3
-rw-r--r--dx/src/com/android/dx/dex/code/HighRegisterPrefix.java1
-rw-r--r--dx/src/com/android/dx/dex/code/InsnFormat.java1
-rw-r--r--dx/src/com/android/dx/dex/code/LocalList.java3
-rw-r--r--dx/src/com/android/dx/dex/code/OutputCollector.java1
-rw-r--r--dx/src/com/android/dx/dex/code/OutputFinisher.java4
-rw-r--r--dx/src/com/android/dx/dex/code/RopToDop.java5
-rw-r--r--dx/src/com/android/dx/dex/code/RopTranslator.java1
-rw-r--r--dx/src/com/android/dx/dex/code/StdCatchBuilder.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form11n.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form11x.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form12x.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form21c.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form21h.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form21s.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form21t.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form22b.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form22c.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form22s.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form22t.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form22x.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form23x.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form31c.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form31i.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form31t.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form32x.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form35c.java1
-rw-r--r--dx/src/com/android/dx/dex/code/form/Form51l.java1
-rw-r--r--dx/src/com/android/dx/dex/file/AnnotationItem.java3
-rw-r--r--dx/src/com/android/dx/dex/file/AnnotationSetItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/AnnotationUtils.java4
-rw-r--r--dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java1
-rw-r--r--dx/src/com/android/dx/dex/file/CatchStructs.java1
-rw-r--r--dx/src/com/android/dx/dex/file/ClassDataItem.java3
-rw-r--r--dx/src/com/android/dx/dex/file/ClassDefItem.java3
-rw-r--r--dx/src/com/android/dx/dex/file/ClassDefsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/CodeItem.java11
-rw-r--r--dx/src/com/android/dx/dex/file/DebugInfoDecoder.java42
-rw-r--r--dx/src/com/android/dx/dex/file/DebugInfoEncoder.java22
-rw-r--r--dx/src/com/android/dx/dex/file/DebugInfoItem.java3
-rw-r--r--dx/src/com/android/dx/dex/file/DexFile.java7
-rw-r--r--dx/src/com/android/dx/dex/file/EncodedArrayItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/EncodedField.java7
-rw-r--r--dx/src/com/android/dx/dex/file/EncodedMember.java1
-rw-r--r--dx/src/com/android/dx/dex/file/EncodedMethod.java9
-rw-r--r--dx/src/com/android/dx/dex/file/FieldIdsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/HeaderItem.java4
-rw-r--r--dx/src/com/android/dx/dex/file/HeaderSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/MapItem.java1
-rw-r--r--dx/src/com/android/dx/dex/file/MemberIdItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/MemberIdsSection.java2
-rw-r--r--dx/src/com/android/dx/dex/file/MethodIdsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/MixedItemSection.java3
-rw-r--r--dx/src/com/android/dx/dex/file/OffsettedItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java1
-rw-r--r--dx/src/com/android/dx/dex/file/ProtoIdItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/ProtoIdsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/Section.java1
-rw-r--r--dx/src/com/android/dx/dex/file/Statistics.java1
-rw-r--r--dx/src/com/android/dx/dex/file/StringDataItem.java6
-rw-r--r--dx/src/com/android/dx/dex/file/StringIdItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/StringIdsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/TypeIdItem.java4
-rw-r--r--dx/src/com/android/dx/dex/file/TypeIdsSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/TypeListItem.java1
-rw-r--r--dx/src/com/android/dx/dex/file/UniformItemSection.java1
-rw-r--r--dx/src/com/android/dx/dex/file/UniformListItem.java2
-rw-r--r--dx/src/com/android/dx/dex/file/ValueEncoder.java20
-rw-r--r--dx/src/com/android/dx/io/CodeReader.java2
-rw-r--r--dx/src/com/android/dx/io/DexHasher.java7
-rw-r--r--dx/src/com/android/dx/io/DexIndexPrinter.java31
-rw-r--r--dx/src/com/android/dx/io/instructions/AddressMap.java1
-rw-r--r--dx/src/com/android/dx/io/instructions/BaseCodeCursor.java2
-rw-r--r--dx/src/com/android/dx/io/instructions/DecodedInstruction.java2
-rw-r--r--dx/src/com/android/dx/io/instructions/InstructionCodec.java3
-rw-r--r--dx/src/com/android/dx/merge/DexMerger.java161
-rw-r--r--dx/src/com/android/dx/merge/IndexMap.java97
-rw-r--r--dx/src/com/android/dx/merge/InstructionTransformer.java2
-rw-r--r--dx/src/com/android/dx/merge/SortableType.java14
-rw-r--r--dx/src/com/android/dx/rop/annotation/Annotation.java1
-rw-r--r--dx/src/com/android/dx/rop/annotation/Annotations.java1
-rw-r--r--dx/src/com/android/dx/rop/code/FillArrayDataInsn.java3
-rw-r--r--dx/src/com/android/dx/rop/code/LocalVariableInfo.java1
-rw-r--r--dx/src/com/android/dx/rop/code/PlainInsn.java6
-rw-r--r--dx/src/com/android/dx/rop/code/RegisterSpec.java1
-rw-r--r--dx/src/com/android/dx/rop/code/RegisterSpecList.java1
-rw-r--r--dx/src/com/android/dx/rop/code/RopMethod.java1
-rw-r--r--dx/src/com/android/dx/rop/cst/CstArray.java1
-rw-r--r--dx/src/com/android/dx/rop/cst/StdConstantPool.java2
-rw-r--r--dx/src/com/android/dx/rop/type/Type.java1
-rw-r--r--dx/src/com/android/dx/ssa/BasicRegisterMapper.java1
-rw-r--r--dx/src/com/android/dx/ssa/DeadCodeRemover.java7
-rw-r--r--dx/src/com/android/dx/ssa/DomFront.java4
-rw-r--r--dx/src/com/android/dx/ssa/EscapeAnalysis.java1
-rw-r--r--dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java6
-rw-r--r--dx/src/com/android/dx/ssa/LiteralOpUpgrader.java11
-rw-r--r--dx/src/com/android/dx/ssa/LocalVariableExtractor.java3
-rw-r--r--dx/src/com/android/dx/ssa/LocalVariableInfo.java5
-rw-r--r--dx/src/com/android/dx/ssa/MoveParamCombiner.java6
-rw-r--r--dx/src/com/android/dx/ssa/NormalSsaInsn.java7
-rw-r--r--dx/src/com/android/dx/ssa/Optimizer.java1
-rw-r--r--dx/src/com/android/dx/ssa/PhiInsn.java8
-rw-r--r--dx/src/com/android/dx/ssa/PhiTypeResolver.java3
-rw-r--r--dx/src/com/android/dx/ssa/RegisterMapper.java1
-rw-r--r--dx/src/com/android/dx/ssa/SCCP.java5
-rw-r--r--dx/src/com/android/dx/ssa/SsaBasicBlock.java1
-rw-r--r--dx/src/com/android/dx/ssa/SsaConverter.java1
-rw-r--r--dx/src/com/android/dx/ssa/SsaInsn.java6
-rw-r--r--dx/src/com/android/dx/ssa/SsaMethod.java1
-rw-r--r--dx/src/com/android/dx/ssa/SsaRenamer.java1
-rw-r--r--dx/src/com/android/dx/ssa/back/FirstFitAllocator.java6
-rw-r--r--dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java18
-rw-r--r--dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java5
-rw-r--r--dx/src/com/android/dx/ssa/back/InterferenceGraph.java10
-rw-r--r--dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java9
-rw-r--r--dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java3
-rw-r--r--dx/src/com/android/dx/ssa/back/RegisterAllocator.java10
-rw-r--r--dx/src/com/android/dx/ssa/back/SsaToRop.java1
-rw-r--r--dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java7
-rw-r--r--dx/src/com/android/dx/util/MutabilityException.java2
-rw-r--r--dx/src/com/android/dx/util/Output.java2
-rw-r--r--dx/src/com/android/dx/util/Uint.java32
-rw-r--r--dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java18
-rw-r--r--dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java24
-rw-r--r--dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java3
-rw-r--r--dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java14
199 files changed, 584 insertions, 729 deletions
diff --git a/dx/junit-tests/com/android/dx/io/EncodedValueReaderTest.java b/dx/junit-tests/com/android/dex/EncodedValueReaderTest.java
index 63689ec03..a4ca37672 100644
--- a/dx/junit-tests/com/android/dx/io/EncodedValueReaderTest.java
+++ b/dx/junit-tests/com/android/dex/EncodedValueReaderTest.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 {
diff --git a/dx/junit-tests/com/android/dx/util/BitIntSetTest.java b/dx/junit-tests/com/android/dx/util/BitIntSetTest.java
index d46d14fe3..6d1b9e878 100644
--- a/dx/junit-tests/com/android/dx/util/BitIntSetTest.java
+++ b/dx/junit-tests/com/android/dx/util/BitIntSetTest.java
@@ -14,8 +14,11 @@
* 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;
diff --git a/dx/junit-tests/com/android/dx/util/BitsTest.java b/dx/junit-tests/com/android/dx/util/BitsTest.java
index e4275132f..5cf2b6fa6 100644
--- a/dx/junit-tests/com/android/dx/util/BitsTest.java
+++ b/dx/junit-tests/com/android/dx/util/BitsTest.java
@@ -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 {
diff --git a/dx/junit-tests/com/android/dx/util/IntListTest.java b/dx/junit-tests/com/android/dx/util/IntListTest.java
index 7a53a67ba..8b72da10f 100644
--- a/dx/junit-tests/com/android/dx/util/IntListTest.java
+++ b/dx/junit-tests/com/android/dx/util/IntListTest.java
@@ -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 {
diff --git a/dx/junit-tests/com/android/dx/util/ListIntSetTest.java b/dx/junit-tests/com/android/dx/util/ListIntSetTest.java
index 868e630a1..dd72b6bab 100644
--- a/dx/junit-tests/com/android/dx/util/ListIntSetTest.java
+++ b/dx/junit-tests/com/android/dx/util/ListIntSetTest.java
@@ -14,8 +14,11 @@
* 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;
diff --git a/dx/src/com/android/dx/io/Annotation.java b/dx/src/com/android/dex/Annotation.java
index ed2446ee9..e5ef9783b 100644
--- a/dx/src/com/android/dx/io/Annotation.java
+++ b/dx/src/com/android/dex/Annotation.java
@@ -14,20 +14,20 @@
* 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());
}
}
diff --git a/dx/src/com/android/dx/io/ClassData.java b/dx/src/com/android/dex/ClassData.java
index 5da7ddd09..840756c5b 100644
--- a/dx/src/com/android/dx/io/ClassData.java
+++ b/dx/src/com/android/dex/ClassData.java
@@ -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;
diff --git a/dx/src/com/android/dx/io/ClassDef.java b/dx/src/com/android/dex/ClassDef.java
index 5c8d10b88..b3225ec0e 100644
--- a/dx/src/com/android/dx/io/ClassDef.java
+++ b/dx/src/com/android/dex/ClassDef.java
@@ -14,14 +14,14 @@
* 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;
diff --git a/dx/src/com/android/dx/io/Code.java b/dx/src/com/android/dex/Code.java
index 82da86267..9258af795 100644
--- a/dx/src/com/android/dx/io/Code.java
+++ b/dx/src/com/android/dex/Code.java
@@ -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;
diff --git a/dx/src/com/android/dx/io/DexBuffer.java b/dx/src/com/android/dex/Dex.java
index 2ea597efb..2395e50fa 100644
--- a/dx/src/com/android/dx/io/DexBuffer.java
+++ b/dx/src/com/android/dex/Dex.java
@@ -14,20 +14,14 @@
* 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);
diff --git a/dx/src/com/android/dx/util/DexException.java b/dx/src/com/android/dex/DexException.java
index 527b0b911..a30a46f78 100644
--- a/dx/src/com/android/dx/util/DexException.java
+++ b/dx/src/com/android/dex/DexException.java
@@ -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
diff --git a/dx/src/com/android/dx/dex/DexFormat.java b/dx/src/com/android/dex/DexFormat.java
index 3543b3527..85941fd46 100644
--- a/dx/src/com/android/dx/dex/DexFormat.java
+++ b/dx/src/com/android/dex/DexFormat.java
@@ -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}
diff --git a/dx/src/com/android/dx/io/EncodedValue.java b/dx/src/com/android/dex/EncodedValue.java
index c83c36448..8d0c3adcf 100644
--- a/dx/src/com/android/dx/io/EncodedValue.java
+++ b/dx/src/com/android/dex/EncodedValue.java
@@ -14,10 +14,10 @@
* 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);
}
diff --git a/dx/src/com/android/dx/util/EncodedValueUtils.java b/dx/src/com/android/dex/EncodedValueCodec.java
index bb92389b7..7fc172434 100644
--- a/dx/src/com/android/dx/util/EncodedValueUtils.java
+++ b/dx/src/com/android/dex/EncodedValueCodec.java
@@ -14,13 +14,16 @@
* 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() {
}
/**
diff --git a/dx/src/com/android/dx/io/EncodedValueReader.java b/dx/src/com/android/dex/EncodedValueReader.java
index fb928cc25..a26346410 100644
--- a/dx/src/com/android/dx/io/EncodedValueReader.java
+++ b/dx/src/com/android/dex/EncodedValueReader.java
@@ -14,12 +14,9 @@
* 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() {
diff --git a/dx/src/com/android/dx/io/FieldId.java b/dx/src/com/android/dex/FieldId.java
index da409fa44..2f41708c8 100644
--- a/dx/src/com/android/dx/io/FieldId.java
+++ b/dx/src/com/android/dex/FieldId.java
@@ -14,18 +14,18 @@
* 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);
}
}
diff --git a/dx/src/com/android/dx/util/Leb128Utils.java b/dx/src/com/android/dex/Leb128.java
index 10374638e..1a82e383e 100644
--- a/dx/src/com/android/dx/util/Leb128Utils.java
+++ b/dx/src/com/android/dex/Leb128.java
@@ -14,18 +14,17 @@
* 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() {
}
/**
diff --git a/dx/src/com/android/dx/io/MethodId.java b/dx/src/com/android/dex/MethodId.java
index e65366156..e51874026 100644
--- a/dx/src/com/android/dx/io/MethodId.java
+++ b/dx/src/com/android/dex/MethodId.java
@@ -14,18 +14,18 @@
* 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());
}
}
diff --git a/dx/src/com/android/dx/util/Mutf8.java b/dx/src/com/android/dex/Mutf8.java
index fe5572492..c64da331b 100644
--- a/dx/src/com/android/dx/util/Mutf8.java
+++ b/dx/src/com/android/dex/Mutf8.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/io/ProtoId.java b/dx/src/com/android/dex/ProtoId.java
index 98c07771f..9d9f484f2 100644
--- a/dx/src/com/android/dx/io/ProtoId.java
+++ b/dx/src/com/android/dex/ProtoId.java
@@ -14,18 +14,18 @@
* 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);
}
}
diff --git a/dx/src/com/android/dx/dex/SizeOf.java b/dx/src/com/android/dex/SizeOf.java
index 6ded78282..65fab565b 100644
--- a/dx/src/com/android/dx/dex/SizeOf.java
+++ b/dx/src/com/android/dex/SizeOf.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dx.dex;
+package com.android.dex;
public final class SizeOf {
private SizeOf() {}
diff --git a/dx/src/com/android/dx/dex/TableOfContents.java b/dx/src/com/android/dex/TableOfContents.java
index fbe46264c..d1b87ac8f 100644
--- a/dx/src/com/android/dx/dex/TableOfContents.java
+++ b/dx/src/com/android/dex/TableOfContents.java
@@ -14,10 +14,8 @@
* 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()) {
diff --git a/dx/src/com/android/dx/merge/TypeList.java b/dx/src/com/android/dex/TypeList.java
index 62984e2b7..aa1bf5832 100644
--- a/dx/src/com/android/dx/merge/TypeList.java
+++ b/dx/src/com/android/dex/TypeList.java
@@ -14,21 +14,19 @@
* 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();
diff --git a/dx/src/com/android/dx/util/ByteArrayByteInput.java b/dx/src/com/android/dex/util/ByteArrayByteInput.java
index 07c543fe3..889a936c5 100644
--- a/dx/src/com/android/dx/util/ByteArrayByteInput.java
+++ b/dx/src/com/android/dex/util/ByteArrayByteInput.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dx.util;
+package com.android.dex.util;
public final class ByteArrayByteInput implements ByteInput {
diff --git a/dx/src/com/android/dx/util/ByteInput.java b/dx/src/com/android/dex/util/ByteInput.java
index 8181e3ea3..f1a719614 100644
--- a/dx/src/com/android/dx/util/ByteInput.java
+++ b/dx/src/com/android/dex/util/ByteInput.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dx.util;
+package com.android.dex.util;
/**
* A byte source.
diff --git a/dx/src/com/android/dx/util/ByteOutput.java b/dx/src/com/android/dex/util/ByteOutput.java
index 512dcf8d9..eb77040ec 100644
--- a/dx/src/com/android/dx/util/ByteOutput.java
+++ b/dx/src/com/android/dex/util/ByteOutput.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dx.util;
+package com.android.dex.util;
/**
* A byte sink.
diff --git a/dx/src/com/android/dx/util/ExceptionWithContext.java b/dx/src/com/android/dex/util/ExceptionWithContext.java
index 7f8523c15..5dfd95474 100644
--- a/dx/src/com/android/dx/util/ExceptionWithContext.java
+++ b/dx/src/com/android/dex/util/ExceptionWithContext.java
@@ -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;
diff --git a/dx/src/com/android/dx/util/FileUtils.java b/dx/src/com/android/dex/util/FileUtils.java
index bcf67298e..4cea95c59 100644
--- a/dx/src/com/android/dx/util/FileUtils.java
+++ b/dx/src/com/android/dex/util/FileUtils.java
@@ -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.
}
/**
diff --git a/dx/src/com/android/dx/util/Unsigned.java b/dx/src/com/android/dex/util/Unsigned.java
index f15bd86da..cb50d0a40 100644
--- a/dx/src/com/android/dx/util/Unsigned.java
+++ b/dx/src/com/android/dex/util/Unsigned.java
@@ -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.
diff --git a/dx/src/com/android/dx/cf/code/BaseMachine.java b/dx/src/com/android/dx/cf/code/BaseMachine.java
index c56dd3e72..7bff2ff2f 100644
--- a/dx/src/com/android/dx/cf/code/BaseMachine.java
+++ b/dx/src/com/android/dx/cf/code/BaseMachine.java
@@ -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;
diff --git a/dx/src/com/android/dx/cf/code/BasicBlocker.java b/dx/src/com/android/dx/cf/code/BasicBlocker.java
index 56d399111..8fb9560f8 100644
--- a/dx/src/com/android/dx/cf/code/BasicBlocker.java
+++ b/dx/src/com/android/dx/cf/code/BasicBlocker.java
@@ -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;
diff --git a/dx/src/com/android/dx/cf/code/ByteBlockList.java b/dx/src/com/android/dx/cf/code/ByteBlockList.java
index 412dfc3f7..5370c951f 100644
--- a/dx/src/com/android/dx/cf/code/ByteBlockList.java
+++ b/dx/src/com/android/dx/cf/code/ByteBlockList.java
@@ -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;
diff --git a/dx/src/com/android/dx/cf/code/ExecutionStack.java b/dx/src/com/android/dx/cf/code/ExecutionStack.java
index 51f633447..696abc80a 100644
--- a/dx/src/com/android/dx/cf/code/ExecutionStack.java
+++ b/dx/src/com/android/dx/cf/code/ExecutionStack.java
@@ -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;
diff --git a/dx/src/com/android/dx/cf/code/Frame.java b/dx/src/com/android/dx/cf/code/Frame.java
index 002a4fbc1..cb32b92d9 100644
--- a/dx/src/com/android/dx/cf/code/Frame.java
+++ b/dx/src/com/android/dx/cf/code/Frame.java
@@ -16,10 +16,10 @@
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;
/**
diff --git a/dx/src/com/android/dx/cf/code/LocalVariableList.java b/dx/src/com/android/dx/cf/code/LocalVariableList.java
index 2962698e5..4a0bae10c 100644
--- a/dx/src/com/android/dx/cf/code/LocalVariableList.java
+++ b/dx/src/com/android/dx/cf/code/LocalVariableList.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/code/LocalsArray.java b/dx/src/com/android/dx/cf/code/LocalsArray.java
index 75af04752..07ca96da6 100644
--- a/dx/src/com/android/dx/cf/code/LocalsArray.java
+++ b/dx/src/com/android/dx/cf/code/LocalsArray.java
@@ -16,11 +16,10 @@
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;
diff --git a/dx/src/com/android/dx/cf/code/LocalsArraySet.java b/dx/src/com/android/dx/cf/code/LocalsArraySet.java
index 5d0305508..c4b7da9f3 100644
--- a/dx/src/com/android/dx/cf/code/LocalsArraySet.java
+++ b/dx/src/com/android/dx/cf/code/LocalsArraySet.java
@@ -16,13 +16,11 @@
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;
/**
diff --git a/dx/src/com/android/dx/cf/code/Machine.java b/dx/src/com/android/dx/cf/code/Machine.java
index a81feaff3..a1905059f 100644
--- a/dx/src/com/android/dx/cf/code/Machine.java
+++ b/dx/src/com/android/dx/cf/code/Machine.java
@@ -16,10 +16,10 @@
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;
/**
diff --git a/dx/src/com/android/dx/cf/code/OneLocalsArray.java b/dx/src/com/android/dx/cf/code/OneLocalsArray.java
index cafd177d3..0286a706f 100644
--- a/dx/src/com/android/dx/cf/code/OneLocalsArray.java
+++ b/dx/src/com/android/dx/cf/code/OneLocalsArray.java
@@ -16,12 +16,11 @@
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.
diff --git a/dx/src/com/android/dx/cf/code/Ropper.java b/dx/src/com/android/dx/cf/code/Ropper.java
index 715cfd8e9..c318b4c72 100644
--- a/dx/src/com/android/dx/cf/code/Ropper.java
+++ b/dx/src/com/android/dx/cf/code/Ropper.java
@@ -16,7 +16,22 @@
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;
diff --git a/dx/src/com/android/dx/cf/code/RopperMachine.java b/dx/src/com/android/dx/cf/code/RopperMachine.java
index f45bc1f42..f1b8db412 100644
--- a/dx/src/com/android/dx/cf/code/RopperMachine.java
+++ b/dx/src/com/android/dx/cf/code/RopperMachine.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/code/SimException.java b/dx/src/com/android/dx/cf/code/SimException.java
index 220f2818a..7cbab04c7 100644
--- a/dx/src/com/android/dx/cf/code/SimException.java
+++ b/dx/src/com/android/dx/cf/code/SimException.java
@@ -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.
diff --git a/dx/src/com/android/dx/cf/code/Simulator.java b/dx/src/com/android/dx/cf/code/Simulator.java
index c09783167..35e62281b 100644
--- a/dx/src/com/android/dx/cf/code/Simulator.java
+++ b/dx/src/com/android/dx/cf/code/Simulator.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/direct/AnnotationParser.java b/dx/src/com/android/dx/cf/direct/AnnotationParser.java
index fdbc99047..f76669445 100644
--- a/dx/src/com/android/dx/cf/direct/AnnotationParser.java
+++ b/dx/src/com/android/dx/cf/direct/AnnotationParser.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java b/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
index 7621bf7c7..e2e2cfbe9 100644
--- a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
+++ b/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
@@ -16,18 +16,17 @@
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
diff --git a/dx/src/com/android/dx/cf/direct/CodeObserver.java b/dx/src/com/android/dx/cf/direct/CodeObserver.java
index efcc80ba9..4262cf82c 100644
--- a/dx/src/com/android/dx/cf/direct/CodeObserver.java
+++ b/dx/src/com/android/dx/cf/direct/CodeObserver.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/direct/DirectClassFile.java b/dx/src/com/android/dx/cf/direct/DirectClassFile.java
index 4f1c85de7..a7bb073a6 100644
--- a/dx/src/com/android/dx/cf/direct/DirectClassFile.java
+++ b/dx/src/com/android/dx/cf/direct/DirectClassFile.java
@@ -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;
diff --git a/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java b/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java
index ae04a1397..992809a0a 100644
--- a/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java
+++ b/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/cf/iface/ParseException.java b/dx/src/com/android/dx/cf/iface/ParseException.java
index 18a9d0e24..6ed6d3bbf 100644
--- a/dx/src/com/android/dx/cf/iface/ParseException.java
+++ b/dx/src/com/android/dx/cf/iface/ParseException.java
@@ -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.
diff --git a/dx/src/com/android/dx/command/annotool/AnnotationLister.java b/dx/src/com/android/dx/command/annotool/AnnotationLister.java
index 6584b6032..2de899cfb 100644
--- a/dx/src/com/android/dx/command/annotool/AnnotationLister.java
+++ b/dx/src/com/android/dx/command/annotool/AnnotationLister.java
@@ -16,17 +16,16 @@
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;
diff --git a/dx/src/com/android/dx/command/annotool/Main.java b/dx/src/com/android/dx/command/annotool/Main.java
index 7661c3d45..14d737329 100644
--- a/dx/src/com/android/dx/command/annotool/Main.java
+++ b/dx/src/com/android/dx/command/annotool/Main.java
@@ -16,21 +16,8 @@
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 {
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 87f152afb..8f1a3e887 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -16,13 +16,15 @@
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();
}
diff --git a/dx/src/com/android/dx/command/dump/BaseDumper.java b/dx/src/com/android/dx/command/dump/BaseDumper.java
index ad6540b59..b71be4737 100644
--- a/dx/src/com/android/dx/command/dump/BaseDumper.java
+++ b/dx/src/com/android/dx/command/dump/BaseDumper.java
@@ -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;
diff --git a/dx/src/com/android/dx/command/dump/BlockDumper.java b/dx/src/com/android/dx/command/dump/BlockDumper.java
index 6919b0967..b670cd7fa 100644
--- a/dx/src/com/android/dx/command/dump/BlockDumper.java
+++ b/dx/src/com/android/dx/command/dump/BlockDumper.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/command/dump/ClassDumper.java b/dx/src/com/android/dx/command/dump/ClassDumper.java
index e98b6d6ef..9723c6200 100644
--- a/dx/src/com/android/dx/command/dump/ClassDumper.java
+++ b/dx/src/com/android/dx/command/dump/ClassDumper.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/command/dump/DotDumper.java b/dx/src/com/android/dx/command/dump/DotDumper.java
index 9de48fc82..1c4c74bfe 100644
--- a/dx/src/com/android/dx/command/dump/DotDumper.java
+++ b/dx/src/com/android/dx/command/dump/DotDumper.java
@@ -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;
diff --git a/dx/src/com/android/dx/command/dump/Main.java b/dx/src/com/android/dx/command/dump/Main.java
index d6ba3740a..59c10b0f6 100644
--- a/dx/src/com/android/dx/command/dump/Main.java
+++ b/dx/src/com/android/dx/command/dump/Main.java
@@ -16,10 +16,9 @@
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;
/**
diff --git a/dx/src/com/android/dx/command/dump/SsaDumper.java b/dx/src/com/android/dx/command/dump/SsaDumper.java
index 0572a300e..80953c16e 100644
--- a/dx/src/com/android/dx/command/dump/SsaDumper.java
+++ b/dx/src/com/android/dx/command/dump/SsaDumper.java
@@ -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;
diff --git a/dx/src/com/android/dx/command/findusages/FindUsages.java b/dx/src/com/android/dx/command/findusages/FindUsages.java
index 6651f53c1..f84d87d41 100644
--- a/dx/src/com/android/dx/command/findusages/FindUsages.java
+++ b/dx/src/com/android/dx/command/findusages/FindUsages.java
@@ -16,15 +16,14 @@
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);
diff --git a/dx/src/com/android/dx/command/findusages/Main.java b/dx/src/com/android/dx/command/findusages/Main.java
index ba29787a5..b0eeb6966 100644
--- a/dx/src/com/android/dx/command/findusages/Main.java
+++ b/dx/src/com/android/dx/command/findusages/Main.java
@@ -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();
diff --git a/dx/src/com/android/dx/command/grep/Grep.java b/dx/src/com/android/dx/command/grep/Grep.java
index 14c46d7cc..5972fa170 100644
--- a/dx/src/com/android/dx/command/grep/Grep.java
+++ b/dx/src/com/android/dx/command/grep/Grep.java
@@ -16,12 +16,12 @@
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()) {
diff --git a/dx/src/com/android/dx/command/grep/Main.java b/dx/src/com/android/dx/command/grep/Main.java
index e3b119a9b..08920f7b2 100644
--- a/dx/src/com/android/dx/command/grep/Main.java
+++ b/dx/src/com/android/dx/command/grep/Main.java
@@ -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);
}
diff --git a/dx/src/com/android/dx/dex/DexOptions.java b/dx/src/com/android/dx/dex/DexOptions.java
index 0a0745192..db0c7a2c5 100644
--- a/dx/src/com/android/dx/dex/DexOptions.java
+++ b/dx/src/com/android/dx/dex/DexOptions.java
@@ -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.
*/
diff --git a/dx/src/com/android/dx/dex/cf/AttributeTranslator.java b/dx/src/com/android/dx/dex/cf/AttributeTranslator.java
index 8dc8b928d..90e32c3ab 100644
--- a/dx/src/com/android/dx/dex/cf/AttributeTranslator.java
+++ b/dx/src/com/android/dx/dex/cf/AttributeTranslator.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/cf/CfOptions.java b/dx/src/com/android/dx/dex/cf/CfOptions.java
index 468f0bec1..03d1d29ca 100644
--- a/dx/src/com/android/dx/dex/cf/CfOptions.java
+++ b/dx/src/com/android/dx/dex/cf/CfOptions.java
@@ -17,7 +17,6 @@
package com.android.dx.dex.cf;
import com.android.dx.dex.code.PositionList;
-
import java.io.PrintStream;
/**
diff --git a/dx/src/com/android/dx/dex/cf/CfTranslator.java b/dx/src/com/android/dx/dex/cf/CfTranslator.java
index 8b94f9164..d4cda2a9a 100644
--- a/dx/src/com/android/dx/dex/cf/CfTranslator.java
+++ b/dx/src/com/android/dx/dex/cf/CfTranslator.java
@@ -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
diff --git a/dx/src/com/android/dx/dex/cf/CodeStatistics.java b/dx/src/com/android/dx/dex/cf/CodeStatistics.java
index 33d03fded..618fe2c63 100644
--- a/dx/src/com/android/dx/dex/cf/CodeStatistics.java
+++ b/dx/src/com/android/dx/dex/cf/CodeStatistics.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/cf/OptimizerOptions.java b/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
index a66421e76..151d54c9c 100644
--- a/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
+++ b/dx/src/com/android/dx/dex/cf/OptimizerOptions.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/code/ArrayData.java b/dx/src/com/android/dx/dex/code/ArrayData.java
index 6674b7553..fd2871285 100644
--- a/dx/src/com/android/dx/dex/code/ArrayData.java
+++ b/dx/src/com/android/dx/dex/code/ArrayData.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/CatchBuilder.java b/dx/src/com/android/dx/dex/code/CatchBuilder.java
index 90d2e8d7c..059091e57 100644
--- a/dx/src/com/android/dx/dex/code/CatchBuilder.java
+++ b/dx/src/com/android/dx/dex/code/CatchBuilder.java
@@ -17,7 +17,6 @@
package com.android.dx.dex.code;
import com.android.dx.rop.type.Type;
-
import java.util.HashSet;
/**
diff --git a/dx/src/com/android/dx/dex/code/CatchTable.java b/dx/src/com/android/dx/dex/code/CatchTable.java
index 0ee890f85..8470789fe 100644
--- a/dx/src/com/android/dx/dex/code/CatchTable.java
+++ b/dx/src/com/android/dx/dex/code/CatchTable.java
@@ -16,7 +16,6 @@
package com.android.dx.dex.code;
-import com.android.dx.rop.cst.CstType;
import com.android.dx.util.FixedSizeList;
/**
diff --git a/dx/src/com/android/dx/dex/code/DalvCode.java b/dx/src/com/android/dx/dex/code/DalvCode.java
index 58f191b56..ebaf28857 100644
--- a/dx/src/com/android/dx/dex/code/DalvCode.java
+++ b/dx/src/com/android/dx/dex/code/DalvCode.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/DalvInsn.java b/dx/src/com/android/dx/dex/code/DalvInsn.java
index d0cf39540..41fcbdca8 100644
--- a/dx/src/com/android/dx/dex/code/DalvInsn.java
+++ b/dx/src/com/android/dx/dex/code/DalvInsn.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/DalvInsnList.java b/dx/src/com/android/dx/dex/code/DalvInsnList.java
index e856cb4bc..ace0e8f5d 100644
--- a/dx/src/com/android/dx/dex/code/DalvInsnList.java
+++ b/dx/src/com/android/dx/dex/code/DalvInsnList.java
@@ -16,14 +16,13 @@
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;
diff --git a/dx/src/com/android/dx/dex/code/HighRegisterPrefix.java b/dx/src/com/android/dx/dex/code/HighRegisterPrefix.java
index 6fab094e5..4f8194984 100644
--- a/dx/src/com/android/dx/dex/code/HighRegisterPrefix.java
+++ b/dx/src/com/android/dx/dex/code/HighRegisterPrefix.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/InsnFormat.java b/dx/src/com/android/dx/dex/code/InsnFormat.java
index c866fecdc..63fcea96d 100644
--- a/dx/src/com/android/dx/dex/code/InsnFormat.java
+++ b/dx/src/com/android/dx/dex/code/InsnFormat.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/LocalList.java b/dx/src/com/android/dx/dex/code/LocalList.java
index ab8343a1e..45764c703 100644
--- a/dx/src/com/android/dx/dex/code/LocalList.java
+++ b/dx/src/com/android/dx/dex/code/LocalList.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/code/OutputCollector.java b/dx/src/com/android/dx/dex/code/OutputCollector.java
index a5e54a89d..46f096b5f 100644
--- a/dx/src/com/android/dx/dex/code/OutputCollector.java
+++ b/dx/src/com/android/dx/dex/code/OutputCollector.java
@@ -17,7 +17,6 @@
package com.android.dx.dex.code;
import com.android.dx.dex.DexOptions;
-
import java.util.ArrayList;
/**
diff --git a/dx/src/com/android/dx/dex/code/OutputFinisher.java b/dx/src/com/android/dx/dex/code/OutputFinisher.java
index c9387fab6..2140eb639 100644
--- a/dx/src/com/android/dx/dex/code/OutputFinisher.java
+++ b/dx/src/com/android/dx/dex/code/OutputFinisher.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/code/RopToDop.java b/dx/src/com/android/dx/dex/code/RopToDop.java
index 0330113b6..fbfb0db2a 100644
--- a/dx/src/com/android/dx/dex/code/RopToDop.java
+++ b/dx/src/com/android/dx/dex/code/RopToDop.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/RopTranslator.java b/dx/src/com/android/dx/dex/code/RopTranslator.java
index 46ed8112d..d81fd4b9d 100644
--- a/dx/src/com/android/dx/dex/code/RopTranslator.java
+++ b/dx/src/com/android/dx/dex/code/RopTranslator.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/StdCatchBuilder.java b/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
index 1e7612e7a..afac94669 100644
--- a/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
+++ b/dx/src/com/android/dx/dex/code/StdCatchBuilder.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/code/form/Form11n.java b/dx/src/com/android/dx/dex/code/form/Form11n.java
index 479af6e78..f83f33198 100644
--- a/dx/src/com/android/dx/dex/code/form/Form11n.java
+++ b/dx/src/com/android/dx/dex/code/form/Form11n.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form11x.java b/dx/src/com/android/dx/dex/code/form/Form11x.java
index 82dda65d8..cb1fd0d3f 100644
--- a/dx/src/com/android/dx/dex/code/form/Form11x.java
+++ b/dx/src/com/android/dx/dex/code/form/Form11x.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form12x.java b/dx/src/com/android/dx/dex/code/form/Form12x.java
index aabab8adb..b4d5b4a5c 100644
--- a/dx/src/com/android/dx/dex/code/form/Form12x.java
+++ b/dx/src/com/android/dx/dex/code/form/Form12x.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form21c.java b/dx/src/com/android/dx/dex/code/form/Form21c.java
index 0335dc731..1c381d37b 100644
--- a/dx/src/com/android/dx/dex/code/form/Form21c.java
+++ b/dx/src/com/android/dx/dex/code/form/Form21c.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form21h.java b/dx/src/com/android/dx/dex/code/form/Form21h.java
index 02cc0fd0e..ea51cb8dd 100644
--- a/dx/src/com/android/dx/dex/code/form/Form21h.java
+++ b/dx/src/com/android/dx/dex/code/form/Form21h.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form21s.java b/dx/src/com/android/dx/dex/code/form/Form21s.java
index 9264ec0c8..76f9824d1 100644
--- a/dx/src/com/android/dx/dex/code/form/Form21s.java
+++ b/dx/src/com/android/dx/dex/code/form/Form21s.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form21t.java b/dx/src/com/android/dx/dex/code/form/Form21t.java
index 8adb66865..9d31dc5e4 100644
--- a/dx/src/com/android/dx/dex/code/form/Form21t.java
+++ b/dx/src/com/android/dx/dex/code/form/Form21t.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form22b.java b/dx/src/com/android/dx/dex/code/form/Form22b.java
index e5a8b5d67..006308bb6 100644
--- a/dx/src/com/android/dx/dex/code/form/Form22b.java
+++ b/dx/src/com/android/dx/dex/code/form/Form22b.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form22c.java b/dx/src/com/android/dx/dex/code/form/Form22c.java
index 5ffdb8628..98cba4b27 100644
--- a/dx/src/com/android/dx/dex/code/form/Form22c.java
+++ b/dx/src/com/android/dx/dex/code/form/Form22c.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form22s.java b/dx/src/com/android/dx/dex/code/form/Form22s.java
index 03d180ac6..a48c367c8 100644
--- a/dx/src/com/android/dx/dex/code/form/Form22s.java
+++ b/dx/src/com/android/dx/dex/code/form/Form22s.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form22t.java b/dx/src/com/android/dx/dex/code/form/Form22t.java
index 15ce0f8dd..f67608f1c 100644
--- a/dx/src/com/android/dx/dex/code/form/Form22t.java
+++ b/dx/src/com/android/dx/dex/code/form/Form22t.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form22x.java b/dx/src/com/android/dx/dex/code/form/Form22x.java
index 01eec0bea..fedc9117b 100644
--- a/dx/src/com/android/dx/dex/code/form/Form22x.java
+++ b/dx/src/com/android/dx/dex/code/form/Form22x.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form23x.java b/dx/src/com/android/dx/dex/code/form/Form23x.java
index 91644820e..4e11ab899 100644
--- a/dx/src/com/android/dx/dex/code/form/Form23x.java
+++ b/dx/src/com/android/dx/dex/code/form/Form23x.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form31c.java b/dx/src/com/android/dx/dex/code/form/Form31c.java
index 3295fdab4..9e082fa06 100644
--- a/dx/src/com/android/dx/dex/code/form/Form31c.java
+++ b/dx/src/com/android/dx/dex/code/form/Form31c.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form31i.java b/dx/src/com/android/dx/dex/code/form/Form31i.java
index b52341d5e..a05911158 100644
--- a/dx/src/com/android/dx/dex/code/form/Form31i.java
+++ b/dx/src/com/android/dx/dex/code/form/Form31i.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form31t.java b/dx/src/com/android/dx/dex/code/form/Form31t.java
index 1999bba61..77dc0773f 100644
--- a/dx/src/com/android/dx/dex/code/form/Form31t.java
+++ b/dx/src/com/android/dx/dex/code/form/Form31t.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form32x.java b/dx/src/com/android/dx/dex/code/form/Form32x.java
index abed0e938..a65361981 100644
--- a/dx/src/com/android/dx/dex/code/form/Form32x.java
+++ b/dx/src/com/android/dx/dex/code/form/Form32x.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form35c.java b/dx/src/com/android/dx/dex/code/form/Form35c.java
index b9c12c643..82b4631d6 100644
--- a/dx/src/com/android/dx/dex/code/form/Form35c.java
+++ b/dx/src/com/android/dx/dex/code/form/Form35c.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/code/form/Form51l.java b/dx/src/com/android/dx/dex/code/form/Form51l.java
index 4dc7bcd95..2a31deaef 100644
--- a/dx/src/com/android/dx/dex/code/form/Form51l.java
+++ b/dx/src/com/android/dx/dex/code/form/Form51l.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/AnnotationItem.java b/dx/src/com/android/dx/dex/file/AnnotationItem.java
index 1d9224780..e42f74ca5 100644
--- a/dx/src/com/android/dx/dex/file/AnnotationItem.java
+++ b/dx/src/com/android/dx/dex/file/AnnotationItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/AnnotationSetItem.java b/dx/src/com/android/dx/dex/file/AnnotationSetItem.java
index 218770034..1d0062271 100644
--- a/dx/src/com/android/dx/dex/file/AnnotationSetItem.java
+++ b/dx/src/com/android/dx/dex/file/AnnotationSetItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/AnnotationUtils.java b/dx/src/com/android/dx/dex/file/AnnotationUtils.java
index 350ed9aea..935c250f6 100644
--- a/dx/src/com/android/dx/dex/file/AnnotationUtils.java
+++ b/dx/src/com/android/dx/dex/file/AnnotationUtils.java
@@ -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.
*/
diff --git a/dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java b/dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java
index 972d4e6c1..b9e82040d 100644
--- a/dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java
+++ b/dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/CatchStructs.java b/dx/src/com/android/dx/dex/file/CatchStructs.java
index 8b0f1bdd7..1e02452cf 100644
--- a/dx/src/com/android/dx/dex/file/CatchStructs.java
+++ b/dx/src/com/android/dx/dex/file/CatchStructs.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/ClassDataItem.java b/dx/src/com/android/dx/dex/file/ClassDataItem.java
index e9ae18ba3..c3bd0c143 100644
--- a/dx/src/com/android/dx/dex/file/ClassDataItem.java
+++ b/dx/src/com/android/dx/dex/file/ClassDataItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/ClassDefItem.java b/dx/src/com/android/dx/dex/file/ClassDefItem.java
index df3945af6..0b4c92b69 100644
--- a/dx/src/com/android/dx/dex/file/ClassDefItem.java
+++ b/dx/src/com/android/dx/dex/file/ClassDefItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/ClassDefsSection.java b/dx/src/com/android/dx/dex/file/ClassDefsSection.java
index 1ca391f7f..4db056ba2 100644
--- a/dx/src/com/android/dx/dex/file/ClassDefsSection.java
+++ b/dx/src/com/android/dx/dex/file/ClassDefsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/CodeItem.java b/dx/src/com/android/dx/dex/file/CodeItem.java
index a47f68ae7..9e3ae74bf 100644
--- a/dx/src/com/android/dx/dex/file/CodeItem.java
+++ b/dx/src/com/android/dx/dex/file/CodeItem.java
@@ -16,26 +16,17 @@
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
diff --git a/dx/src/com/android/dx/dex/file/DebugInfoDecoder.java b/dx/src/com/android/dx/dex/file/DebugInfoDecoder.java
index 9fb484536..203b0f856 100644
--- a/dx/src/com/android/dx/dex/file/DebugInfoDecoder.java
+++ b/dx/src/com/android/dx/dex/file/DebugInfoDecoder.java
@@ -16,26 +16,36 @@
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:
diff --git a/dx/src/com/android/dx/dex/file/DebugInfoEncoder.java b/dx/src/com/android/dx/dex/file/DebugInfoEncoder.java
index ae87fc375..9f57b6b64 100644
--- a/dx/src/com/android/dx/dex/file/DebugInfoEncoder.java
+++ b/dx/src/com/android/dx/dex/file/DebugInfoEncoder.java
@@ -16,28 +16,36 @@
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
diff --git a/dx/src/com/android/dx/dex/file/DebugInfoItem.java b/dx/src/com/android/dx/dex/file/DebugInfoItem.java
index 09b27128e..2fd864a33 100644
--- a/dx/src/com/android/dx/dex/file/DebugInfoItem.java
+++ b/dx/src/com/android/dx/dex/file/DebugInfoItem.java
@@ -16,14 +16,13 @@
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 {
diff --git a/dx/src/com/android/dx/dex/file/DexFile.java b/dx/src/com/android/dx/dex/file/DexFile.java
index 6a9882c9a..0d5b110ef 100644
--- a/dx/src/com/android/dx/dex/file/DexFile.java
+++ b/dx/src/com/android/dx/dex/file/DexFile.java
@@ -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.
diff --git a/dx/src/com/android/dx/dex/file/EncodedArrayItem.java b/dx/src/com/android/dx/dex/file/EncodedArrayItem.java
index 3d05ab3b6..12d4b1736 100644
--- a/dx/src/com/android/dx/dex/file/EncodedArrayItem.java
+++ b/dx/src/com/android/dx/dex/file/EncodedArrayItem.java
@@ -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.
diff --git a/dx/src/com/android/dx/dex/file/EncodedField.java b/dx/src/com/android/dx/dex/file/EncodedField.java
index fdfa5d291..317c97961 100644
--- a/dx/src/com/android/dx/dex/file/EncodedField.java
+++ b/dx/src/com/android/dx/dex/file/EncodedField.java
@@ -16,13 +16,12 @@
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));
}
diff --git a/dx/src/com/android/dx/dex/file/EncodedMember.java b/dx/src/com/android/dx/dex/file/EncodedMember.java
index 627764697..a681d822c 100644
--- a/dx/src/com/android/dx/dex/file/EncodedMember.java
+++ b/dx/src/com/android/dx/dex/file/EncodedMember.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/EncodedMethod.java b/dx/src/com/android/dx/dex/file/EncodedMethod.java
index c3f71b7a4..0a177e650 100644
--- a/dx/src/com/android/dx/dex/file/EncodedMethod.java
+++ b/dx/src/com/android/dx/dex/file/EncodedMethod.java
@@ -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));
}
diff --git a/dx/src/com/android/dx/dex/file/FieldIdsSection.java b/dx/src/com/android/dx/dex/file/FieldIdsSection.java
index c3207311f..27d946d64 100644
--- a/dx/src/com/android/dx/dex/file/FieldIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/FieldIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/HeaderItem.java b/dx/src/com/android/dx/dex/file/HeaderItem.java
index 3816eb883..f404c3e8a 100644
--- a/dx/src/com/android/dx/dex/file/HeaderItem.java
+++ b/dx/src/com/android/dx/dex/file/HeaderItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/HeaderSection.java b/dx/src/com/android/dx/dex/file/HeaderSection.java
index 21da4881a..e3de356b6 100644
--- a/dx/src/com/android/dx/dex/file/HeaderSection.java
+++ b/dx/src/com/android/dx/dex/file/HeaderSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/MapItem.java b/dx/src/com/android/dx/dex/file/MapItem.java
index d78dc9197..f68cd9422 100644
--- a/dx/src/com/android/dx/dex/file/MapItem.java
+++ b/dx/src/com/android/dx/dex/file/MapItem.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/MemberIdItem.java b/dx/src/com/android/dx/dex/file/MemberIdItem.java
index 08a31230f..ffe4c6c95 100644
--- a/dx/src/com/android/dx/dex/file/MemberIdItem.java
+++ b/dx/src/com/android/dx/dex/file/MemberIdItem.java
@@ -16,11 +16,11 @@
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
diff --git a/dx/src/com/android/dx/dex/file/MemberIdsSection.java b/dx/src/com/android/dx/dex/file/MemberIdsSection.java
index ee844d9de..9f82f410c 100644
--- a/dx/src/com/android/dx/dex/file/MemberIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/MemberIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/MethodIdsSection.java b/dx/src/com/android/dx/dex/file/MethodIdsSection.java
index fa0cd3c25..d99198b24 100644
--- a/dx/src/com/android/dx/dex/file/MethodIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/MethodIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/MixedItemSection.java b/dx/src/com/android/dx/dex/file/MixedItemSection.java
index b88530671..4edc6b62f 100644
--- a/dx/src/com/android/dx/dex/file/MixedItemSection.java
+++ b/dx/src/com/android/dx/dex/file/MixedItemSection.java
@@ -16,10 +16,9 @@
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;
diff --git a/dx/src/com/android/dx/dex/file/OffsettedItem.java b/dx/src/com/android/dx/dex/file/OffsettedItem.java
index 772147066..02787f90f 100644
--- a/dx/src/com/android/dx/dex/file/OffsettedItem.java
+++ b/dx/src/com/android/dx/dex/file/OffsettedItem.java
@@ -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.
diff --git a/dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java b/dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java
index 078c21986..1fc4365ce 100644
--- a/dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java
+++ b/dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/ProtoIdItem.java b/dx/src/com/android/dx/dex/file/ProtoIdItem.java
index 235a8c830..19eb3d27d 100644
--- a/dx/src/com/android/dx/dex/file/ProtoIdItem.java
+++ b/dx/src/com/android/dx/dex/file/ProtoIdItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/ProtoIdsSection.java b/dx/src/com/android/dx/dex/file/ProtoIdsSection.java
index dc6e8ad98..4b1303b15 100644
--- a/dx/src/com/android/dx/dex/file/ProtoIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/ProtoIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/Section.java b/dx/src/com/android/dx/dex/file/Section.java
index 3f04216a9..bde714c46 100644
--- a/dx/src/com/android/dx/dex/file/Section.java
+++ b/dx/src/com/android/dx/dex/file/Section.java
@@ -17,7 +17,6 @@
package com.android.dx.dex.file;
import com.android.dx.util.AnnotatedOutput;
-
import java.util.Collection;
/**
diff --git a/dx/src/com/android/dx/dex/file/Statistics.java b/dx/src/com/android/dx/dex/file/Statistics.java
index 62e183286..42f5b490e 100644
--- a/dx/src/com/android/dx/dex/file/Statistics.java
+++ b/dx/src/com/android/dx/dex/file/Statistics.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/StringDataItem.java b/dx/src/com/android/dx/dex/file/StringDataItem.java
index e85a823bd..38be34492 100644
--- a/dx/src/com/android/dx/dex/file/StringDataItem.java
+++ b/dx/src/com/android/dx/dex/file/StringDataItem.java
@@ -16,11 +16,11 @@
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());
}
diff --git a/dx/src/com/android/dx/dex/file/StringIdItem.java b/dx/src/com/android/dx/dex/file/StringIdItem.java
index 533427d5e..b3e7d02ab 100644
--- a/dx/src/com/android/dx/dex/file/StringIdItem.java
+++ b/dx/src/com/android/dx/dex/file/StringIdItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/StringIdsSection.java b/dx/src/com/android/dx/dex/file/StringIdsSection.java
index 2f7c40b37..7aff82ea9 100644
--- a/dx/src/com/android/dx/dex/file/StringIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/StringIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/TypeIdItem.java b/dx/src/com/android/dx/dex/file/TypeIdItem.java
index 04be2a1a6..e585f1f69 100644
--- a/dx/src/com/android/dx/dex/file/TypeIdItem.java
+++ b/dx/src/com/android/dx/dex/file/TypeIdItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/TypeIdsSection.java b/dx/src/com/android/dx/dex/file/TypeIdsSection.java
index bcc825027..1df4b4657 100644
--- a/dx/src/com/android/dx/dex/file/TypeIdsSection.java
+++ b/dx/src/com/android/dx/dex/file/TypeIdsSection.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/TypeListItem.java b/dx/src/com/android/dx/dex/file/TypeListItem.java
index b815dd347..1f9b6a8ef 100644
--- a/dx/src/com/android/dx/dex/file/TypeListItem.java
+++ b/dx/src/com/android/dx/dex/file/TypeListItem.java
@@ -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;
diff --git a/dx/src/com/android/dx/dex/file/UniformItemSection.java b/dx/src/com/android/dx/dex/file/UniformItemSection.java
index d8c09ab26..ade268fa8 100644
--- a/dx/src/com/android/dx/dex/file/UniformItemSection.java
+++ b/dx/src/com/android/dx/dex/file/UniformItemSection.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/UniformListItem.java b/dx/src/com/android/dx/dex/file/UniformListItem.java
index 88919c7cb..0196ca19c 100644
--- a/dx/src/com/android/dx/dex/file/UniformListItem.java
+++ b/dx/src/com/android/dx/dex/file/UniformListItem.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/dex/file/ValueEncoder.java b/dx/src/com/android/dx/dex/file/ValueEncoder.java
index aafb42945..fa807a7e4 100644
--- a/dx/src/com/android/dx/dex/file/ValueEncoder.java
+++ b/dx/src/com/android/dx/dex/file/ValueEncoder.java
@@ -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: {
diff --git a/dx/src/com/android/dx/io/CodeReader.java b/dx/src/com/android/dx/io/CodeReader.java
index cab106332..5fd5cf696 100644
--- a/dx/src/com/android/dx/io/CodeReader.java
+++ b/dx/src/com/android/dx/io/CodeReader.java
@@ -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.
diff --git a/dx/src/com/android/dx/io/DexHasher.java b/dx/src/com/android/dx/io/DexHasher.java
index 416b3e28c..425925957 100644
--- a/dx/src/com/android/dx/io/DexHasher.java
+++ b/dx/src/com/android/dx/io/DexHasher.java
@@ -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);
diff --git a/dx/src/com/android/dx/io/DexIndexPrinter.java b/dx/src/com/android/dx/io/DexIndexPrinter.java
index 85c201512..2b89d44e7 100644
--- a/dx/src/com/android/dx/io/DexIndexPrinter.java
+++ b/dx/src/com/android/dx/io/DexIndexPrinter.java
@@ -16,7 +16,12 @@
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++;
}
diff --git a/dx/src/com/android/dx/io/instructions/AddressMap.java b/dx/src/com/android/dx/io/instructions/AddressMap.java
index a8dbe0bab..953bdc915 100644
--- a/dx/src/com/android/dx/io/instructions/AddressMap.java
+++ b/dx/src/com/android/dx/io/instructions/AddressMap.java
@@ -16,7 +16,6 @@
package com.android.dx.io.instructions;
-import java.io.EOFException;
import java.util.HashMap;
/**
diff --git a/dx/src/com/android/dx/io/instructions/BaseCodeCursor.java b/dx/src/com/android/dx/io/instructions/BaseCodeCursor.java
index 6915fa881..5cf11420d 100644
--- a/dx/src/com/android/dx/io/instructions/BaseCodeCursor.java
+++ b/dx/src/com/android/dx/io/instructions/BaseCodeCursor.java
@@ -16,8 +16,6 @@
package com.android.dx.io.instructions;
-import java.io.EOFException;
-
/**
* Base implementation of {@link CodeCursor}.
*/
diff --git a/dx/src/com/android/dx/io/instructions/DecodedInstruction.java b/dx/src/com/android/dx/io/instructions/DecodedInstruction.java
index a8bc8592e..e5b70734e 100644
--- a/dx/src/com/android/dx/io/instructions/DecodedInstruction.java
+++ b/dx/src/com/android/dx/io/instructions/DecodedInstruction.java
@@ -16,10 +16,10 @@
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;
diff --git a/dx/src/com/android/dx/io/instructions/InstructionCodec.java b/dx/src/com/android/dx/io/instructions/InstructionCodec.java
index 2e803ed6b..228352f58 100644
--- a/dx/src/com/android/dx/io/instructions/InstructionCodec.java
+++ b/dx/src/com/android/dx/io/instructions/InstructionCodec.java
@@ -16,12 +16,11 @@
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;
/**
diff --git a/dx/src/com/android/dx/merge/DexMerger.java b/dx/src/com/android/dx/merge/DexMerger.java
index 319153f39..329920e31 100644
--- a/dx/src/com/android/dx/merge/DexMerger.java
+++ b/dx/src/com/android/dx/merge/DexMerger.java
@@ -16,18 +16,19 @@
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]));
}
diff --git a/dx/src/com/android/dx/merge/IndexMap.java b/dx/src/com/android/dx/merge/IndexMap.java
index 9d6ef7abb..739238a0a 100644
--- a/dx/src/com/android/dx/merge/IndexMap.java
+++ b/dx/src/com/android/dx/merge/IndexMap.java
@@ -16,36 +16,37 @@
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);
}
diff --git a/dx/src/com/android/dx/merge/InstructionTransformer.java b/dx/src/com/android/dx/merge/InstructionTransformer.java
index 6051e17d8..aa67a8815 100644
--- a/dx/src/com/android/dx/merge/InstructionTransformer.java
+++ b/dx/src/com/android/dx/merge/InstructionTransformer.java
@@ -16,11 +16,11 @@
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;
diff --git a/dx/src/com/android/dx/merge/SortableType.java b/dx/src/com/android/dx/merge/SortableType.java
index 838ea28aa..2ae68fb23 100644
--- a/dx/src/com/android/dx/merge/SortableType.java
+++ b/dx/src/com/android/dx/merge/SortableType.java
@@ -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() {
diff --git a/dx/src/com/android/dx/rop/annotation/Annotation.java b/dx/src/com/android/dx/rop/annotation/Annotation.java
index 8f9e9767e..e4af15df1 100644
--- a/dx/src/com/android/dx/rop/annotation/Annotation.java
+++ b/dx/src/com/android/dx/rop/annotation/Annotation.java
@@ -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;
diff --git a/dx/src/com/android/dx/rop/annotation/Annotations.java b/dx/src/com/android/dx/rop/annotation/Annotations.java
index 807d5d422..aea4f248e 100644
--- a/dx/src/com/android/dx/rop/annotation/Annotations.java
+++ b/dx/src/com/android/dx/rop/annotation/Annotations.java
@@ -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;
diff --git a/dx/src/com/android/dx/rop/code/FillArrayDataInsn.java b/dx/src/com/android/dx/rop/code/FillArrayDataInsn.java
index ed9345d4d..248c2a6a0 100644
--- a/dx/src/com/android/dx/rop/code/FillArrayDataInsn.java
+++ b/dx/src/com/android/dx/rop/code/FillArrayDataInsn.java
@@ -17,10 +17,9 @@
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;
/**
diff --git a/dx/src/com/android/dx/rop/code/LocalVariableInfo.java b/dx/src/com/android/dx/rop/code/LocalVariableInfo.java
index 5d2b99527..4376a2e6b 100644
--- a/dx/src/com/android/dx/rop/code/LocalVariableInfo.java
+++ b/dx/src/com/android/dx/rop/code/LocalVariableInfo.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/rop/code/PlainInsn.java b/dx/src/com/android/dx/rop/code/PlainInsn.java
index 3b52efa8e..8c7d5d573 100644
--- a/dx/src/com/android/dx/rop/code/PlainInsn.java
+++ b/dx/src/com/android/dx/rop/code/PlainInsn.java
@@ -16,12 +16,12 @@
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
diff --git a/dx/src/com/android/dx/rop/code/RegisterSpec.java b/dx/src/com/android/dx/rop/code/RegisterSpec.java
index e5f908b43..cb02ea9de 100644
--- a/dx/src/com/android/dx/rop/code/RegisterSpec.java
+++ b/dx/src/com/android/dx/rop/code/RegisterSpec.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/rop/code/RegisterSpecList.java b/dx/src/com/android/dx/rop/code/RegisterSpecList.java
index 3d891fd88..7448d3df0 100644
--- a/dx/src/com/android/dx/rop/code/RegisterSpecList.java
+++ b/dx/src/com/android/dx/rop/code/RegisterSpecList.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/rop/code/RopMethod.java b/dx/src/com/android/dx/rop/code/RopMethod.java
index 591d325f2..f1643c18a 100644
--- a/dx/src/com/android/dx/rop/code/RopMethod.java
+++ b/dx/src/com/android/dx/rop/code/RopMethod.java
@@ -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;
diff --git a/dx/src/com/android/dx/rop/cst/CstArray.java b/dx/src/com/android/dx/rop/cst/CstArray.java
index 2766b5f1e..5644b2fe0 100644
--- a/dx/src/com/android/dx/rop/cst/CstArray.java
+++ b/dx/src/com/android/dx/rop/cst/CstArray.java
@@ -16,7 +16,6 @@
package com.android.dx.rop.cst;
-import com.android.dx.rop.type.Type;
import com.android.dx.util.FixedSizeList;
/**
diff --git a/dx/src/com/android/dx/rop/cst/StdConstantPool.java b/dx/src/com/android/dx/rop/cst/StdConstantPool.java
index 244395d8a..bb975e498 100644
--- a/dx/src/com/android/dx/rop/cst/StdConstantPool.java
+++ b/dx/src/com/android/dx/rop/cst/StdConstantPool.java
@@ -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;
diff --git a/dx/src/com/android/dx/rop/type/Type.java b/dx/src/com/android/dx/rop/type/Type.java
index c564fab16..4bf29ba4e 100644
--- a/dx/src/com/android/dx/rop/type/Type.java
+++ b/dx/src/com/android/dx/rop/type/Type.java
@@ -17,7 +17,6 @@
package com.android.dx.rop.type;
import com.android.dx.util.Hex;
-
import java.util.HashMap;
/**
diff --git a/dx/src/com/android/dx/ssa/BasicRegisterMapper.java b/dx/src/com/android/dx/ssa/BasicRegisterMapper.java
index 83045b234..45e93c347 100644
--- a/dx/src/com/android/dx/ssa/BasicRegisterMapper.java
+++ b/dx/src/com/android/dx/ssa/BasicRegisterMapper.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/ssa/DeadCodeRemover.java b/dx/src/com/android/dx/ssa/DeadCodeRemover.java
index 07fb553ae..4a2f59d04 100644
--- a/dx/src/com/android/dx/ssa/DeadCodeRemover.java
+++ b/dx/src/com/android/dx/ssa/DeadCodeRemover.java
@@ -16,15 +16,8 @@
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;
diff --git a/dx/src/com/android/dx/ssa/DomFront.java b/dx/src/com/android/dx/ssa/DomFront.java
index 941a317ce..c3e65ac94 100644
--- a/dx/src/com/android/dx/ssa/DomFront.java
+++ b/dx/src/com/android/dx/ssa/DomFront.java
@@ -17,11 +17,7 @@
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;
/**
diff --git a/dx/src/com/android/dx/ssa/EscapeAnalysis.java b/dx/src/com/android/dx/ssa/EscapeAnalysis.java
index b02c9297f..8533de834 100644
--- a/dx/src/com/android/dx/ssa/EscapeAnalysis.java
+++ b/dx/src/com/android/dx/ssa/EscapeAnalysis.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java b/dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java
index 851249ba3..446888dca 100644
--- a/dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java
+++ b/dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java
@@ -16,14 +16,12 @@
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
diff --git a/dx/src/com/android/dx/ssa/LiteralOpUpgrader.java b/dx/src/com/android/dx/ssa/LiteralOpUpgrader.java
index f3976f2d9..ad017e23c 100644
--- a/dx/src/com/android/dx/ssa/LiteralOpUpgrader.java
+++ b/dx/src/com/android/dx/ssa/LiteralOpUpgrader.java
@@ -16,20 +16,19 @@
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;
diff --git a/dx/src/com/android/dx/ssa/LocalVariableExtractor.java b/dx/src/com/android/dx/ssa/LocalVariableExtractor.java
index 11d53cf2a..b86bed67f 100644
--- a/dx/src/com/android/dx/ssa/LocalVariableExtractor.java
+++ b/dx/src/com/android/dx/ssa/LocalVariableExtractor.java
@@ -16,10 +16,9 @@
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;
diff --git a/dx/src/com/android/dx/ssa/LocalVariableInfo.java b/dx/src/com/android/dx/ssa/LocalVariableInfo.java
index 8845270c3..152053187 100644
--- a/dx/src/com/android/dx/ssa/LocalVariableInfo.java
+++ b/dx/src/com/android/dx/ssa/LocalVariableInfo.java
@@ -16,10 +16,9 @@
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;
diff --git a/dx/src/com/android/dx/ssa/MoveParamCombiner.java b/dx/src/com/android/dx/ssa/MoveParamCombiner.java
index 41660d203..fe3ac9722 100644
--- a/dx/src/com/android/dx/ssa/MoveParamCombiner.java
+++ b/dx/src/com/android/dx/ssa/MoveParamCombiner.java
@@ -16,14 +16,12 @@
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;
/**
diff --git a/dx/src/com/android/dx/ssa/NormalSsaInsn.java b/dx/src/com/android/dx/ssa/NormalSsaInsn.java
index cfef40083..61c12e54c 100644
--- a/dx/src/com/android/dx/ssa/NormalSsaInsn.java
+++ b/dx/src/com/android/dx/ssa/NormalSsaInsn.java
@@ -16,7 +16,12 @@
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.
diff --git a/dx/src/com/android/dx/ssa/Optimizer.java b/dx/src/com/android/dx/ssa/Optimizer.java
index 42ae16697..8c2e284c2 100644
--- a/dx/src/com/android/dx/ssa/Optimizer.java
+++ b/dx/src/com/android/dx/ssa/Optimizer.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/ssa/PhiInsn.java b/dx/src/com/android/dx/ssa/PhiInsn.java
index bc9c4b0d4..0a398642c 100644
--- a/dx/src/com/android/dx/ssa/PhiInsn.java
+++ b/dx/src/com/android/dx/ssa/PhiInsn.java
@@ -16,11 +16,15 @@
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;
diff --git a/dx/src/com/android/dx/ssa/PhiTypeResolver.java b/dx/src/com/android/dx/ssa/PhiTypeResolver.java
index 4b8b4e3a6..1b2ce9fe5 100644
--- a/dx/src/com/android/dx/ssa/PhiTypeResolver.java
+++ b/dx/src/com/android/dx/ssa/PhiTypeResolver.java
@@ -17,12 +17,11 @@
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;
diff --git a/dx/src/com/android/dx/ssa/RegisterMapper.java b/dx/src/com/android/dx/ssa/RegisterMapper.java
index bef941f31..3099000a7 100644
--- a/dx/src/com/android/dx/ssa/RegisterMapper.java
+++ b/dx/src/com/android/dx/ssa/RegisterMapper.java
@@ -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.
diff --git a/dx/src/com/android/dx/ssa/SCCP.java b/dx/src/com/android/dx/ssa/SCCP.java
index 1c869e160..a6dee340c 100644
--- a/dx/src/com/android/dx/ssa/SCCP.java
+++ b/dx/src/com/android/dx/ssa/SCCP.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/SsaBasicBlock.java b/dx/src/com/android/dx/ssa/SsaBasicBlock.java
index 499f59fe5..56d8c8cd1 100644
--- a/dx/src/com/android/dx/ssa/SsaBasicBlock.java
+++ b/dx/src/com/android/dx/ssa/SsaBasicBlock.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/SsaConverter.java b/dx/src/com/android/dx/ssa/SsaConverter.java
index 5cd8b6f56..1fd6f7825 100644
--- a/dx/src/com/android/dx/ssa/SsaConverter.java
+++ b/dx/src/com/android/dx/ssa/SsaConverter.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/SsaInsn.java b/dx/src/com/android/dx/ssa/SsaInsn.java
index ca7a1a2f1..fb82f2d61 100644
--- a/dx/src/com/android/dx/ssa/SsaInsn.java
+++ b/dx/src/com/android/dx/ssa/SsaInsn.java
@@ -16,7 +16,11 @@
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;
/**
diff --git a/dx/src/com/android/dx/ssa/SsaMethod.java b/dx/src/com/android/dx/ssa/SsaMethod.java
index 4c2bd8503..7d7b565ca 100644
--- a/dx/src/com/android/dx/ssa/SsaMethod.java
+++ b/dx/src/com/android/dx/ssa/SsaMethod.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/SsaRenamer.java b/dx/src/com/android/dx/ssa/SsaRenamer.java
index 58e414265..66391a05d 100644
--- a/dx/src/com/android/dx/ssa/SsaRenamer.java
+++ b/dx/src/com/android/dx/ssa/SsaRenamer.java
@@ -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;
diff --git a/dx/src/com/android/dx/ssa/back/FirstFitAllocator.java b/dx/src/com/android/dx/ssa/back/FirstFitAllocator.java
index 6416e84e8..a9043c283 100644
--- a/dx/src/com/android/dx/ssa/back/FirstFitAllocator.java
+++ b/dx/src/com/android/dx/ssa/back/FirstFitAllocator.java
@@ -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.
diff --git a/dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java b/dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java
index 9ef95a7fd..743955ecd 100644
--- a/dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java
+++ b/dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java
@@ -16,19 +16,23 @@
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;
diff --git a/dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java b/dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java
index 515b04f0a..b2be1dd0c 100644
--- a/dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java
+++ b/dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java
@@ -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;
/**
diff --git a/dx/src/com/android/dx/ssa/back/InterferenceGraph.java b/dx/src/com/android/dx/ssa/back/InterferenceGraph.java
index e6cde622a..5ed2f820b 100644
--- a/dx/src/com/android/dx/ssa/back/InterferenceGraph.java
+++ b/dx/src/com/android/dx/ssa/back/InterferenceGraph.java
@@ -16,18 +16,8 @@
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;
/**
diff --git a/dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java b/dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java
index a293e6f4a..0ea195af9 100644
--- a/dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java
+++ b/dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java
@@ -16,15 +16,14 @@
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
diff --git a/dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java b/dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java
index 0205c11f9..adacdda98 100644
--- a/dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java
+++ b/dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java
@@ -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
diff --git a/dx/src/com/android/dx/ssa/back/RegisterAllocator.java b/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
index 1f9f70f7c..9d5379809 100644
--- a/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
+++ b/dx/src/com/android/dx/ssa/back/RegisterAllocator.java
@@ -16,21 +16,19 @@
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;
/**
diff --git a/dx/src/com/android/dx/ssa/back/SsaToRop.java b/dx/src/com/android/dx/ssa/back/SsaToRop.java
index 0e30250b1..401c67f12 100644
--- a/dx/src/com/android/dx/ssa/back/SsaToRop.java
+++ b/dx/src/com/android/dx/ssa/back/SsaToRop.java
@@ -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;
diff --git a/dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java b/dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java
index 05ec733f8..187d88656 100644
--- a/dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java
+++ b/dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java
@@ -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);
}
diff --git a/dx/src/com/android/dx/util/MutabilityException.java b/dx/src/com/android/dx/util/MutabilityException.java
index bd21651b2..6e029df0d 100644
--- a/dx/src/com/android/dx/util/MutabilityException.java
+++ b/dx/src/com/android/dx/util/MutabilityException.java
@@ -16,6 +16,8 @@
package com.android.dx.util;
+import com.android.dex.util.ExceptionWithContext;
+
/**
* Exception due to a mutability problem.
*/
diff --git a/dx/src/com/android/dx/util/Output.java b/dx/src/com/android/dx/util/Output.java
index e5956a25a..8ddec2ed9 100644
--- a/dx/src/com/android/dx/util/Output.java
+++ b/dx/src/com/android/dx/util/Output.java
@@ -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
index 039756a49..000000000
--- a/dx/src/com/android/dx/util/Uint.java
+++ /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);
- }
-}
diff --git a/dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java b/dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java
index c6ffbdce5..f51e2516a 100644
--- a/dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java
+++ b/dx/tests/115-merge/com/android/dx/merge/DexMergeTest.java
@@ -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 {
diff --git a/dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java b/dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java
index dbc0ea37b..13d0cb820 100644
--- a/dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java
+++ b/dx/tests/116-leb128/com/android/dx/util/Leb128UtilsTest.java
@@ -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();
}
diff --git a/dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java b/dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java
index 8e6188db0..db92a9637 100644
--- a/dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java
+++ b/dx/tests/117-modified-utf8/com/android/dx/util/Mutf8Test.java
@@ -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;
diff --git a/dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java b/dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java
index 421d33204..0248e9677 100644
--- a/dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java
+++ b/dx/tests/119-merge-conflict/com/android/dx/merge/MergeConflictTest.java
@@ -16,19 +16,19 @@
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));
}
}