lmcode-java skill

Use lmcode-java to embed the DSLB v6 verifier and virtual machine into Java 21 or GraalVM Native Image host applications.

Purpose

Provide a JDK-only bytecode loader, stack VM, 226-signature standard library, stdio REST/CLI controller, and invocation result framer for JVM and native executables.

When to use it

Use lmcode-java when building a Java, Kotlin, or Scala host application or GraalVM native binary that executes schema-bound lmcode programs.

Install

Build with JDK 21 and Maven 3.6.3+ (mvn -q verify), or vendor src/main/java/io/lmctl/lmcode directly into your project.

Commands

mvn -q verify
./scripts/build-native.sh
lmctl autorun examples/byte_strings.lms

Inputs and outputs

Safety rules

Worked examples

Registry registry = new Registry();
registry.function("greet", List.of("string"), "string", (ctx, self, args) ->
    Value.ofString(VmString.fromString("hello " + args[0].asString().toString()))
);
Program program = Program.load(bytecodeBytes, schemaBytes, registry);
Context context = new Context();
program.run(context, registry);

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, or loop-free operand stack underflow
RUN_HOSTrun3Host callback failure, invalid encoding, expired collection handle, or REST route validation failure
APP_FAILapp4Post-run application domain validation failure or output stream write failure

How to verify

mvn -q verify
lmscript test.lms