[Soot-list] Probable problem in isAbstract method for SootMethod class

Chandan Rupakheti rupakhcr at clarkson.edu
Thu Mar 18 14:00:43 EDT 2010


Hello Everybody,

I came across a case when Soot is reporting a method as abstract as well as
interface. I am not sure if this is intentional. For example, let consider
following class:

-----------------------------------------------------------------
package serl.test;

import java.util.ArrayList;
import java.util.List;

public class TestClass {
private List<String> list;
 public TestClass() {
list = new ArrayList<String>();
}
 public String testMe() {
return list.get(0); // get method here is both abstract and interface
}
}


-----------------------------------------------------------------
To check the flag for get method inside testMe (i.e. list.get(0)), I used
following static call:

       // Here sootClass == serl.test.TestClass and methodName == testMe
public static void checkMethodFlags(SootClass sootClass, String methodName)
{
SootMethod method = sootClass.getMethodByName(methodName);
JimpleBody jimpleBody = (JimpleBody)method.retrieveActiveBody();
for(Unit aUnit : jimpleBody.getUnits()) {
if(aUnit instanceof Stmt) {
Stmt stmt = (Stmt)aUnit;
if(stmt.containsInvokeExpr()) {
InvokeExpr invkExpr = stmt.getInvokeExpr();
SootMethod aMethod = invkExpr.getMethod();
String name = aMethod.getName();
 System.out.println("Flags for method: " + name);
if(invkExpr instanceof InterfaceInvokeExpr) {
System.out.println("interface");
}
if(aMethod.isAbstract()) {
System.out.println("abstract");
}
}
}
}
}

Assuming we loaded serl.test.TestClass in soot and made a call
to checkMethodFlags passing TestClass as sootClass and testMe as methodName,
we get following output:

Flags for method: get
interface
abstract

I am wondering if this is what soot anticipates or is it a bug?

Thanks,

Chandan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100318/1b71c582/attachment.html 


More information about the Soot-list mailing list