https://github.com/nbauma109/transformer-api
Unified Java API for multiple decompilers (Fernflower, Vineflower, Procyon, CFR, JD-Core, JADX)
https://github.com/nbauma109/transformer-api
Last synced: 5 months ago
JSON representation
Unified Java API for multiple decompilers (Fernflower, Vineflower, Procyon, CFR, JD-Core, JADX)
- Host: GitHub
- URL: https://github.com/nbauma109/transformer-api
- Owner: nbauma109
- License: apache-2.0
- Fork: true (helios-decompiler/transformer-api)
- Created: 2022-01-29T17:25:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2026-01-12T20:01:56.000Z (6 months ago)
- Last Synced: 2026-01-13T01:17:46.364Z (5 months ago)
- Language: Java
- Homepage:
- Size: 2.08 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - transformer-api - Unified API that exposes multiple decompilers through one in-memory transformation interface. (Projects / Decompilation)
README
# Transformer API
[](https://central.sonatype.com/artifact/io.github.nbauma109/transformer-api)
[](https://github.com/nbauma109/transformer-api/actions/workflows/codeql-analysis.yml)
[](https://github.com/nbauma109/transformer-api/actions/workflows/maven.yml)
[](https://github.com/nbauma109/transformer-api/actions/workflows/release.yml)
[](https://app.codecov.io/gh/nbauma109/transformer-api)
The Transformer API provides convenient access to different transformers (currently decompilers only) under a unified
API. The API is still subject to major changes, but only with a major version bump.
## Usage
Currently, this API supports the following decompilers :
- Fernflower
- Vineflower (fork of Fernflower)
- Procyon
- CFR
- JD-Core V0 and V1
- JADX
Decompilers can be accessed either via `StandardTransformers.DECOMPILER` or by creating a new instance. They are also
stateless, which means you can use the same instance across different threads.
An example program decompiling a file using Vineflower (fork of Fernflower) is shown below:
```java
package com.heliosdecompiler.transformerapi;
import com.heliosdecompiler.transformerapi.common.Loader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
public class Sample {
public byte[] load(String internalName) throws IOException {
InputStream is = this.getClass().getResourceAsStream("/" + internalName + ".class");
if (is == null) {
return null;
}
try (InputStream in=is; ByteArrayOutputStream out=new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024];
int read = in.read(buffer);
while (read > 0) {
out.write(buffer, 0, read);
read = in.read(buffer);
}
return out.toByteArray();
}
}
public boolean canLoad(String internalName) {
return this.getClass().getResource("/" + internalName + ".class") != null;
}
public static void main(String[] args) {
Sample sample = new Sample();
Loader loader = new Loader(sample::canLoad, sample::load);
Map preferences = new HashMap<>();
try {
String ff = StandardTransformers.Decompilers.ENGINE_VINEFLOWER;
DecompilationResult result =
StandardTransformers.decompile(
loader,
"java/lang/String",
preferences,
ff
);
System.out.println(result.getDecompiledOutput());
} catch (Exception e) {
System.err.println(e);
}
}
}
```
## Features
### Updates
This API will be updated as decompilers receive updates, which means fixes reach you faster.