下面列出了怎么用org.objectweb.asm.commons.AnalyzerAdapter的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
final MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
if (name.equals(methodName) && desc.equals(methodDesc)) {
logger.debug("visit method, name: {}, desc: {}", name, desc);
MonitorMethodVisitor monitorMV = new MonitorMethodVisitor(methodVisitor, access, name, desc, className);
AnalyzerAdapter analyzerAdapter = new AnalyzerAdapter(className, access, name, desc, monitorMV);
monitorMV.setAnalyzerAdapter(analyzerAdapter);
LocalVariablesSorter localVariablesSorter = new LocalVariablesSorter(access, desc, analyzerAdapter);
monitorMV.setLocalVariablesSorter(localVariablesSorter);
return localVariablesSorter;
} else {
return methodVisitor;
}
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
System.out.println(name);
final MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
/*if (!"setCount".equals(name)) {
return methodVisitor;
}*/
MonitorAdviceAdapter monitorMV = new MonitorAdviceAdapter(ASM7, methodVisitor, access, name, desc, className, exceptions);
AnalyzerAdapter analyzerAdapter = new AnalyzerAdapter(className, access, name, desc, monitorMV);
monitorMV.setAnalyzerAdapter(analyzerAdapter);
LocalVariablesSorter localVariablesSorter = new LocalVariablesSorter(access, desc, analyzerAdapter);
monitorMV.setLocalVariablesSorter(localVariablesSorter);
//MonitorAdviceAdapter monitorMV = new MonitorAdviceAdapter(ASM7, new LocalVariablesSorter(access, desc, methodVisitor), access, name, desc, className, exceptions);
return localVariablesSorter;
}
public TaintTrackingMethodVisitor(InheritanceMap inheritanceMap,
Map<MethodReference.Handle, Set<Integer>> passthroughDataflow,
final int api, final MethodVisitor mv, final String owner, int access,
String name, String desc, String signature, String[] exceptions) {
super(api, new AnalyzerAdapter(owner, access, name, desc, mv));
this.inheritanceMap = inheritanceMap;
this.passthroughDataflow = passthroughDataflow;
this.analyzerAdapter = (AnalyzerAdapter)this.mv;
this.access = access;
this.name = name;
this.desc = desc;
this.signature = signature;
this.exceptions = exceptions;
}
@Override
public MethodVisitor visitMethod(
int access, String name, String desc, String signature, String[] exceptions) {
RegSpecMethodVisitor mv = new RegSpecMethodVisitor(className, name);
AnalyzerAdapter adapter = new AnalyzerAdapter(className, access, name, desc, mv);
mv.adapter = adapter;
return adapter;
}
public void setAnalyzerAdapter(AnalyzerAdapter analyzerAdapter) {
this.analyzerAdapter = analyzerAdapter;
}
public void setAnalyzerAdapter(AnalyzerAdapter analyzerAdapter) {
this.analyzerAdapter = analyzerAdapter;
}