Vineflower - モダンなJVM 言語用のデコンパイラ


Vineflower とは

レコードクラスやシールドクラス、スイッチ式などの新しい文法に対応(Java 20+)した JVM 言語用のデコンパイラです(Quiltflower 1.9.0 が、Vineflower 1.9.1 と名称変更されました)。

vineflower.org

intellij-community の java-decompiler からフォークして、デコンパイラ・エンジン Fernflower を使っています。Fernflower によるデコンパイルは以下が参考になります。

github.com


コマンドラインでの実行

vineflower.jar にデコンパイルしたい jar を渡して実行するだけです。

java -jar vineflower.jar <arguments> <source> <destination>

例として、vineflower.jar をダウンロードして、vineflower.jar 自身をデコンパイルして dest ディレクトリに出力するには以下のようにします。

$ curl -o vineflower.jar https://github.com/Vineflower/vineflower/releases/download/1.9.3/vineflower-1.9.3.jar
$ java -jar vineflower.jar vineflower.jar dest

dest ディレクトリ内にデコンパイルされたソースファイルが出力されます。


コマンドラインオプション

コマンドラインオプションは以下で確認できます。

$ java -jar vineflower.jar --help

Usage: java -jar vineflower.jar [-<option>=<value>]* [<source>]+ <destination>
At least one source file or directory must be specified.
Options:
--help: Show this help

Saving options
A maximum of one of the options can be specified:
--file          - Write the decompiled source to a file
--folder        - Write the decompiled source to a folder
--legacy-saving - Use the legacy console-specific method of saving
If unspecified, the decompiled source will be automatically detected based on destination name.

General options
These options can be specified multiple times.
-e=<path>     - Add the specified path to the list of external libraries
-only=<class> - Only decompile the specified class

Additional options
These options take the last specified value.
They each are specified with a three-character name followed by an equals sign, followed by the value.
Booleans are traditionally indicated with `0` or `1`, but may also be specified with `true` or `false`.
Because of this, an option indicated as a boolean may actually be a number.
-rbr=<bool>   - Remove Bridge Methods: Removes any methods that are marked as bridge from the decompiled output. (default: true)
...
-ren=<bool>   - Rename Members: Rename classes, fields, and methods with a number suffix to help in deobfuscation. (default: false)
...

大量にありますが、通常は特に何も指定しなくても良いでしょう。 対象のソースが難読化されているケースでは、-ren=1 を指定すると良いでしょう。