您可以使用WALA库读取所有方法签名。 但是,您需要首先加载Java的Stub-Code。 以下程序应读出所有签名:
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.types.ClassLoaderReference;
import java.util.jar.JarFile;
import java.io.IOException;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
public class methods {
public static void main(String[] args) throws IOException, ClassHierarchyException {
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
scope.addToScope(ClassLoaderReference.Primordial, new JarFile("jSDG-stubs-jre1.5.jar"));
scope.addToScope(ClassLoaderReference.Application, new JarFile("myProgram.jar"));
IClassHierarchy cha = ClassHierarchy.make(scope);
for (IClass cl : cha) {
if (cl.getClassLoader().getReference().equals(ClassLoaderReference.Application)) {
for (IMethod m : cl.getAllMethods()) {
String ac = "";
if (m.isAbstract()) ac = ac + "abstract ";
if (m.isClinit()) ac = ac + "clinit ";
if (m.isFinal()) ac = ac + "final ";
if (m.isInit()) ac = ac + "init ";
if (m.isNative()) ac = ac + "native ";
if (m.isPrivate()) ac = ac + "private ";
if (m.isProtected()) ac = ac + "protected ";
if (m.isPublic()) ac = ac + "public ";
if (m.isSynchronized()) ac = ac + "synchronized ";
System.out.println(ac + m.getSignature());
}
}
}
}
}
如果您从此处使用改编的WALA版本,它也会使用Dalvik(例如Android Apps)。