diff --git a/smalivm/src/main/java/org/cf/smalivm/ClassManager.java b/smalivm/src/main/java/org/cf/smalivm/ClassManager.java index 6d23121f6..03f8bda16 100644 --- a/smalivm/src/main/java/org/cf/smalivm/ClassManager.java +++ b/smalivm/src/main/java/org/cf/smalivm/ClassManager.java @@ -218,7 +218,7 @@ public List getTryBlocks(String methodDescriptor) { return methodDescriptorToTryBlocks.get(methodDescriptor); } - public boolean isFramework(String typeName) { + public boolean isFrameworkClass(String typeName) { String className = typeName.split("->")[0]; return smaliFileFactory.isFrameworkClass(className); @@ -296,7 +296,7 @@ public boolean isNativeMethod(String methodDescriptor) { return Modifier.isNative(method.getAccessFlags()); } - public boolean isSafeFramework(String typeName) { + public boolean isSafeFrameworkClass(String typeName) { String className = typeName.split("->")[0]; return smaliFileFactory.isSafeFrameworkClass(className); @@ -344,7 +344,7 @@ private void addParameterTypes(BuilderMethod method) { int accessFlags = method.getAccessFlags(); boolean isStatic = Modifier.isStatic(accessFlags); if (!isStatic) { - // First "parameter" for non-static methods is instance ref + // First "parameter" for non-static methods is instance reference parameterTypes.add(0, method.getDefiningClass()); } diff --git a/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOp.java b/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOp.java index 45e89c8f5..0d60dde57 100644 --- a/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOp.java +++ b/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOp.java @@ -126,7 +126,7 @@ public void execute(ExecutionNode node, ExecutionContext ectx) { // This assumes if reflection or emulation fails, not worth it to try possibly cached framework classes. ClassManager classManager = vm.getClassManager(); if (classManager.isLocalMethod(targetMethod)) { - if (classManager.isFramework(targetMethod) && !classManager.isSafeFramework(targetMethod)) { + if (classManager.isFrameworkClass(targetMethod) && !classManager.isSafeFrameworkClass(targetMethod)) { if (log.isDebugEnabled()) { log.debug("Not executing unsafe local method: {}. Assuming maxiumum ambiguity.", targetMethod); } diff --git a/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOpFactory.java b/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOpFactory.java index 719e8314a..1adb1af18 100644 --- a/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOpFactory.java +++ b/smalivm/src/main/java/org/cf/smalivm/opcode/InvokeOpFactory.java @@ -55,11 +55,14 @@ private int[] buildParameterRegisters(List parameterTypes, int[] registe } private static List getParameterTypes(String methodDescriptor, boolean isStatic, ClassManager classManager) { - List parameterTypes; - if (classManager.isLocalMethod(methodDescriptor) && !classManager.isFramework(methodDescriptor) || classManager - .isSafeFramework(methodDescriptor)) { + List parameterTypes = null; + if (classManager.isLocalMethod(methodDescriptor) && !classManager.isFrameworkClass(methodDescriptor) || classManager + .isSafeFrameworkClass(methodDescriptor)) { parameterTypes = classManager.getParameterTypes(methodDescriptor); - } else { + } + + if (parameterTypes == null) { + // Possibly a framework class, but the method was not found. parameterTypes = Utils.getParameterTypes(methodDescriptor); if (!isStatic) { parameterTypes.add(0, methodDescriptor.split("->")[0]); diff --git a/smalivm/src/main/java/org/cf/smalivm/opcode/NewArrayOpFactory.java b/smalivm/src/main/java/org/cf/smalivm/opcode/NewArrayOpFactory.java index 2d730055b..ba8cbb80f 100644 --- a/smalivm/src/main/java/org/cf/smalivm/opcode/NewArrayOpFactory.java +++ b/smalivm/src/main/java/org/cf/smalivm/opcode/NewArrayOpFactory.java @@ -25,9 +25,9 @@ public Op create(MethodLocation location, TIntObjectMap addressT String baseClassName = SmaliClassUtils.getBaseClass(arrayType); ClassManager classManager = vm.getClassManager(); boolean useLocalClass = false; - if (classManager.isFramework(baseClassName)) { + if (classManager.isFrameworkClass(baseClassName)) { // Create arrays of LocalInstance - useLocalClass = classManager.isSafeFramework(baseClassName); + useLocalClass = classManager.isSafeFrameworkClass(baseClassName); } else { useLocalClass = classManager.isLocalClass(baseClassName); } diff --git a/smalivm/src/test/java/org/cf/smalivm/opcode/TestInvokeOp.java b/smalivm/src/test/java/org/cf/smalivm/opcode/TestInvokeOp.java index 39d85ca62..eb01fda30 100644 --- a/smalivm/src/test/java/org/cf/smalivm/opcode/TestInvokeOp.java +++ b/smalivm/src/test/java/org/cf/smalivm/opcode/TestInvokeOp.java @@ -82,8 +82,8 @@ public void setUp() { classManager = mock(ClassManager.class); when(vm.getClassManager()).thenReturn(classManager); when(classManager.isLocalClass(METHOD_CLASS)).thenReturn(true); - when(classManager.isFramework(METHOD_DESCRIPTOR)).thenReturn(false); - when(classManager.isSafeFramework(METHOD_DESCRIPTOR)).thenReturn(false); + when(classManager.isFrameworkClass(METHOD_DESCRIPTOR)).thenReturn(false); + when(classManager.isSafeFrameworkClass(METHOD_DESCRIPTOR)).thenReturn(false); methodRef = mock(MethodReference.class); when(methodRef.getDefiningClass()).thenReturn(METHOD_CLASS);