lmteavm application authoring skill

Use the lmteavm example to embed annotation-dispatched LMCode entries in a TeaVM browser application.

Purpose

Build browser behavior in Java, expose typed host callbacks to LMCode, and dispatch LMCode interface entries by annotation. The quick reference contains copyable schema, LMCode, Java, and JSON examples.

When to use it

Use this pattern when a browser application needs LMCode behavior with explicit host capabilities, or when Java browser infrastructure and LMCode handlers should share a typed contract. Start with the working demo and its public source.

Install

Install Java 21, Maven, Node 24.15 or newer, lmcode-java 0.1.1 in the local Maven repository, and @lmctl-ai/lmctl 0.2.482 or newer. Set LMCODE_COMPILER_MODULE to the compiler package's dist/dsl.js.

Commands

mvn clean package
npm ci
npx playwright install --with-deps chromium
npm test

Inputs and outputs

Safety rules

Worked examples

  1. Read the demo's DemoHandler, DrawCommand, and TodoHandler interfaces.
  2. Add an annotation and function implementing DemoHandler.
  3. Register any required host callback with Registry.function.
  4. Resolve the annotation through program.entries() and invoke Program.call.
  5. For data-driven drawing, add a JSON document using the shared @data and @draw entries rather than duplicating the renderer.

Errors and exit codes

Compiler diagnostics and Maven failures produce a nonzero build exit. Program.load reports schema mismatches and unbound imports. Browser integration assertions produce a nonzero test exit; inspect the reported status, console errors, and page errors.

How to verify

  1. Run a clean Maven build.
  2. Run npm test with Chromium installed.
  3. Exercise each changed mode through real browser events.
  4. Check JSON requests and visible output, not only compilation.
  5. For canvas and WebGL, verify rendered pixels and the absence of browser or GL errors.