soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.87k stars 706 forks source link

Assigning a local to a virtual invoke. #860

Open arvindksilvan opened 6 years ago

arvindksilvan commented 6 years ago

Hello, I'm trying to acheive the below statement in Jimple format

 l_device_jObject = virtualinvoke device.<org.apache.cordova.device.Device: org.json.JSONObject execute(java.lang.String,org.json.JSONArray,org.apache.cordova.CallbackContext)>(jArray_standard, jArray_standard, jArray_standard)

I'm simply trying to assign a local to a virtualinvokeexpression.

However, even after deriving this code(with all the correct inputs for arguments):

VirtualInvokeExpr vexpr = Jimple.v().newVirtualInvokeExpr(item,toCall.makeRef(),jArray_standard,jArray_standard,jArray_standard);
AssignStmt invokeStmt = Jimple.v().newAssignStmt(jObject,vexpr);
units.add(Jimple.v().newStmtBox(Jimple.v().newStmtBox(invokeStmt).getUnit()).getUnit());

My end results in the Jimple file is this:

 virtualinvoke device.<org.apache.cordova.device.Device: org.json.JSONObject execute(java.lang.String,org.json.JSONArray,org.apache.cordova.CallbackContext)>(jArray_standard, jArray_standard, jArray_standard);

As it can be seen, l_device_jObject is not assigned at all. Rest assured, I've created the local for l_device_jObject and even added them to the body. What am I missing out from here? Some urgent @help would be really appreciated - thank you! @mbenz89 @StevenArzt @ericbodden

mbenz89 commented 6 years ago

Can you try using

units.add(invokeStmt);

instead of

units.add(Jimple.v().newStmtBox(Jimple.v().newStmtBox(invokeStmt).getUnit()).getUnit());