YABR is a bidirectional Java (de)compiler, program-analysis, and transformation framework. It spans bytecode, SSA, a structured IR, execution, and source, so a program can be lifted, analyzed, transformed, executed, compiled, and decompiled across one ecosystem.
- JStudio - A Java reverse engineering and analysis IDE.
- J2CS - A Java to C# transpiler.
- Dukes-8-Bit-Challenge - A game-jam submission using YABR in
buildSrc/for compile-time transformations.
- Java 11+
./gradlew build
./gradlew :all:shadowJarThe published artifact is the merged jar from the all module. Via JitPack:
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
dependencies {
implementation("com.github.Tonic-Box.YABR:all:<version>")
}// Load a class
ClassPool pool = ClassPool.getDefault();
ClassFile cf = pool.loadClass(inputStream);
// Create a new class with a default constructor
int access = new AccessBuilder().setPublic().build();
ClassFile newClass = ClassFactory.createClass(pool, "com/example/MyClass", access);
// Add a field with a getter and setter
FieldEntry field = newClass.createNewField(access, "value", "I", new ArrayList<>());
ClassFactory.generateGetter(newClass, field, false);
ClassFactory.generateSetter(newClass, field, false);
// Write the class
newClass.rebuild();
byte[] bytes = newClass.write();Runnable examples are in examples/src/main/java/com/tonic/demo/,
including class creation, SSA transformation, LLVM lowering, AST mutation, decompilation, call
graphs, dependency analysis, type inference, and pattern search.
The generated API reference lives at tonic-box.github.io/YABR;
regenerate it into docs/ with ./gradlew docSite. The guides below are in md-docs/.
| Guide | Description |
|---|---|
| Quick Start | Load, create, and modify classes in five minutes |
| Architecture | Module structure and design |
| Guide | Description |
|---|---|
| Class Files | ClassPool, ClassFile, ConstPool |
| Bytecode API | Low-level bytecode editing |
| Generation API | Fluent class/method generation |
| Visitors | Traversal and transformation patterns |
| Frame Computation | StackMapTable generation |
| Guide | Description |
|---|---|
| SSA Guide | SSA intermediate representation |
| SSA Transforms | Optimization and analysis passes |
| LLVM Lowering | Lower SSA IR to textual LLVM IR |
| LLVM Lifting | Lift LLVM IR back to SSA |
| Guide | Description |
|---|---|
| AST Guide | AST recovery, mutation, and emission |
| AST Editor | ExprEditor-style AST transformation |
| Parser API | Java source parser |
| Decompiler API | Class -> Java source decompilation |
| Guide | Description |
|---|---|
| Analysis APIs | Overview of the analysis suite |
| Call Graph API | Call-graph construction |
| Data Flow API | Data-flow analysis |
| Dependency API | Dependency analysis |
| PDG API | Program Dependence Graph with slicing |
| SDG API | Interprocedural System Dependence Graph |
| CPG API | Code Property Graph with taint analysis |
| Pattern Search API | Structural bytecode pattern search |
| Similarity API | Method similarity and fingerprinting |
| Type Inference API | Type inference |
| Xref API | Cross-references |
| Guide | Description |
|---|---|
| Execution API | Concrete bytecode execution |
| Simulation API | Abstract simulation |
| Abstract Execution API | Operand-stack and local def-use |
| Instrumentation API | Bytecode instrumentation and hooks |
| Verifier API | Bytecode verification |
| Guide | Description |
|---|---|
| Query API | Bytecode query language |
| Renamer API | Class, method, and field renaming |
YABR is a Gradle multi-project. Production code is split into layered modules (core, bytecode,
renamer, ssa, source, analyses, execution, query) whose dependencies are acyclic and
build-enforced; the all module merges them into a single jar. See
Architecture.
Inspired by classpooly.
MIT