我看了有关WALA的文章,地址是http://www.programcreek.com/2012/10/wala-tutorial/,并尝试执行其中的示例。我想知道如何除去test.jar中除了我的测试代码之外的所有类。谢谢!
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);
for (IClass c : cha) {
String cname = c.getName().toString();
System.out.println("Class:" + cname);
for (IMethod m : c.getAllMethods()) {
String mname = m.getName().toString();
System.out.println(" method:" + mname);
}
System.out.println();
}
}
}