How to get rid of the unrelated classes when using WALA to analyze Java bytecode? -
i read aricle wala on http://www.programcreek.com/2012/10/wala-tutorial/ , try execute example. want know how rid of classes except test code within test.jar. thank you!
import java.io.file; import java.io.ioexception; import java.util.jar.jarfile; import com.ibm.wala.classloader.iclass; import com.ibm.wala.classloader.imethod; import com.ibm.wala.ipa.callgraph.analysisscope; import com.ibm.wala.ipa.cha.classhierarchy; import com.ibm.wala.ipa.cha.classhierarchyexception; import com.ibm.wala.ipa.cha.iclasshierarchy; import com.ibm.wala.util.config.analysisscopereader; import com.ibm.wala.util.io.fileprovider; public class walatest { public static void main(string args[]) throws ioexception, classhierarchyexception { file exfile=new fileprovider().getfile("java60regressionexclusions.txt"); system.out.println(exfile.getabsolutepath()); analysisscope scope = analysisscopereader.makejavabinaryanalysisscope("test.jar",exfile); iclasshierarchy cha = classhierarchy.make(scope); (iclass c : cha) { string cname = c.getname().tostring(); system.out.println("class:" + cname); (imethod m : c.getallmethods()) { string mname = m.getname().tostring(); system.out.println(" method:" + mname); } system.out.println(); } } }
in loop of iclass, add following line check scope first using isapplicationloader()
.
if (!scope.isapplicationloader(c.getclassloader())) continue;
Comments
Post a Comment