1 stable release
| 1.0.0 | Jan 12, 2026 |
|---|
#258 in FFI
15KB
159 lines
CADI Java Atomizer
Example extension that demonstrates how to create a language atomizer for CADI.
Overview
This extension provides Java language support for CADI by:
- Extracting atomic chunks from Java source code (classes, methods)
- Resolving Java import statements
- Supporting Java-specific syntax and patterns
Building
cargo build --release
This will create a dynamic library that can be loaded by CADI.
Usage
-
Copy the built library to your CADI extensions directory:
cp target/release/libextension.so ~/.cadi/extensions/java-atomizer/ cp extension.toml ~/.cadi/extensions/java-atomizer/ -
CADI will automatically load the extension on startup.
Extension Structure
java-atomizer/
├── extension.toml # Extension manifest
├── libextension.so # Compiled extension library
└── src/
└── lib.rs # Extension implementation
Implementation Details
The Java atomizer uses regex patterns to:
- Extract class definitions and their bodies
- Extract method definitions within classes
- Resolve import statements
Each extracted atom includes:
- Unique ID based on language and type
- Content type (
text/java) - Metadata (language, type, name, class)
- Dependencies (parent classes/methods)
- Content hash for deduplication
Testing
public class Example {
private String name;
public Example(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
This would be atomized into:
- Class atom:
Exampleclass definition - Method atoms: constructor and
getName()method
Dependencies
~129MB
~3.5M SLoC