简体   繁体   中英

Decompile .class files to .java source code using java libraries

我正在研究需要将.class文件反编译为源代码的java项目,我发现了很多方法,比如JAD反编译器和'javap -p'方法......但是我觉得这些方法都做不到以编程方式(请告诉是否可以),有没有办法以编程方式完成此操作,如果您向我展示任何库,将不胜感激。

Procyon is a Java decompiler written in Java, and it can be called directly from Java code. For example:

final PrintWriter writer = new PrintWriter(System.out);

try {
    com.strobel.decompiler.Decompiler.decompile(
        "W:\\Hello.class",
        new com.strobel.decompiler.PlainTextOutput(writer)
    );
}
finally {
    writer.flush();
}

There is also a decompile() overload that accepts a DecompilerSettings instance, which you can use to toggle certain features and give the decompiler hints on how to resolve class dependencies. Feel free to contact me on BitBucket with any questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM