← Back to Blog

ARIA-JVM: A JVM Bytecode Backend Without gcc

· John Avera

The C backend requires gcc. That is a real friction point for contributors -- a fresh machine needs Java, Clojure, and a native C toolchain just to run hello world. The JVM backend removes that third dependency entirely.

--backend jvm routes to the new aria.codegen-jvm namespace. The output is a .class file or a runnable JAR. The JVM already installed to run aria-clj is also what runs the output. No gcc. No clang. No system compiler at all.

Bytecode generation uses ASM -- the same library Clojure itself uses to compile Clojure code. That endorsement is sufficient.

The type mapping is direct. add.i32 becomes iadd. mul.f64 becomes dmul. ARIA-IR's type-suffixed operations were designed to eliminate ambiguity. The JVM bytecode instruction set was designed the same way. They align cleanly.

Three phases shipped across three PRs:

Phase 1 (PR #10): Arithmetic, string operations, control flow, --emit-class output. The acceptance test: aria-clj examples/fibonacci.aria --backend jvm --emit-class && java Fibonacci with no gcc in the chain.

Phase 2 (PR #11): --emit-jar with a runnable manifest. The @Intent annotation pass -- (intent "...") nodes are emitted as @com.ariacompiler.Intent annotations on generated methods with @Retention(RUNTIME), queryable at runtime via reflection. The C backend preserves intent as a comment. Comments are inert. The JVM annotation system makes intent first-class, and gives Layer 4 intent verification a concrete implementation target.

Phase 3 (PR #13): Pointer support via AriaMemory -- the JVM has no raw pointers, so the ARIA heap is modeled as a static flat int array and pointers become int indices. rem.i32 and rem.i64. Type casting (cast i32 i64). Correct i64 boxing in print statements. All three example programs now compile and run: fibonacci, bubble sort, and math demo.

clojure -M:run examples/bubble_sort.aria --backend jvm --emit-jar
java -jar Bubble_sort.jar
Before sorting: [64, 34, 25, 12, 22, 11, 90, 1]
After sorting:  [1, 11, 12, 22, 25, 34, 64, 90]

92 tests. 252 assertions. Zero failures.