Usage (Code)

To use vineflower from code, it needs to be added as a library. Vineflower is published on Maven Central, and can be accessed from build scripts like so:

 <dependency>
    <groupId>org.vineflower</groupId>
    <artifactId>vineflower</artifactId>
    <version>1.11.1</version>
 </dependency>
 repositories {
    mavenCentral()
 }

 dependencies {
    implementation "org.vineflower:vineflower:1.11.1"
 }
 repositories {
    mavenCentral()
 }

 dependencies {
    implementation("org.vineflower:vineflower:1.11.1")
 }

Development (-SNAPSHOT) builds are published on the Sonatype OSS snapshots repository as well for testing purposes:

<repositories>
    <repository>
       <id>sonatype-central-snapshots</id>
       <url>https://central.sonatype.com/repository/maven-snapshots/</url>
    </repository>
</repositories>
repositories {
   maven {
       name = "sonatype-central-snapshots"
       url = "https://central.sonatype.com/repository/maven-snapshots/"
   }
}
repositories {
   maven(url = "https://central.sonatype.com/repository/maven-snapshots/") {
       name = "sonatype-central-snapshots"
   }
}

Slim jars

Vineflower also publishes a -slim artifact, which does not contain any plugins. It can be accessed by appending -slim to the version number. This can be used if the builtin plugins are not required, or if the smallest possible dependency size is needed.

Running the decompiler

The main API for the decompiler is located at org.jetbrains.java.decompiler.api.Decompiler. After a builder is constructed, inputs and outputs can be specified. After it’s built, the decompile() method does the actual decompilation.

Decompiler decompiler = new Decompiler.Builder()
  .inputs(inputFile) // also accepts IContextSource
  .output(new SingleFileSaver(outputJar)) // also accepts DirectoryResultSaver, or a custom IResultSaver implementation
  .option(IFernflowerPreferences.INCLUDE_ENTIRE_CLASSPATH, true) // optional, change options for the decompiler
  .logger(new IFernflowerLogger() { ... }) // optional, provide a logger impl for the decompiler to use
  .libraries(libraryFile) // optional, include libraries to enhance the decompiler's analysis but not decompile
  .build();

decompiler.decompile();
// Done!

Backwards compatibility

Generally dependencies on Fernflower can be seamlessly swapped for Vineflower without changing the code if they only use Fernflower’s informal public API, files in org.jetbrains.java.decompiler.main.extern. Other files have been extensively modified.