From 55c33ebb09d9d6de74cf1aae87109706d1042d51 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Fri, 16 Sep 2016 10:35:47 +0100 Subject: [PATCH] Add a placeholder ART version number / api level for aosp/master. Also make invoke-polymorphic conditional on this new art version. This also fixes a bug where the version was being selected incorrectly due to a parameter name that shadowed a local variable. --- dexlib2/src/main/java/org/jf/dexlib2/Opcode.java | 4 ++-- dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java | 4 ++-- .../src/main/java/org/jf/dexlib2/VersionMap.java | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java b/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java index 1d7a12d9..60dffa2f 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java @@ -305,8 +305,8 @@ public enum Opcode SPARSE_SWITCH_PAYLOAD(0x200, "sparse-switch-payload", ReferenceType.NONE, Format.SparseSwitchPayload, 0), ARRAY_PAYLOAD(0x300, "array-payload", ReferenceType.NONE, Format.ArrayPayload, 0), - INVOKE_POLYMORPHIC(firstApi(0xfa, 26), "invoke-polymorphic", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format45cc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_POLYMORPHIC_RANGE(firstApi(0xfb, 26), "invoke-polymorphic/range", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format4rcc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT); + INVOKE_POLYMORPHIC(firstArtVersion(0xfa, 87), "invoke-polymorphic", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format45cc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), + INVOKE_POLYMORPHIC_RANGE(firstArtVersion(0xfb, 87), "invoke-polymorphic/range", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format4rcc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT); //if the instruction can throw an exception public static final int CAN_THROW = 0x1; diff --git a/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java b/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java index c1e40ad2..d6d4fdbf 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java @@ -92,9 +92,9 @@ public class Opcodes { int version; if (isArt()) { - version = artVersion; + version = this.artVersion; } else { - version = api; + version = this.api; } for (Opcode opcode: Opcode.values()) { diff --git a/dexlib2/src/main/java/org/jf/dexlib2/VersionMap.java b/dexlib2/src/main/java/org/jf/dexlib2/VersionMap.java index e0e1a6bb..b3581876 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/VersionMap.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/VersionMap.java @@ -35,6 +35,12 @@ public class VersionMap { public static final int NO_VERSION = -1; public static int mapArtVersionToApi(int artVersion) { + // NOTE: Art version 87 and api level 26 do not correspond to any + // particular android release and represent the current (as of + // October 2016) state of aosp/master. + if (artVersion >= 87) { + return 26; + } if (artVersion >= 79) { return 24; } @@ -62,10 +68,15 @@ public class VersionMap { case 23: return 64; case 24: + case 25: return 79; } - if (api > 24) { - return 79; + + // NOTE: Art version 87 and api level 26 do not correspond to any + // particular android release and represent the current (as of + // October 2016) state of aosp/master. + if (api > 25) { + return 87; } return NO_VERSION; }