use of org.objectweb.asm.tree.analysis.Analyzer in project dex2jar by pxb1988.
the class AsmVerify method doCommandLine.
@Override
protected void doCommandLine() throws Exception {
if (remainingArgs.length < 1) {
usage();
return;
}
List<Path> files = new ArrayList<>();
for (String fn : remainingArgs) {
Path file = new File(fn).toPath();
if (!Files.exists(file)) {
System.err.println(fn + " is not exists");
usage();
return;
}
files.add(file);
}
for (Path file : files) {
System.out.println("verify " + file);
walkJarOrDir(file, new FileVisitorX() {
@Override
public void visitFile(Path file, String relative) throws IOException {
if (file.getFileName().toString().endsWith(".class")) {
ClassReader cr = new ClassReader(Files.readAllBytes(file));
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES | ClassReader.SKIP_FRAMES);
for (MethodNode method : cn.methods) {
BasicVerifier verifier = new BasicVerifier();
Analyzer<BasicValue> a = new Analyzer<>(verifier);
try {
a.analyze(cn.name, method);
} catch (Exception ex) {
System.err.println("Error verify method " + cr.getClassName() + "." + method.name + " " + method.desc);
if (detail) {
ex.printStackTrace(System.err);
printAnalyzerResult(method, a, new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8)));
}
}
}
}
}
});
}
}
Aggregations