// JAVARS — JAVA IN RUST

javars v0.1.9 · Java on fusevm · lex/parse → AST → bytecode → Cranelift JIT · no bespoke VM · no JVM · a fusevm language host (with zshrs, stryke, awkrs, elisp, rubylang) · MIT · in active development

Report Reference GitHub
// Color scheme

>_JAVARS REFERENCE

A Java frontend written in Rust. Source is lexed and parsed to an AST, lowered to fusevm bytecode, and executed on the same language-agnostic VM + three-tier Cranelift JIT that hosts zshrs, stryke, awkrs, elisp, and rubylang. No bespoke VM, no JVM, no .class files. In active development.

What it is

javars runs Java programs as ordinary compiled bytecode: it lexes and parses the source, lowers it to fusevm instructions, and lets the shared engine execute and JIT-compile them. There is no bespoke VM or tree-walker — arithmetic and comparisons lower to native fusevm ops so the Cranelift JIT can trace hot loops, while Java-specific behaviour (the String + overload, Java-flavoured value formatting where a whole double prints as 3.0) is served by the host numeric hook and print builtins.

It is another language hosted on fusevm, the shared bytecode VM and Cranelift JIT behind zshrs (the shell), stryke (the language), awkrs (AWK), elisp (Emacs Lisp), and rubylang (Ruby). javars carries no VM or JIT of its own — the JVM runs Java on the JVM; javars runs Java on fusevm.

Architecture

The pipeline mirrors how zshrs hosts zsh and rubylang hosts Ruby:

Java source  →  lexer  →  parser (AST)  →  lower to fusevm bytecode  →  fusevm VM + Cranelift JIT
                                                  │
                                        host: String + concat, Java value formatting, print builtins

fusevm-hosted

No local vm.rs / jit.rs. Java is lowered to fusevm bytecode and executed on the shared three-tier Cranelift JIT; jit-disk-cache persists compiled native code across runs.

No JVM, no .class

javars never emits .class files and never links a JVM. It is a source-in, run-out frontend: the compiled chunk runs directly on fusevm.

Native fast paths

Integer and floating arithmetic and comparisons lower to native fusevm ops, so the tracing JIT can compile hot for / while loops; only the mixed-operand String + takes the host hook.

Editor tooling

A read-only LSP (--lsp) supplies completion, hover, and parser-driven diagnostics; a DAP debugger (--dap) provides breakpoints, stepping, and local inspection over the running program.

Example

public class Demo {
    public static void main(String[] args) {
        int total = 0;
        for (int i = 1; i <= 4; i++) {
            total += i;
        }
        System.out.println(total);          // => 10

        String label = "sum = " + total;
        System.out.println(label);           // => sum = 10

        double half = 3.0;
        System.out.println(half);            // => 3.0  (Java double formatting)

        boolean ok = total > 0 && half < 5;
        System.out.println(ok);              // => true
    }
}

Status & roadmap

The table below reflects the current state of the tree. See BUGS.md for the honest ledger of what is not yet carried.

ComponentStateNotes
Lexer / parser → ASTImplementedHand-written tokenizer + recursive-descent parser with precedence climbing (src/lexer.rs, src/parser.rs).
AST → fusevm bytecode loweringImplementedNo local VM; native arithmetic + CallBuiltin print dispatch, backpatched control flow (src/compiler.rs).
Entry class + main bodyImplementedMultiple top-level and nested classes; the class declaring public static void main is the entry.
Locals, assignment, compound assignmentImplementedint x = e;, x += e;, post-inc/dec; several declarators per statement (int a = 1, b = 2;, int p[] = {1}, q;); the declared type drives /-truncation and the 32-bit int wrap.
Control flow (if/while/for, break/continue)ImplementedC-style for, short-circuiting &&/||, loop backpatching.
String + concat & Java value formattingImplementedHost numeric hook concatenates on a String operand; true/false, 3.0, null (src/host.rs).
Console IO (System.out.print/println)ImplementedLowered to Java-formatting print builtins.
LSP server (--lsp)ImplementedCompletion + hover from the keyword/type/IO corpus, parser-driven diagnostics (src/lsp.rs).
DAP debugger (--dap)ImplementedLine breakpoints, stepping, stack trace, and main-locals inspection via debug line markers (src/dap.rs).
Dumps (--dump-tokens/--dump-ast/--disasm)ImplementedPrint an artifact and exit (src/main.rs).
User methods, classes, fields, objectsImplementedstatic and instance methods on the Op::Call frame ABI, constructors, inheritance, interfaces, overloading, virtual dispatch, and reference arrays on a host object heap (src/host.rs). static fields (with static { } blocks), record types, and abstract classes run too.
ExceptionsImplementedthrow, try/catch/finally, try-with-resources, the modeled java.lang throwable hierarchy, and javars's own runtime faults (bad index, parseInt, / 0, null receiver) raised as catchable exceptions with Java's detail messages.
Standard library, genericsPlannedType-erased generics, record/enum types, lambdas and method references, and the java.util collections (with Java’s real HashMap iteration order) run today; streams and the functional-interface default methods are pending (see BUGS.md).
Inline rust { } FFIImplementedA rust { } block compiles to a cached cdylib whose exports are callable by name (src/rust_ffi.rs).

Why javars

Compiled, not walked

Every prior Java runtime targets the JVM; javars lowers Java to fusevm bytecode and JITs hot paths through Cranelift — the same architecture that makes zshrs and stryke fast.

No JVM dependency

No .class files, no classpath, no JVM install: a single java binary lexes, parses, lowers, and runs.

One shared engine

Bug fixes and JIT improvements in fusevm benefit zshrs, stryke, awkrs, elisp, rubylang, and javars at once.

Editor-ready

LSP and DAP ship in the same binary, so completion, diagnostics, and a stepping debugger work from any editor that speaks the protocols.

Building from source

javars builds as a standalone Rust crate (it is not a workspace member of the meta repo):

# clone
git clone https://github.com/MenkeTechnologies/javars
cd javars

# build (produces target/debug/java)
cargo build

# run a program, or inspect the pipeline
./target/debug/java Hello.java
./target/debug/java --disasm Fib.java
./target/debug/java --dump-ast FizzBuzz.java

# editor tooling over stdio
./target/debug/java --lsp
./target/debug/java --dap

# run tests
cargo test

fusevm is pulled from crates.io with the jit, jit-disk-cache, and aot features.

License

javars is MIT licensed — free and open source. See LICENSE.

Repository & links