Skip to main content

Crate javars

Crate javars 

Source
Expand description

javars — Java as a fusevm frontend.

Pipeline: lexer → parser builds a Java AST → compiler lowers it to a fusevm::Chunk → fusevm executes it on the shared three-tier Cranelift JIT, calling back into host (the strict numeric hook) for Java’s String + overload. There is no bespoke VM or JVM here — execution and codegen live in fusevm, the same engine behind zshrs, stryke, awkrs, elisp, and ruby.

Re-exports§

pub use banner::version_banner;
pub use embed::run_program;

Modules§

ast
The Java AST javars parses and lowers to fusevm bytecode.
banner
The java --version banner string.
cli
Command-line parsing for the java binary.
compiler
Lower the Java AST to a fusevm::Chunk.
dap
Debug Adapter Protocol over stdio (java --dap).
embed
Embedding entry point: run a Java program from Rust with a given stdin and get its stdout back as a string.
fdlibm
java.lang.FdLibm: the JDK’s own Java port of fdlibm, which every StrictMath function answers from, and which Math delegates to wherever HotSpot has no intrinsic for the function.
flow
Definite assignment (JLS chapter 16), checked the way javac checks it.
host
The javars host: builtin registration, Java value formatting, and the strict numeric hook.
hotspot_trig
Math.sin and Math.cos as HotSpot answers them on aarch64: a port of the dsin/dcos stubs MacroAssembler::generate_dsin_dcos emits (src/hotspot/cpu/aarch64/macroAssembler_aarch64_trig.cpp, openjdk 27), which the interpreter, C1 and C2 all call for those two methods.
jbig
java.math.BigInteger: the arithmetic of num-bigint behind the JDK’s contract — truncating divide/remainder, always-non-negative mod, two’s-complement bitwise semantics on negatives, the exact exception messages, hashCode over the big-endian 32-bit magnitude words, and the low-bits narrowing of intValue/longValue.
jbigdec
java.math.BigDecimal, RoundingMode and MathContext: an unscaled BigInt plus a decimal scale, following the JDK’s contract — the preferred scales of divide/sqrt, the canonical toString, scale-sensitive equals, the string grammar and its exception messages.
jbitset
java.util.BitSet, ported from java.base/java/util/BitSet.java (openjdk 27): a growable vector of 64-bit words with the JDK’s capacity rule (size() is the allocated word count times 64, doubling on growth), its index checks and their messages, its hashCode, and its {1, 3} rendering.
jdk_generic_statics
Generated by scripts/GenJdkGenericStatics.java from OpenJDK 64-Bit Server VM 21.0.13.0.2 — do not edit.
jdk_supertypes
Generated by scripts/GenJdkSupertypes.java from OpenJDK 64-Bit Server VM 21.0.13.0.2 — do not edit.
jio
Console and text input and output: System.in, java.util.Scanner, java.io.BufferedReader/InputStreamReader/StringReader, java.util.StringTokenizer, and on the output side System.out/err, the java.io writers (PrintWriter, BufferedWriter, OutputStreamWriter, StringWriter) and print streams (PrintStream, BufferedOutputStream). The output half is at the end of the file.
jrandom
java.util.Random: the JDK’s 48-bit linear congruential generator.
jstr
Java’s String model on fusevm’s UTF-8 Value::Str.
lexer
A hand-written Java lexer.
lsp
Language Server Protocol over stdio (java --lsp).
parser
A recursive-descent arser with precedence-climbing for expressions.
prelude
The implicit java.lang / java.util.function prelude.
reference
The javars language-reference corpus.
regex
java.util.regex on fancy-regex.
regex_names
Generated by scripts/GenRegexNames.java from OpenJDK 64-Bit Server VM 21.0.13.0.2 — do not edit.
regex_syntax
java.util.regex.Pattern’s syntax check, ported from its recursive-descent parser (Pattern.expr/sequence/atom/closure/group0/clazz/ range/escape and the escape helpers in OpenJDK 21’s Pattern.java).
rust_ffi
Java wiring for inline Rust FFI (rust { ... } blocks).
tiers
Which fusevm execution tier a program’s bytecode actually reaches.
unicode_tables
Unicode property tables for java.lang.Character, generated from openjdk 21.0.13.0.2 by scripts/GenUnicodeTables.java, which dumps the JDK’s own answers for every code point (Character.getType, getNumericValue, isIdeographic, the emoji properties, UnicodeBlock.of) as sorted, non-overlapping (first, last, value) runs. Regenerate rather than edit.
uninames
Character.getName, from the names scripts/GenUnicodeTables.java dumps out of the JDK into src/data/uninames.bin (its header describes the format). A code point with no name of its own there is named as the JDK names it: its block, then its code point in upper-case hex.

Functions§

compile
Parse and lower Java src to a runnable fusevm chunk.
disassemble
Compile src and return a human-readable disassembly of the fusevm chunk (for java --disasm).
parse
Parse Java src to an AST. Inline rust { ... } FFI blocks are desugared to __rust_compile(...) statements first (see rust_ffi), so every parse path — run, --dump-ast, --disasm, --dap — sees the same rewritten source. No-op when the source has no rust block.
run_file
Read and run a .java file.
run_str
Compile and run a Java source string with no program arguments (args is a zero-length String[]); return the last VM value.
run_str_args
Compile and run a Java source string, binding argv to main’s String[] parameter.