繁体   English   中英

使用Proycon将.class文件反编译为.java文件

[英]Decompile .class File to .java File using Proycon

我有一个将.class文件转换为.java文件的项目,在研究过程中,我发现Proycon是一个有助于实现此目的的Java库。 不幸的是,我找不到Proycon的任何适当文档。 任何有使用此经验的人,如果可以,请告诉我我必须使用哪种方法将.class转换为.java文件并将其打印到控制台中?

JD-core-java https://github.com/nviennot/jd-core-java是jd-core的薄包装。 自述文件显示了如何在项目中使用它。

/* Returns the source of SomeClass from compiled.jar as a String */
new jd.core.Decompiler.decompile("compiled.jar", "com/namespace/SomeClass.class");

/*
 * Returns the sources of all the classes in compiled.jar as a Map<String, String>
 * where the key is the class name (full path) and the value is the source
 */
new jd.core.Decompiler.decompile("compiled.jar");

/*
 * Returns the number of classes decompiled and saved into out_dir
 */
new jd.core.Decompiler.decompileToDir("compiled.jar", "out_dir");

下载Java Decompiler(JD)将.class文件转换为.java,我用过此Decompiler,我认为最好

我正在使用其Bitbucket存储库中的 procyon-decompiler-0.5.30.jar

如果需要反编译一个或多个jar,请将其复制到文件夹中,然后运行:

%JAVA_HOME%\bin\java -jar c:\procyon\procyon-decompiler-0.5.30.jar -o . *.jar

在上面的命令中,我指定了procyon jar和-o .的完整路径-o . 将输出设置为当前文件夹。

假设我要检查sentry-logback-1.5.4.jar ,在运行上述命令后,我将最终进入具有以下结构的工作文件夹:

sentry-logback-1.5.4.jar
[io]
  `-- [sentry]
          `-- [logback]
                 `-- SentryAppender.java

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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