diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java index 1760a738..44d37836 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java @@ -37,7 +37,8 @@ import org.jf.dexlib.Item; import org.jf.dexlib.TypeIdItem; import org.jf.dexlib.Util.AnnotatedOutput; -public class Instruction21c extends InstructionWithReference implements SingleRegisterInstruction { +public class Instruction21c extends InstructionWithReference implements SingleRegisterInstruction, + InstructionWithJumboVariant { public static final Instruction.InstructionFactory Factory = new Factory(); private byte regA; @@ -88,6 +89,19 @@ public class Instruction21c extends InstructionWithReference implements SingleRe return regA & 0xFF; } + public Instruction makeJumbo() { + Opcode jumboOpcode = opcode.getJumboOpcode(); + if (jumboOpcode == null) { + return null; + } + + if (jumboOpcode.format == Format.Format31c) { + return new Instruction31c(jumboOpcode, (short)getRegisterA(), getReferencedItem()); + } + + return new Instruction41c(jumboOpcode, getRegisterA(), getReferencedItem()); + } + private static class Factory implements Instruction.InstructionFactory { public Instruction makeInstruction(DexFile dexFile, Opcode opcode, byte[] buffer, int bufferIndex) { return new Instruction21c(dexFile, opcode, buffer, bufferIndex); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22c.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22c.java index 3ffb71c8..91662793 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22c.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction22c.java @@ -37,7 +37,8 @@ import org.jf.dexlib.Item; import org.jf.dexlib.Util.AnnotatedOutput; import org.jf.dexlib.Util.NumberUtils; -public class Instruction22c extends InstructionWithReference implements TwoRegisterInstruction { +public class Instruction22c extends InstructionWithReference implements TwoRegisterInstruction, + InstructionWithJumboVariant { public static final Instruction.InstructionFactory Factory = new Factory(); private byte regA; private byte regB; @@ -83,6 +84,15 @@ public class Instruction22c extends InstructionWithReference implements TwoRegis return regB; } + public Instruction makeJumbo() { + Opcode jumboOpcode = opcode.getJumboOpcode(); + if (jumboOpcode == null) { + return null; + } + + return new Instruction52c(jumboOpcode, getRegisterA(), getRegisterB(), getReferencedItem()); + } + private static class Factory implements Instruction.InstructionFactory { public Instruction makeInstruction(DexFile dexFile, Opcode opcode, byte[] buffer, int bufferIndex) { return new Instruction22c(dexFile, opcode, buffer, bufferIndex); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rc.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rc.java index 70b25ac3..057c9447 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rc.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rc.java @@ -41,7 +41,8 @@ import org.jf.dexlib.Util.NumberUtils; import static org.jf.dexlib.Code.Opcode.*; -public class Instruction3rc extends InstructionWithReference implements RegisterRangeInstruction { +public class Instruction3rc extends InstructionWithReference implements RegisterRangeInstruction, + InstructionWithJumboVariant { public static final Instruction.InstructionFactory Factory = new Factory(); private byte regCount; private short startReg; @@ -124,6 +125,15 @@ public class Instruction3rc extends InstructionWithReference implements Register } } + public Instruction makeJumbo() { + Opcode jumboOpcode = opcode.getJumboOpcode(); + if (jumboOpcode == null) { + return null; + } + + return new Instruction5rc(jumboOpcode, getRegCount(), getStartRegister(), getReferencedItem()); + } + private static class Factory implements Instruction.InstructionFactory { public Instruction makeInstruction(DexFile dexFile, Opcode opcode, byte[] buffer, int bufferIndex) { return new Instruction3rc(dexFile, opcode, buffer, bufferIndex); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/InstructionWithJumboVariant.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/InstructionWithJumboVariant.java new file mode 100644 index 00000000..9557e696 --- /dev/null +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/InstructionWithJumboVariant.java @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.dexlib.Code.Format; + +import org.jf.dexlib.Code.Instruction; + +public interface InstructionWithJumboVariant { + Instruction makeJumbo(); +} diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Opcode.java b/dexlib/src/main/java/org/jf/dexlib/Code/Opcode.java index 3fa18de1..d0259059 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Opcode.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Opcode.java @@ -60,18 +60,18 @@ public enum Opcode CONST_WIDE_32((short)0x17, "const-wide/32", ReferenceType.none, Format.Format31i, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), CONST_WIDE((short)0x18, "const-wide", ReferenceType.none, Format.Format51l, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), CONST_WIDE_HIGH16((short)0x19, "const-wide/high16", ReferenceType.none, Format.Format21h, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - CONST_STRING((short)0x1a, "const-string", ReferenceType.string, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), + CONST_STRING((short)0x1a, "const-string", ReferenceType.string, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0x1b), CONST_STRING_JUMBO((short)0x1b, "const-string/jumbo", ReferenceType.string, Format.Format31c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST_CLASS((short)0x1c, "const-class", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), + CONST_CLASS((short)0x1c, "const-class", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff00), MONITOR_ENTER((short)0x1d, "monitor-enter", ReferenceType.none, Format.Format11x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), MONITOR_EXIT((short)0x1e, "monitor-exit", ReferenceType.none, Format.Format11x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - CHECK_CAST((short)0x1f, "check-cast", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INSTANCE_OF((short)0x20, "instance-of", ReferenceType.type, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), + CHECK_CAST((short)0x1f, "check-cast", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff01), + INSTANCE_OF((short)0x20, "instance-of", ReferenceType.type, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff02), ARRAY_LENGTH((short)0x21, "array-length", ReferenceType.none, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEW_INSTANCE((short)0x22, "new-instance", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEW_ARRAY((short)0x23, "new-array", ReferenceType.type, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), + NEW_INSTANCE((short)0x22, "new-instance", ReferenceType.type, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff03), + NEW_ARRAY((short)0x23, "new-array", ReferenceType.type, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff04), FILLED_NEW_ARRAY((short)0x24, "filled-new-array", ReferenceType.type, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - FILLED_NEW_ARRAY_RANGE((short)0x25, "filled-new-array/range", ReferenceType.type, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), + FILLED_NEW_ARRAY_RANGE((short)0x25, "filled-new-array/range", ReferenceType.type, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff05), FILL_ARRAY_DATA((short)0x26, "fill-array-data", ReferenceType.none, Format.Format31t, Opcode.CAN_CONTINUE), THROW((short)0x27, "throw", ReferenceType.none, Format.Format11x, Opcode.CAN_THROW), GOTO((short)0x28, "goto", ReferenceType.none, Format.Format10t), @@ -110,44 +110,44 @@ public enum Opcode APUT_BYTE((short)0x4f, "aput-byte", ReferenceType.none, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), APUT_CHAR((short)0x50, "aput-char", ReferenceType.none, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), APUT_SHORT((short)0x51, "aput-short", ReferenceType.none, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IGET((short)0x52, "iget", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_WIDE((short)0x53, "iget-wide", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - IGET_OBJECT((short)0x54, "iget-object", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_BOOLEAN((short)0x55, "iget-boolean", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_BYTE((short)0x56, "iget-byte", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_CHAR((short)0x57, "iget-char", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_SHORT((short)0x58, "iget-short", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IPUT((short)0x59, "iput", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_WIDE((short)0x5a, "iput-wide", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_OBJECT((short)0x5b, "iput-object", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_BOOLEAN((short)0x5c, "iput-boolean", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_BYTE((short)0x5d, "iput-byte", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_CHAR((short)0x5e, "iput-char", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_SHORT((short)0x5f, "iput-short", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SGET((short)0x60, "sget", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_WIDE((short)0x61, "sget-wide", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SGET_OBJECT((short)0x62, "sget-object", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_BOOLEAN((short)0x63, "sget-boolean", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_BYTE((short)0x64, "sget-byte", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_CHAR((short)0x65, "sget-char", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_SHORT((short)0x66, "sget-short", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SPUT((short)0x67, "sput", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_WIDE((short)0x68, "sput-wide", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_OBJECT((short)0x69, "sput-object", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_BOOLEAN((short)0x6a, "sput-boolean", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_BYTE((short)0x6b, "sput-byte", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_CHAR((short)0x6c, "sput-char", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_SHORT((short)0x6d, "sput-short", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), + IGET((short)0x52, "iget", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff06), + IGET_WIDE((short)0x53, "iget-wide", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER, (short)0xff07), + IGET_OBJECT((short)0x54, "iget-object", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff08), + IGET_BOOLEAN((short)0x55, "iget-boolean", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff09), + IGET_BYTE((short)0x56, "iget-byte", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff0a), + IGET_CHAR((short)0x57, "iget-char", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff0b), + IGET_SHORT((short)0x58, "iget-short", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff0c), + IPUT((short)0x59, "iput", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff0d), + IPUT_WIDE((short)0x5a, "iput-wide", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff0e), + IPUT_OBJECT((short)0x5b, "iput-object", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff0f), + IPUT_BOOLEAN((short)0x5c, "iput-boolean", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff10), + IPUT_BYTE((short)0x5d, "iput-byte", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff11), + IPUT_CHAR((short)0x5e, "iput-char", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff12), + IPUT_SHORT((short)0x5f, "iput-short", ReferenceType.field, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff13), + SGET((short)0x60, "sget", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff14), + SGET_WIDE((short)0x61, "sget-wide", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER, (short)0xff15), + SGET_OBJECT((short)0x62, "sget-object", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff16), + SGET_BOOLEAN((short)0x63, "sget-boolean", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff17), + SGET_BYTE((short)0x64, "sget-byte", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff18), + SGET_CHAR((short)0x65, "sget-char", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff19), + SGET_SHORT((short)0x66, "sget-short", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0xff1a), + SPUT((short)0x67, "sput", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff1b), + SPUT_WIDE((short)0x68, "sput-wide", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff1c), + SPUT_OBJECT((short)0x69, "sput-object", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff1d), + SPUT_BOOLEAN((short)0x6a, "sput-boolean", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff1e), + SPUT_BYTE((short)0x6b, "sput-byte", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff1f), + SPUT_CHAR((short)0x6c, "sput-char", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff20), + SPUT_SHORT((short)0x6d, "sput-short", ReferenceType.field, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE, (short)0xff21), INVOKE_VIRTUAL((short)0x6e, "invoke-virtual", ReferenceType.method, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), INVOKE_SUPER((short)0x6f, "invoke-super", ReferenceType.method, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), INVOKE_DIRECT((short)0x70, "invoke-direct", ReferenceType.method, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), INVOKE_STATIC((short)0x71, "invoke-static", ReferenceType.method, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), INVOKE_INTERFACE((short)0x72, "invoke-interface", ReferenceType.method, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_VIRTUAL_RANGE((short)0x74, "invoke-virtual/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_SUPER_RANGE((short)0x75, "invoke-super/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_DIRECT_RANGE((short)0x76, "invoke-direct/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_STATIC_RANGE((short)0x77, "invoke-static/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_INTERFACE_RANGE((short)0x78, "invoke-interface/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), + INVOKE_VIRTUAL_RANGE((short)0x74, "invoke-virtual/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff22), + INVOKE_SUPER_RANGE((short)0x75, "invoke-super/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff23), + INVOKE_DIRECT_RANGE((short)0x76, "invoke-direct/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff24), + INVOKE_STATIC_RANGE((short)0x77, "invoke-static/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff25), + INVOKE_INTERFACE_RANGE((short)0x78, "invoke-interface/range", ReferenceType.method, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT, (short)0xff26), NEG_INT((short)0x7b, "neg-int", ReferenceType.none, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), NOT_INT((short)0x7c, "not-int", ReferenceType.none, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), NEG_LONG((short)0x7d, "neg-long", ReferenceType.none, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), @@ -379,17 +379,23 @@ public enum Opcode public final ReferenceType referenceType; public final Format format; public final int flags; + private final short jumboOpcode; Opcode(short opcodeValue, String opcodeName, ReferenceType referenceType, Format format) { this(opcodeValue, opcodeName, referenceType, format, 0); } Opcode(short opcodeValue, String opcodeName, ReferenceType referenceType, Format format, int flags) { + this(opcodeValue, opcodeName, referenceType, format, flags, (short)-1); + } + + Opcode(short opcodeValue, String opcodeName, ReferenceType referenceType, Format format, int flags, short jumboOpcodeValue) { this.value = opcodeValue; this.name = opcodeName; this.referenceType = referenceType; this.format = format; this.flags = flags; + this.jumboOpcode = jumboOpcodeValue; } public final boolean canThrow() { @@ -427,4 +433,12 @@ public enum Opcode public final boolean isOdexedStaticVolatile() { return (flags & ODEXED_STATIC_VOLATILE) != 0; } + + public final boolean hasJumboOpcode() { + return jumboOpcode != -1; + } + + public final Opcode getJumboOpcode() { + return Opcode.getOpcodeByValue(jumboOpcode); + } } diff --git a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java index 8a21e66f..2528ada5 100644 --- a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java +++ b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java @@ -28,10 +28,7 @@ package org.jf.dexlib; -import org.jf.dexlib.Code.Format.Instruction20t; -import org.jf.dexlib.Code.Format.Instruction21c; -import org.jf.dexlib.Code.Format.Instruction30t; -import org.jf.dexlib.Code.Format.Instruction31c; +import org.jf.dexlib.Code.Format.*; import org.jf.dexlib.Code.*; import org.jf.dexlib.Debug.DebugInstructionIterator; import org.jf.dexlib.Debug.DebugOpcode; @@ -408,10 +405,11 @@ public class CodeItem extends Item { * - Replace goto and goto/16 with a larger version of goto, when the target is too far away * TODO: we should be able to replace if-* instructions with targets that are too far away with a negated if followed by a goto/32 to the original target * TODO: remove multiple nops that occur before a switch/array data pseudo instruction. In some cases, multiple smali-baksmali cycles with changes in between could cause nops to start piling up + * TODO: in case of non-range invoke with a jumbo-sized method reference, we could check if the registers are sequential, and replace it with the jumbo variant (which only takes a register range) * * The above fixes are applied iteratively, until no more fixes have been performed */ - public void fixInstructions(boolean fixStringConst, boolean fixGoto) { + public void fixInstructions(boolean fixJumbo, boolean fixGoto) { try { boolean didSomething = false; @@ -453,13 +451,15 @@ public class CodeItem extends Item { didSomething = true; break; } - } else if (fixStringConst && instruction.opcode == Opcode.CONST_STRING) { - Instruction21c constStringInstruction = (Instruction21c)instruction; - if (constStringInstruction.getReferencedItem().getIndex() > 0xFFFF) { + } else if (fixJumbo && instruction.opcode.hasJumboOpcode()) { + InstructionWithReference referenceInstruction = (InstructionWithReference)instruction; + if (referenceInstruction.getReferencedItem().getIndex() > 0xFFFF) { + + InstructionWithJumboVariant instructionWithJumboVariant = + (InstructionWithJumboVariant)referenceInstruction; + replaceInstructionAtAddress(currentCodeAddress, - new Instruction31c(Opcode.CONST_STRING_JUMBO, - (short)constStringInstruction.getRegisterA(), - constStringInstruction.getReferencedItem())); + instructionWithJumboVariant.makeJumbo()); didSomething = true; break; } diff --git a/smali-integration-tests/src/test/smali/jumbo-field-tests/Format41c_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-field-tests/Format41c_autofix.smali new file mode 100644 index 00000000..666d2f92 --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-field-tests/Format41c_autofix.smali @@ -0,0 +1,158 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LFormat41c_autofix; +.super Ljava/lang/Object; +.source "Format41c_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public test-sput-sget-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 23 + sput v0, LManyStaticFields;->field99999:I + + sget v1, LManyStaticFields;->field99999:I + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-sput-object-sget-object-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v0, Ljava/lang/Object; + invoke-direct {v0}, Ljava/lang/Object;->()V + + sput-object v0, LManyStaticFields;->field99999Object:Ljava/lang/Object; + + sget-object v1, LManyStaticFields;->field99999Object:Ljava/lang/Object; + + invoke-static/range {v0 .. v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V + return-void +.end method + +.method public test-sput-wide-sget-wide-jumbo()V + .registers 4 + .annotation runtime Lorg/junit/Test; + .end annotation + + const-wide v0, 0x200000000L + + sput-wide v0, LManyStaticFields;->field99999Wide:J + + sget-wide v2, LManyStaticFields;->field99999Wide:J + + invoke-static/range {v0 .. v3}, Lorg/junit/Assert;->assertEquals(JJ)V + return-void +.end method + +.method public test-sput-boolean-sget-boolean-true-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 1 + + sput-boolean v0, LManyStaticFields;->field99999Boolean:Z + + sget-boolean v1, LManyStaticFields;->field99999Boolean:Z + + invoke-static/range {v1}, Lorg/junit/Assert;->assertTrue(Z)V + return-void +.end method + +.method public test-sput-boolean-sget-boolean-false-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 0 + + sput-boolean v0, LManyStaticFields;->field99999Boolean:Z + + sget-boolean v1, LManyStaticFields;->field99999Boolean:Z + + invoke-static/range {v1}, Lorg/junit/Assert;->assertFalse(Z)V + return-void +.end method + +.method public test-sput-byte-sget-byte-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 120T + + sput-byte v0, LManyStaticFields;->field99999Byte:B + + sget-byte v1, LManyStaticFields;->field99999Byte:B + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-sput-char-sget-char-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 'a' + + sput-char v0, LManyStaticFields;->field99999Char:C + + sget-char v1, LManyStaticFields;->field99999Char:C + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-sput-short-sget-short-jumbo()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 1234S + + sput-short v0, LManyStaticFields;->field99999Short:S + + sget-short v1, LManyStaticFields;->field99999Short:S + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-field-tests/Format52c_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-field-tests/Format52c_autofix.smali new file mode 100644 index 00000000..9bda9d8a --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-field-tests/Format52c_autofix.smali @@ -0,0 +1,182 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LFormat52c_autofix; +.super Ljava/lang/Object; +.source "Format52c_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public test-iput-iget-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 23 + iput v0, v2, LzzzInstanceFields;->field99999:I + + iget v1, v2, LzzzInstanceFields;->field99999:I + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-iput-object-iget-object-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + new-instance v0, Ljava/lang/Object; + invoke-direct {v0}, Ljava/lang/Object;->()V + + iput-object v0, v2, LzzzInstanceFields;->field99999Object:Ljava/lang/Object; + + iget-object v1, v2, LzzzInstanceFields;->field99999Object:Ljava/lang/Object; + + invoke-static/range {v0 .. v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V + return-void +.end method + +.method public test-iput-wide-iget-wide-jumbo()V + .registers 5 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v4, LzzzInstanceFields; + invoke-direct/range {v4}, LzzzInstanceFields;->()V + + const-wide v0, 0x200000000L + + iput-wide v0, v4, LzzzInstanceFields;->field99999Wide:J + + iget-wide v2, v4, LzzzInstanceFields;->field99999Wide:J + + invoke-static/range {v0 .. v3}, Lorg/junit/Assert;->assertEquals(JJ)V + return-void +.end method + +.method public test-iput-boolean-iget-boolean-true-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 1 + + iput-boolean v0, v2, LzzzInstanceFields;->field99999Boolean:Z + + iget-boolean v1, v2, LzzzInstanceFields;->field99999Boolean:Z + + invoke-static/range {v1}, Lorg/junit/Assert;->assertTrue(Z)V + return-void +.end method + +.method public test-iput-boolean-iget-boolean-false-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 0 + + iput-boolean v0, v2, LzzzInstanceFields;->field99999Boolean:Z + + iget-boolean v1, v2, LzzzInstanceFields;->field99999Boolean:Z + + invoke-static/range {v1}, Lorg/junit/Assert;->assertFalse(Z)V + return-void +.end method + +.method public test-iput-byte-iget-byte-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 120T + + iput-byte v0, v2, LzzzInstanceFields;->field99999Byte:B + + iget-byte v1, v2, LzzzInstanceFields;->field99999Byte:B + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-iput-char-iget-char-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 'a' + + iput-char v0, v2, LzzzInstanceFields;->field99999Char:C + + iget-char v1, v2, LzzzInstanceFields;->field99999Char:C + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-iput-short-iget-short-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v2, LzzzInstanceFields; + invoke-direct/range {v2}, LzzzInstanceFields;->()V + + const v0, 1234S + + iput-short v0, v2, LzzzInstanceFields;->field99999Short:S + + iget-short v1, v2, LzzzInstanceFields;->field99999Short:S + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-field-tests/TestSuite.smali b/smali-integration-tests/src/test/smali/jumbo-field-tests/TestSuite.smali index 001e18f6..61354a29 100644 --- a/smali-integration-tests/src/test/smali/jumbo-field-tests/TestSuite.smali +++ b/smali-integration-tests/src/test/smali/jumbo-field-tests/TestSuite.smali @@ -36,6 +36,8 @@ .annotation runtime Lorg/junit/runners/Suite$SuiteClasses; value = { LFormat41c;, - LFormat52c; + LFormat41c_autofix;, + LFormat52c;, + LFormat52c_autofix; } .end annotation \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-method-tests/Format5rc_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-method-tests/Format5rc_autofix.smali new file mode 100644 index 00000000..2c2280aa --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-method-tests/Format5rc_autofix.smali @@ -0,0 +1,176 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LFormat5rc_autofix; +.super LzzzRangeMethodsSuper_autofix; +.source "Format5rc_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct/range {p0}, LzzzRangeMethodsSuper_autofix;->()V + return-void +.end method + +.method public superMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + #add something extra, to make the test fail if this method is called instead of the super's method + const v1, 1 + add-int v0, v0, v1 + + return v0 +.end method + +.method private directMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + return v0 +.end method + + +.method public test_invoke-virtual-range()V + .registers 7 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v0, LzzzRangeMethods_autofix; + invoke-direct/range {v0}, LzzzRangeMethods_autofix;->()V + + const v1, 1 + const v2, 2 + const v3, 3 + const v4, 4 + const v5, 5 + const v6, 6 + + invoke-virtual/range {v0 .. v6}, LzzzRangeMethods_autofix;->virtualMethodTest(IIIIII)I + move-result v0 + + const v1, 21 + invoke-static {v0, v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test_invoke-super-range()V + .registers 7 + .annotation runtime Lorg/junit/Test; + .end annotation + + move-object v0, p0 + const v1, 1 + const v2, 2 + const v3, 3 + const v4, 4 + const v5, 5 + const v6, 6 + + invoke-super/range {v0 .. v6}, LFormat5rc_autofix;->superMethodTest(IIIIII)I + move-result v0 + + const v1, 21 + invoke-static {v0, v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test_invoke-direct-range()V + .registers 7 + .annotation runtime Lorg/junit/Test; + .end annotation + + move-object v0, p0 + const v1, 1 + const v2, 2 + const v3, 3 + const v4, 4 + const v5, 5 + const v6, 6 + + invoke-direct/range {v0 .. v6}, LFormat5rc_autofix;->directMethodTest(IIIIII)I + move-result v0 + + const v1, 21 + invoke-static {v0, v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test_invoke-static-range()V + .registers 7 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v1, 1 + const v2, 2 + const v3, 3 + const v4, 4 + const v5, 5 + const v6, 6 + + invoke-static/range {v1 .. v6}, LzzzRangeMethods_autofix;->staticMethodTest(IIIIII)I + move-result v0 + + const v1, 21 + invoke-static {v0, v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test_invoke-interface-range()V + .registers 7 + .annotation runtime Lorg/junit/Test; + .end annotation + + move-object v0, p0 + const v1, 1 + const v2, 2 + const v3, 3 + const v4, 4 + const v5, 5 + const v6, 6 + + new-instance v0, LzzzRangeMethods_autofix; + invoke-direct/range {v0}, LzzzRangeMethods_autofix;->()V + + invoke-interface/range {v0 .. v6}, LzzzRangeMethodsInterface_autofix;->interfaceMethodTest(IIIIII)I + move-result v0 + + const v1, 21 + invoke-static {v0, v1}, LAssert;->assertEquals(II)V + return-void +.end method diff --git a/smali-integration-tests/src/test/smali/jumbo-method-tests/TestSuite.smali b/smali-integration-tests/src/test/smali/jumbo-method-tests/TestSuite.smali index aeb9bc31..6e376748 100644 --- a/smali-integration-tests/src/test/smali/jumbo-method-tests/TestSuite.smali +++ b/smali-integration-tests/src/test/smali/jumbo-method-tests/TestSuite.smali @@ -35,5 +35,6 @@ .end annotation .annotation runtime Lorg/junit/runners/Suite$SuiteClasses; - value = { LFormat5rc; } + value = { LFormat5rc;, + LFormat5rc_autofix;} .end annotation \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsInterface_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsInterface_autofix.smali new file mode 100644 index 00000000..f072b33d --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsInterface_autofix.smali @@ -0,0 +1,34 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public abstract interface LzzzRangeMethodsInterface_autofix; +.super Ljava/lang/Object; + +.method public abstract interfaceMethodTest(IIIIII)I +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsSuper_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsSuper_autofix.smali new file mode 100644 index 00000000..c820464c --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethodsSuper_autofix.smali @@ -0,0 +1,65 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LzzzRangeMethodsSuper_autofix; +.super Ljava/lang/Object; + +.method public constructor ()V + .registers 1 + invoke-direct/range {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public superMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + return v0 +.end method + +.method public virtualMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + #add something extra, to make the test fail if this method is called instead of the subclasses's method + const v1, 1 + add-int v0, v0, v1 + + return v0 +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethods_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethods_autofix.smali new file mode 100644 index 00000000..7ee469ab --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-method-tests/zzzRangeMethods_autofix.smali @@ -0,0 +1,74 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LzzzRangeMethods_autofix; +.super LzzzRangeMethodsSuper_autofix; +.implements LzzzRangeMethodsInterface_autofix; + +.method public constructor ()V + .registers 1 + invoke-direct/range {p0}, LzzzRangeMethodsSuper_autofix;->()V + return-void +.end method + +.method public virtualMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + return v0 +.end method + +.method public static staticMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + return v0 +.end method + +.method public interfaceMethodTest(IIIIII)I + .registers 7 + + add-int v0, v1, v2 + add-int v0, v0, v3 + add-int v0, v0, v4 + add-int v0, v0, v5 + add-int v0, v0, v6 + + return v0 +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-type-tests/Format41c_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format41c_autofix.smali new file mode 100644 index 00000000..59c45e33 --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format41c_autofix.smali @@ -0,0 +1,115 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LFormat41c_autofix; +.super Ljava/lang/Object; +.source "Format41c_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public test_const-class-jumbo()V + .registers 9 + .annotation runtime Lorg/junit/Test; + .end annotation + + const-class v0, Lzzz99999; + invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String; + move-result-object v0 + + #check for the initial 3 z's + const v1, 3 + const v2, 0 + const-wide v3, 'z' + + :loop + invoke-virtual {v0, v2}, Ljava/lang/String;->charAt(I)C + move-result v5 + + int-to-long v6, v5 + + invoke-static {v3, v4, v6, v7}, Lorg/junit/Assert;->assertEquals(JJ)V + + add-int/lit8 v2, v2, 1 + if-ne v1, v2, :loop + + #and now for the final 9's + invoke-virtual {v0}, Ljava/lang/String;->length()I + move-result v1 + const-wide v3, '9' + + :loop2 + invoke-virtual {v0, v2}, Ljava/lang/String;->charAt(I)C + move-result v5 + + int-to-long v6, v5 + + invoke-static {v3, v4, v6, v7}, Lorg/junit/Assert;->assertEquals(JJ)V + + add-int/lit8 v2, v2, 1 + if-ne v1, v2, :loop2 + + return-void +.end method + +.method public test_new-instance-jumbo-index()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + new-instance v1, Lzzz99999; + + #there's no way to initialize the new object, due to type index constraints on a method_id_item + #so just attempt to create the new object and call it good + + return-void +.end method + +.method public test_check-cast-jumbo-fail()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + :tryStart + const-string v0, "test" + + check-cast v0, Lzzz99999; + :tryEnd + .catch Ljava/lang/ClassCastException; {:tryStart .. :tryEnd} :handler + + #the check-cast didn't throw an exception as expected + invoke-static {}, Lorg/junit/Assert;->fail()V + + :handler + + return-void +.end method diff --git a/smali-integration-tests/src/test/smali/jumbo-type-tests/Format52c_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format52c_autofix.smali new file mode 100644 index 00000000..9cc6d2bc --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format52c_autofix.smali @@ -0,0 +1,89 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE + +.class public LFormat52c_autofix; +.super Ljava/lang/Object; +.source "Format52c_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public test-instance-of-jumbo-success()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const-string v0, "test" + + new-instance v1, LStringWrapper; + invoke-direct {v1, v0}, LStringWrapper;->(Ljava/lang/String;)V + + instance-of v0, v1, Ljava/lang/Object; + + const v1, 1 + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-instance-of-jumbo-failure()V + .registers 2 + .annotation runtime Lorg/junit/Test; + .end annotation + + const-string v0, "test" + + new-instance v1, LStringWrapper; + invoke-direct {v1, v0}, LStringWrapper;->(Ljava/lang/String;)V + + instance-of v0, v1, Lzzz99999; + + const v1, 0 + + invoke-static/range {v0 .. v1}, LAssert;->assertEquals(II)V + return-void +.end method + +.method public test-new-array-jumbo()V + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 1 + + new-array v1, v0, [Lzzz99999; + + array-length v2, v1 + + invoke-static {v0, v2}, LAssert;->assertEquals(II)V + return-void +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-type-tests/Format5rc_autofix.smali b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format5rc_autofix.smali new file mode 100644 index 00000000..e674a9bf --- /dev/null +++ b/smali-integration-tests/src/test/smali/jumbo-type-tests/Format5rc_autofix.smali @@ -0,0 +1,86 @@ +#Copyright 2011, Google Inc. +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are +#met: +# +# * Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +#copyright notice, this list of conditions and the following disclaimer +#in the documentation and/or other materials provided with the +#distribution. +# * Neither the name of Google Inc. nor the names of its +#contributors may be used to endorse or promote products derived from +#this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.class public LFormat5rc_autofix; +.super Ljava/lang/Object; +.source "Format5rc_autofix.smali" + +.method public constructor ()V + .registers 1 + invoke-direct/range {p0}, Ljava/lang/Object;->()V + return-void +.end method + +.method public test_filled-new-array-range()V + .registers 6 + .annotation runtime Lorg/junit/Test; + .end annotation + + const v0, 1 + const v1, 2 + const v2, 3 + const v3, 4 + const v4, 5 + const v5, 6 + + filled-new-array/range {v0 .. v5}, [I + move-result-object v0 + + const v1, 0 + aget v2, v0, v1 + const v1, 1 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + const v1, 1 + aget v2, v0, v1 + const v1, 2 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + const v1, 2 + aget v2, v0, v1 + const v1, 3 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + const v1, 3 + aget v2, v0, v1 + const v1, 4 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + const v1, 4 + aget v2, v0, v1 + const v1, 5 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + const v1, 5 + aget v2, v0, v1 + const v1, 6 + invoke-static {v1, v2}, LAssert;->assertEquals(II)V + + return-void +.end method \ No newline at end of file diff --git a/smali-integration-tests/src/test/smali/jumbo-type-tests/TestSuite.smali b/smali-integration-tests/src/test/smali/jumbo-type-tests/TestSuite.smali index 647d6267..6cdca29e 100644 --- a/smali-integration-tests/src/test/smali/jumbo-type-tests/TestSuite.smali +++ b/smali-integration-tests/src/test/smali/jumbo-type-tests/TestSuite.smali @@ -36,7 +36,10 @@ .annotation runtime Lorg/junit/runners/Suite$SuiteClasses; value = { LFormat41c;, + LFormat41c_autofix;, LFormat52c;, - LFormat5rc; + LFormat52c_autofix;, + LFormat5rc;, + LFormat5rc_autofix; } .end annotation \ No newline at end of file diff --git a/smali/src/main/java/org/jf/smali/main.java b/smali/src/main/java/org/jf/smali/main.java index 86c2229b..ff72a449 100644 --- a/smali/src/main/java/org/jf/smali/main.java +++ b/smali/src/main/java/org/jf/smali/main.java @@ -100,7 +100,7 @@ public class main { boolean allowOdex = false; boolean sort = false; - boolean fixStringConst = true; + boolean fixJumbo = true; boolean fixGoto = true; boolean verboseErrors = false; boolean oldLexer = false; @@ -142,8 +142,8 @@ public class main { case 'S': sort = true; break; - case 'C': - fixStringConst = false; + case 'J': + fixJumbo = false; break; case 'G': fixGoto = false; @@ -203,8 +203,8 @@ public class main { dexFile.setSortAllItems(true); } - if (fixStringConst || fixGoto) { - fixInstructions(dexFile, fixStringConst, fixGoto); + if (fixJumbo || fixGoto) { + fixInstructions(dexFile, fixJumbo, fixGoto); } dexFile.place(); @@ -255,13 +255,11 @@ public class main { } } - private static void fixInstructions(DexFile dexFile, boolean fixStringConst, boolean fixGoto) { + private static void fixInstructions(DexFile dexFile, boolean fixJumbo, boolean fixGoto) { dexFile.place(); - byte[] newInsns = null; - for (CodeItem codeItem: dexFile.CodeItemsSection.getItems()) { - codeItem.fixInstructions(fixStringConst, fixGoto); + codeItem.fixInstructions(fixJumbo, fixGoto); } } @@ -395,9 +393,9 @@ public class main { .withDescription("sort the items in the dex file into a canonical order before writing") .create("S"); - Option noFixStringConstOption = OptionBuilder.withLongOpt("no-fix-string-const") - .withDescription("Don't replace string-const instructions with string-const/jumbo where appropriate") - .create("C"); + Option noFixJumboOption = OptionBuilder.withLongOpt("no-fix-jumbo") + .withDescription("Don't automatically instructions with the /jumbo variant where appropriate") + .create("J"); Option noFixGotoOption = OptionBuilder.withLongOpt("no-fix-goto") .withDescription("Don't replace goto type instructions with a larger version where appropriate") @@ -422,7 +420,7 @@ public class main { debugOptions.addOption(dumpOption); debugOptions.addOption(sortOption); - debugOptions.addOption(noFixStringConstOption); + debugOptions.addOption(noFixJumboOption); debugOptions.addOption(noFixGotoOption); debugOptions.addOption(verboseErrorsOption); debugOptions.addOption(oldLexerOption);