lmcode-java-sample skill

Use lmcode-java-sample as a verified blueprint for embedding lmcode-java (vendor/lmcode-java) in a Java 21 (JVM & GraalVM Native Image) host application with schema discovery, R49 rule entries, dry mode, and LMCODE_RETURN framing.

Purpose

Demonstrate a complete, byte-pinned Java 21 (JVM & GraalVM Native Image) host application that exposes a 45-signature Shop/Ledger domain to DSLB v6 bytecode and passes the shared sample suite.

When to use it

Use lmcode-java-sample when learning how to bind Java 21 (JVM & GraalVM Native Image) domain objects, overloaded methods, operators, R49 rule entries, and LMCODE_RETURN result envelopes with lmcode-java (vendor/lmcode-java).

Install

Clone lmctl-ai/lmcode-java-sample and run ./test.sh with Java 21 (JVM & GraalVM Native Image), Python 3, Node 24.15 or later, and @lmctl-ai/lmctl 0.2.444 or later.

Commands

git clone https://github.com/lmctl-ai/lmcode-java-sample.git
cd lmcode-java-sample
python3 scripts/sync.py check
./build.sh
./test.sh
./bin/lmcode-java-sample --version
./bin/lmcode-java-sample --lmcode-schema --json
./bin/lmcode-java-sample --lmcode-signatures
./bin/lmcode-java-sample --lmcode sample-suite/bytecode/001-literals.dslb

Inputs and outputs

Safety rules

Worked examples

schema = load_schema(schema="sample-suite/sample.dsl.json");
program = _lmcode_ schema;
  ledger.record(shop.total());
  $return.balance = ledger.balance();
end _lmcode_
r = run_lmcode(program, {command:[ARGV[0], "--lmcode", "$DSLFILE"]});
require(r.ok, "sample host execution failed");

Errors and exit codes

CodePhaseExitCondition
LOAD_BAD_BYTECODEload3Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation
LOAD_BAD_SCHEMAload3Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract
LOAD_SCHEMA_MISMATCHload332-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes
LOAD_UNBOUNDload3Bytecode imports a context, function, or method signature not registered in the host Registry
RUN_ERRORrun3VM division or remainder by zero
RUN_HOSTrun3Host callback failure, invalid encoding, or expired collection handle
APP_FAILapp4Post-run application domain validation failure

How to verify

./test.sh