diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/ClassSection.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/ClassSection.java index ca9f710c..628bf9cc 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/ClassSection.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/ClassSection.java @@ -34,6 +34,7 @@ package org.jf.dexlib2.writer; import org.jf.dexlib2.iface.ExceptionHandler; import org.jf.dexlib2.iface.TryBlock; import org.jf.dexlib2.iface.debug.DebugItem; +import org.jf.dexlib2.iface.instruction.Instruction; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,7 +44,7 @@ import java.util.List; import java.util.Map; public interface ClassSection extends IndexSection { + FieldKey, MethodKey, AnnotationSetKey, EncodedValue> extends IndexSection { @Nonnull Collection getSortedClasses(); @Nullable Map.Entry getClassEntryByType(@Nullable TypeKey key); @@ -74,7 +75,7 @@ public interface ClassSection getParameterNames(@Nonnull MethodKey key); int getRegisterCount(@Nonnull MethodKey key); - @Nullable Iterable getInstructions(@Nonnull MethodKey key); + @Nullable Iterable getInstructions(@Nonnull MethodKey key); @Nonnull List> getTryBlocks(@Nonnull MethodKey key); @Nullable TypeKey getExceptionType(@Nonnull ExceptionHandler handler); diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java index e46e5f11..34d9fbc5 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java @@ -117,7 +117,7 @@ public abstract class DexWriter< protected final FieldSection fieldSection; protected final MethodSection methodSection; protected final ClassSection classSection; + EncodedValue> classSection; protected final TypeListSection typeListSection; protected final AnnotationSection annotationSection; @@ -131,7 +131,7 @@ public abstract class DexWriter< FieldSection fieldSection, MethodSection methodSection, ClassSection classSection, + EncodedValue> classSection, TypeListSection typeListSection, AnnotationSection annotationSection, @@ -789,7 +789,7 @@ public abstract class DexWriter< Iterable methods = Iterables.concat(directMethods, virtualMethods); for (MethodKey methodKey: methods) { - Iterable instructions = classSection.getInstructions(methodKey); + Iterable instructions = classSection.getInstructions(methodKey); int debugItemOffset = classSection.getDebugItemOffset(methodKey); if (instructions == null && debugItemOffset == NO_OFFSET) { @@ -813,8 +813,8 @@ public abstract class DexWriter< if (instructions != null) { tryBlocks = TryListBuilder.massageTryBlocks(tryBlocks); - InstructionWriteUtil instrWriteUtil = - new InstructionWriteUtil(instructions, stringSection, instructionFactory); + InstructionWriteUtil instrWriteUtil = + new InstructionWriteUtil(instructions, stringSection, instructionFactory); writer.writeUshort(instrWriteUtil.getOutParamCount()); writer.writeUshort(tryBlocks.size()); writer.writeInt(debugItemOffset); @@ -824,7 +824,7 @@ public abstract class DexWriter< methodSection); writer.writeInt(instrWriteUtil.getCodeUnitCount()); - for (Insn instruction: instrWriteUtil.getInstructions()) { + for (Instruction instruction: instrWriteUtil.getInstructions()) { switch (instruction.getOpcode().format) { case Format10t: instructionWriter.write((Instruction10t)instruction); diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassPool.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassPool.java index 5f8b3e38..0a4563a1 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassPool.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassPool.java @@ -58,7 +58,7 @@ import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; public class BuilderClassPool implements ClassSection { + BuilderClassDef, BuilderField, BuilderMethod, BuilderAnnotationSet, BuilderEncodedValue> { @Nonnull private final ConcurrentMap internedItems = Maps.newConcurrentMap(); diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ClassPool.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ClassPool.java index 06a46d32..e3b1bbbb 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ClassPool.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ClassPool.java @@ -60,7 +60,7 @@ import java.util.Map.Entry; public class ClassPool implements ClassSection>, PoolClassDef, Field, PoolMethod, Set, - EncodedValue, Instruction> { + EncodedValue> { @Nonnull private HashMap internedItems = Maps.newHashMap(); @Nonnull private final StringPool stringPool; diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/util/InstructionWriteUtil.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/util/InstructionWriteUtil.java index 9a9d417f..3d34846f 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/util/InstructionWriteUtil.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/util/InstructionWriteUtil.java @@ -53,13 +53,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class InstructionWriteUtil { private final StringIndexProvider stringIndexProvider; - private final InstructionFactory instructionFactory; - private final Iterable originalInstructions; + private final InstructionFactory instructionFactory; + private final Iterable originalInstructions; - private List instructions; + private List instructions; private ArrayList codeOffsetShifts; private HashMap offsetToNewInstructionMap; @@ -70,9 +70,9 @@ public class InstructionWriteUtil instructions, + public InstructionWriteUtil(@Nonnull Iterable instructions, @Nonnull StringIndexProvider stringIndexProvider, - @Nonnull InstructionFactory instructionFactory) { + @Nonnull InstructionFactory instructionFactory) { this.stringIndexProvider = stringIndexProvider; this.instructionFactory = instructionFactory; this.originalInstructions = instructions; @@ -82,7 +82,7 @@ public class InstructionWriteUtil getInstructions() { + public Iterable getInstructions() { if (instructions != null) { return instructions; } else { @@ -228,8 +228,8 @@ public class InstructionWriteUtil mJumboStrings; - private class InsnWriteUtil extends InstructionWriteUtil { + private class InsnWriteUtil extends InstructionWriteUtil { public InsnWriteUtil(@Nonnull MethodImplementation implementation) { super(implementation.getInstructions(), mockStringIndexProvider, ImmutableInstructionFactory.INSTANCE); } diff --git a/dexlib2/src/test/java/org/jf/dexlib2/writer/PayloadAlignmentTest.java b/dexlib2/src/test/java/org/jf/dexlib2/writer/PayloadAlignmentTest.java index fe25f42b..363f507a 100644 --- a/dexlib2/src/test/java/org/jf/dexlib2/writer/PayloadAlignmentTest.java +++ b/dexlib2/src/test/java/org/jf/dexlib2/writer/PayloadAlignmentTest.java @@ -51,7 +51,7 @@ import java.util.ArrayList; public class PayloadAlignmentTest { private MockStringIndexProvider mockStringIndexProvider; - private class InsnWriteUtil extends InstructionWriteUtil { + private class InsnWriteUtil extends InstructionWriteUtil { public InsnWriteUtil(@Nonnull MethodImplementation implementation) { super(implementation.getInstructions(), mockStringIndexProvider, ImmutableInstructionFactory.INSTANCE); }