diff --git a/dexlib/src/main/java/org/jf/dexlib/Util/DeodexUtil.java b/dexlib/src/main/java/org/jf/dexlib/Util/DeodexUtil.java index dc6aecf6..9dde0785 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Util/DeodexUtil.java +++ b/dexlib/src/main/java/org/jf/dexlib/Util/DeodexUtil.java @@ -246,10 +246,10 @@ public class DeodexUtil { throw new RuntimeException("Could not find the inline method with index " + inlineMethodIndex); } assert inlineMethod != null; - assert inlineMethod.methodIdItem != null; + assert inlineMethod.getMethodIdItem() != null; Opcode opcode = null; - switch (inlineMethod.methodType) { + switch (inlineMethod.getMethodType()) { case Direct: opcode = Opcode.INVOKE_DIRECT; break; @@ -262,14 +262,14 @@ public class DeodexUtil { } i.fixedInstruction = new Instruction35msf(opcode, (Instruction35ms)i.instruction, - inlineMethod.methodIdItem); + inlineMethod.getMethodIdItem()); insn nextInstruction = i.getInstructionAtOffset(i.offset + i.instruction.getSize(i.offset*2)/2); assert nextInstruction != null; if (nextInstruction.instruction.opcode == Opcode.MOVE_RESULT_OBJECT) { nextInstruction.registerReferenceType = - inlineMethod.methodIdItem.getPrototype().getReturnType().getTypeDescriptor(); + inlineMethod.getMethodIdItem().getPrototype().getReturnType().getTypeDescriptor(); } return true; diff --git a/dexlib/src/main/java/org/jf/dexlib/Util/Deodexerant.java b/dexlib/src/main/java/org/jf/dexlib/Util/Deodexerant.java index 4baafa6b..466c9c9a 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Util/Deodexerant.java +++ b/dexlib/src/main/java/org/jf/dexlib/Util/Deodexerant.java @@ -90,24 +90,7 @@ public class Deodexerant { } String methodDescriptor = parts[1]; - - Matcher m = fullMethodPattern.matcher(methodDescriptor); - if (!m.matches()) { - throw new RuntimeException("Invalid method descriptor: " + methodDescriptor); - } - - String classType = m.group(1); - String methodName = m.group(2); - String methodParams = m.group(3); - String methodRet = m.group(4); - - MethodIdItem method = parseAndResolveMethod(classType, methodName, methodParams, methodRet); - if (method == null) { - inlineMethods[i] = null; - continue; - } - - inlineMethods[i] = new InlineMethod(method, type); + inlineMethods[i] = new InlineMethod(methodDescriptor, type); } } @@ -416,13 +399,44 @@ public class Deodexerant { Static } - public static class InlineMethod { - public final MethodIdItem methodIdItem; - public final InlineMethodType methodType; - public InlineMethod(MethodIdItem methodIdItem, InlineMethodType methodType) { - this.methodIdItem = methodIdItem; + public class InlineMethod { + public final String inlineMethodDescriptor; + private final InlineMethodType methodType; + private MethodIdItem methodIdItem = null; + + public InlineMethod(String inlineMethodDescriptor, InlineMethodType methodType) { + this.inlineMethodDescriptor = inlineMethodDescriptor; this.methodType = methodType; } + + public MethodIdItem getMethodIdItem() { + if (methodIdItem == null) { + loadMethod(); + } + return methodIdItem; + } + + public InlineMethodType getMethodType() { + return methodType; + } + + private void loadMethod() { + Matcher m = fullMethodPattern.matcher(inlineMethodDescriptor); + if (!m.matches()) { + throw new RuntimeException("Invalid method descriptor: " + inlineMethodDescriptor); + } + + String classType = m.group(1); + String methodName = m.group(2); + String methodParams = m.group(3); + String methodRet = m.group(4); + + MethodIdItem method = parseAndResolveMethod(classType, methodName, methodParams, methodRet); + if (method == null) { + throw new RuntimeException("Could not resolve method " + inlineMethodDescriptor); + } + this.methodIdItem = method; + } } private TypeIdItem getType(String typeDescriptor) {