wiki:https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler

由于jd好多年没更新了,今天找到这个新的开源反汇编,很不错

分享一下。

之前一直用jd,结果很多时候要看smali

现在好多了

Java Decompiler

As a developer who splits his time between the .NET and Java platforms, I have been surprised and dismayed by the lackluster selection of decompilers in the Java ecosystem. Jad (no longer maintained) and JD-GUI are pretty decent choices, but the former does not support Java 5+ language features, and the latter tends to barf on code emitted by my LINQ/DLR tree compiler. Neither is open source.

To address the situation, I recently started developing a decompiler myself, inspired by (and borrowed heavily from) ILSpy and Mono.Cecil.

Status

While still incomplete, my own tests seem to indicate that the Procyon decompiler can generally hold its own against the other leading Java decompilers out there. There are, however, some known issues.

Known Issues

  1. Classes compiled with Eclipse (or anything other than javac) may produce less than optimal results, especially for constructs like String-based switch statements. Up until now, I have mostly tested classes compiled with Javac. I will work to improve support for other compilers as time goes on.

Why should I care?

The Procyon decompiler handles language enhancements from Java 5 and beyond that most other decompilers don't. It also excels in areas where others fall short. Procyon in particular does well with:

  1. Enum declarations
  2. Enum and String switch statements (only tested against javac 1.7 so far)
  3. Local classes (both anonymous and named)
  4. Annotations
  5. Java 8 Lambdas and method references (i.e., the :: operator).

Output Comparison

I've posted some simple input/output comparisons comparing original source, decompiled output, and JD-GUI output.

How to Use

Java 7 is required to run. Unfortunately, I do not yet have a slick GUI front-end like JD-GUI (but third-party front-ends do exist--see below!). I do, however, offer color-coded output for consoles supporting ANSI/xterm-256. I also offer three output modes:

  1. Java (default)
  2. Raw Bytecode (similar to javap, but prettier; run with -r)
  3. Bytecode AST (an intermediate representation; run with -b, add -u for unoptimized)

Note that color-coded output requires an ANSI-compatible console. Unfortunately, this rules out the Windows command prompt. To get color-coded output on Windows, I recommend using a terminal environment like MobaXterm. If ANSI detection fails for whatever reason (as it does with MobaXterm), you can force it on by running with -DAnsi=true.

The main class (entry point) is com.strobel.decompiler.DecompilerDriver. It's also the entry class for decompiler.jar (available under Downloads). You can pass in one or more types to be processed. At the moment, all output goes to System.out. I will probably add file-based output in the future. To call the public API externally, use the helper class com.strobel.decompiler.Decompiler.

The input types can be fully-qualified names in dotted or binary form (e.g., java.lang.String or java/lang/String) or relative/absolute file paths (path/to/MyClass.class or C:\src\path\to\MyClass.class) or even whole jar files. If you pass in a type name, it will attempt to load it out of the user or bootstrap classpath. If you have trouble getting it to locate classes from jars or directories in your CLASSPATH environment variable, try running the main class directly instead of running with -jar.

I still have a remarkably flimsy grasp of how all this classpath business works in Java, so if someone would like to educate me (or submit a pull request), be my guest :).

Usage Examples

Assuming that you have renamed the download file from procyon-decompiler-x.x.xx.jar to decompiler.jar, the following are some common options.

Show help/usage information and exit.

$ java -jar decompiler.jar
$ java -jar decompiler.jar -?

Decompile a single class to the console.

$ java -jar decompiler.jar java.lang.String
$ java -DAnsi=true -jar decompiler.jar java.util.Collections

Decompile a whole jar to a directory.

$ java -jar decompiler.jar -jar myJar.jar -o out

GUI Front Ends

Don't want to use the command line? Try one of these GUI front-ends for Procyon:

最新文章

  1. 基于webdriver的jmeter性能测试-通过jmeter实现jar录制脚本的性能测试
  2. TDatabase TQuery TDataSource TDBGrid 设定方法
  3. 用Phaser实现Flappy Bird 游戏
  4. dos命令复制当天生成的以日期为文件名的文件
  5. C#中导入Win32 API函数
  6. Fortran并行计算的一些例子
  7. Android(java)学习笔记164:Relativelayout相对布局案例
  8. HDU 5543 Pick The Sticks
  9. echarts雷达图点击事件
  10. 更改dede网站地图模板样式
  11. selenium+python自动化测试系列(一):登录
  12. S3c2440A WINCE平台HIVE注册表+binfs的实现
  13. Vue (三) --- Vue 组件开发
  14. 11. java中路径/和\的区别
  15. Python 安装requests和MySQLdb
  16. TypeScript开发环境搭建(Visual studio code)
  17. yii2中的rules 自定义验证规则详解
  18. 局域网代理通过wget下载
  19. jQuery 库的优缺点
  20. ubuntu14.4安装gtx970显卡驱动的艰辛历程

热门文章

  1. 【分类】AlexNet论文总结
  2. windchill中表格API
  3. PHPCMSV9的CKEDITOR编辑器增加行距
  4. mui app在线更新
  5. C++(二十五) — 类的封装、实现
  6. python进行linux系统监控
  7. Ansible 小手册系列 十七(特性模块)
  8. Ansible 小手册系列 四(详解配置文件)
  9. Jquery validation自定义验证
  10. 决定整理一下canvas的基础学习