Chicory is a WebAssembly runtime written in Java. This document captures practical knowledge for working in the codebase.
- Java 11+ (build targets Java 11 compatibility)
- Maven (or use
./mvnw/./mvnw.cmd)
# Full build with all tests
mvn clean install
# Quick install, skip all tests and checks
mvn -Dquickly
# Skip tests only
mvn install -DskipTests
# Disable linters and enforcers during development
mvn -Ddev <goals>
# Autoformat code (required before committing)
mvn spotless:applyMaven plugins are defined in the same build, so modules do not build in isolation. Always use -pl and -am to include dependencies:
wasm-corpus (test resources)
wasm (parser, validator, types)
└── runtime (interpreter, Instance, Store)
├── wasi (WASI preview1)
│ └── wasm-tools (wat2wasm, wast2json via WASI)
├── compiler (JVM bytecode compiler)
├── simd (SIMD opcodes, pluggable machine)
└── log
Other modules: annotations, annotations/processor, build-time-compiler, compiler-maven-plugin, dircache.
After changing code in a module, you must mvn install it (and its dependencies) before downstream modules can see the changes. Use -DskipTests when you only need to propagate artifacts:
# Build runtime and everything it depends on, skip tests
mvn install -pl runtime -am -DskipTests
# Run only runtime unit tests (after install)
mvn test -pl runtime
# Build everything up to wasm-tools
mvn install -pl wasm-tools -am -DskipTestsThe WebAssembly spec testsuite lives in testsuite/. JUnit tests are generated from .wast files by the test-gen-plugin Maven plugin at build time.
- Add the
.wastfilename to<includedWasts>inruntime-tests/pom.xml - Run
mvn install -pl runtime-tests -amto regenerate the JUnit test classes - Run
mvn surefire:test -pl runtime-teststo execute them
Individual tests can be excluded via <excludedTests> in the same pom.
# Full spec test suite (interpreter) — install first to generate test classes, then run
mvn install -pl runtime-tests -am -DskipTests
mvn surefire:test -pl runtime-tests
# Or in one shot (install runs tests too)
mvn install -pl runtime-tests -am
# Compiler spec tests
mvn surefire:test -pl compiler-tests
# WASI spec tests
mvn surefire:test -pl wasi-testsmvn surefire:test -pl runtime-tests -Dtest=SpecV1GcStructTest| Module | What it tests |
|---|---|
runtime-tests |
Interpreter against the WebAssembly spec testsuite |
compiler-tests |
JVM bytecode compiler against the spec testsuite |
machine-tests |
Shared tests for both interpreter and compiler |
wasi-tests |
WASI preview1 against the WASI testsuite |
- No wildcard imports (configure your IDE accordingly)
- Run
mvn spotless:applybefore committing - Approval tests: set
APPROVAL_TESTS_USE_REPORTER=AutoApproveReporterto auto-approve golden samples
Parser.java— binary format parserValidator.java— type checking and validation (see spec appendix for the algorithm)types/— all Wasm types:ValType,FunctionType,SubType,RecType,CompType,StructType,ArrayType,FieldType,StorageType,PackedType,TypeSection,OpCode
Instance.java— module instantiation, GC ref storage, heap type matchingInterpreterMachine.java— opcode interpreter (the main execution loop)Store.java— cross-module linkingImportFunction.java— imported function representation with cross-module type validationConstantEvaluators.java— constant expression evaluation (globals, element/data segments)WasmStruct.java,WasmArray.java,WasmI31Ref.java— GC object typesinternal/GcRefStore.java— auto-keyed store for Wasm GC references with mark-sweep collection
MachineFactoryCompiler.java— entry point for the JVM bytecode compilerinternal/Compiler.java— translates Wasm opcodes to JVM bytecode
WasiPreview1.java— WASI preview1 host function implementationsWasiOptions.java— configuration (stdin/stdout/stderr, directories, env vars)
- Types should NOT add computation at runtime. Subtyping checks and type lookups should be pre-computed or cached where feasible.
- The hot path in the interpreter (
InterpreterMachine) must remain fast — avoid per-opcode type section lookups when they can be resolved at validation time. - The validator enriches instruction operands with type hints (e.g., source heap type for
ref.test/ref.cast/br_on_cast) so the interpreter can dispatch without guessing.
- Official WebAssembly spec: https://webassembly.github.io/spec/core/
- Validation algorithm appendix: https://webassembly.github.io/spec/core/appendix/algorithm.html
- GC proposal: https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md