Simply the generic-ity around Instruction, OffsetInstruction and InstructionMethodItem
diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java
index c38b524..772d731 100644
--- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java
+++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java
@@ -38,13 +38,11 @@
private InstructionMethodItemFactory() {
}
- public static InstructionMethodItem makeInstructionFormatMethodItem(MethodDefinition methodDefinition,
- CodeItem codeItem,
- int codeAddress,
- Instruction instruction) {
+ public static InstructionMethodItem makeInstructionFormatMethodItem(
+ MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress, Instruction instruction) {
if (instruction instanceof OffsetInstruction) {
- return new OffsetInstructionFormatMethodItem(methodDefinition.getLabelCache(), codeItem, codeAddress,
- instruction);
+ return new OffsetInstructionFormatMethodItem(methodDefinition.getLabelCache(), codeItem,
+ codeAddress, (OffsetInstruction)instruction);
}
switch (instruction.getFormat()) {
@@ -61,7 +59,7 @@
return new UnresolvedOdexInstructionMethodItem(codeItem, codeAddress,
(UnresolvedOdexInstruction)instruction);
default:
- return new InstructionMethodItem(codeItem, codeAddress, instruction);
+ return new InstructionMethodItem<Instruction>(codeItem, codeAddress, instruction);
}
}
}
diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java
index d63e43b..d4edf3d 100644
--- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java
+++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java
@@ -31,19 +31,17 @@
import org.jf.baksmali.Adaptors.LabelMethodItem;
import org.jf.baksmali.Adaptors.MethodDefinition;
import org.jf.util.IndentingWriter;
-import org.jf.dexlib.Code.Instruction;
import org.jf.dexlib.Code.OffsetInstruction;
import org.jf.dexlib.Code.Opcode;
import org.jf.dexlib.CodeItem;
import java.io.IOException;
-public class OffsetInstructionFormatMethodItem<T extends Instruction & OffsetInstruction>
- extends InstructionMethodItem<T> {
+public class OffsetInstructionFormatMethodItem extends InstructionMethodItem<OffsetInstruction> {
protected LabelMethodItem label;
public OffsetInstructionFormatMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress,
- T instruction) {
+ OffsetInstruction instruction) {
super(codeItem, codeAddress, instruction);
label = new LabelMethodItem(codeAddress + instruction.getTargetAddressOffset(), getLabelPrefix());
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction10t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction10t.java
index 9947a10..4b7f872 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction10t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction10t.java
@@ -34,7 +34,7 @@
import org.jf.dexlib.DexFile;
import org.jf.dexlib.Util.AnnotatedOutput;
-public class Instruction10t extends Instruction implements OffsetInstruction {
+public class Instruction10t extends OffsetInstruction {
public static final InstructionFactory Factory = new Factory();
private int targetAddressOffset;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction20t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction20t.java
index a92e1a8..f970cfb 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction20t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction20t.java
@@ -35,7 +35,7 @@
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.NumberUtils;
-public class Instruction20t extends Instruction implements OffsetInstruction {
+public class Instruction20t extends OffsetInstruction {
public static final InstructionFactory Factory = new Factory();
private int targetAddressOffset;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21t.java
index 4a839d5..f1cd7d2 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21t.java
@@ -36,7 +36,7 @@
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.NumberUtils;
-public class Instruction21t extends Instruction implements OffsetInstruction, SingleRegisterInstruction {
+public class Instruction21t extends OffsetInstruction implements SingleRegisterInstruction {
public static final Instruction.InstructionFactory Factory = new Factory();
private byte regA;
private short targetAddressOffset;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22t.java
index d5b3a73..56b8298 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22t.java
@@ -36,7 +36,7 @@
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.NumberUtils;
-public class Instruction22t extends Instruction implements OffsetInstruction, TwoRegisterInstruction {
+public class Instruction22t extends OffsetInstruction implements TwoRegisterInstruction {
public static final Instruction.InstructionFactory Factory = new Factory();
private byte regA;
private byte regB;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction30t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction30t.java
index 7a97903..fc83b22 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction30t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction30t.java
@@ -35,7 +35,7 @@
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.NumberUtils;
-public class Instruction30t extends Instruction implements OffsetInstruction {
+public class Instruction30t extends OffsetInstruction {
public static final InstructionFactory Factory = new Factory();
private int targetAddressOffset;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction31t.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction31t.java
index 52d6ce6..55bcc6b 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction31t.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction31t.java
@@ -36,7 +36,7 @@
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.NumberUtils;
-public class Instruction31t extends Instruction implements OffsetInstruction, SingleRegisterInstruction {
+public class Instruction31t extends OffsetInstruction implements SingleRegisterInstruction {
public static final Instruction.InstructionFactory Factory = new Factory();
private byte regA;
private int targetAddressOffset;
diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/OffsetInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/OffsetInstruction.java
index 7ab366a..d0589c7 100644
--- a/dexlib/src/main/java/org/jf/dexlib/Code/OffsetInstruction.java
+++ b/dexlib/src/main/java/org/jf/dexlib/Code/OffsetInstruction.java
@@ -28,7 +28,11 @@
package org.jf.dexlib.Code;
-public interface OffsetInstruction {
- public int getTargetAddressOffset();
- public void updateTargetAddressOffset(int targetAddressOffset);
+public abstract class OffsetInstruction extends Instruction {
+ protected OffsetInstruction(Opcode opcode) {
+ super(opcode);
+ }
+
+ public abstract int getTargetAddressOffset();
+ public abstract void updateTargetAddressOffset(int targetAddressOffset);
}