lmcode-java reference

Reference tables for the io.lmctl.lmcode Java 21 classes, methods, lmcode_std_v3 REST/CLI interfaces, and VmException error codes.

Host SDK API surface

APIType / ReturnDescription
new Registry()RegistryConstruct a registry with all 226 lmcode_std_v3 signatures registered
new Registry(false)RegistryConstruct an empty registry without standard library signatures
registry.context(name, type)RegistryDeclare a host context object slot
registry.function(name, params, ret, cb)RegistryRegister a host function overload (accepts optional Registry.dry(cb) fifth argument)
registry.method(owner, name, params, ret, cb)RegistryRegister a host method overload (accepts optional Registry.dry(cb) sixth argument)
registry.signatures()List<String>Return sorted canonical signatures registered in this Registry
Program.load(bytecode, schema, registry)ProgramVerify DSLB v6 bytes against exact schema bytes and bind imports
program.entries()List<Program.Entry>Return immutable source-ordered R49 entry metadata
program.run(context, registry)voidExecute the program body
program.call(entryIndex, context, registry, args)ValueInvoke an R49 entry by index
program.callIsolated(entryIndex, context, registry, args)ValueInvoke an entry without resetting or colliding with an active outer run arena
Rest.registerRest(registry, options)RestControllerBind the 20 standard REST/CLI signatures to a configured RestController
restController.run(program, context)voidRun the program body and serve HTTP/1.1 over stdio if rest_serve() was called
restController.dispatch(request)RestHttp.ResponseDispatch one HTTP request in memory
InvocationResults.fromCommand(files)InvocationResultsCreate per-part result collector from CLI file list and LMCODE_INVOCATION_FILE

Standard REST and CLI interfaces (lmcode_std_v3)

The default lmcode_std_v3 catalog provides 226 canonical signatures and 10 standard interfaces on RestExchange for HTTP/1.1 stdio endpoints and stateless CLI commands.

InterfaceCanonical declarationBehavior
RestGetinterface RestGet(exchange: RestExchange) -> voidHTTP GET endpoint bound by path annotation such as @"/users/:id"
RestPostinterface RestPost(exchange: RestExchange) -> voidHTTP POST endpoint bound by path annotation such as @"/users"
RestPutinterface RestPut(exchange: RestExchange) -> voidHTTP PUT endpoint bound by path annotation such as @"/users/:id"
RestDeleteinterface RestDelete(exchange: RestExchange) -> voidHTTP DELETE endpoint bound by path annotation such as @"/users/:id"
RestPatchinterface RestPatch(exchange: RestExchange) -> voidHTTP PATCH endpoint bound by path annotation such as @"/users/:id"
RestHeadinterface RestHead(exchange: RestExchange) -> voidHTTP HEAD endpoint bound by path annotation
RestOptionsinterface RestOptions(exchange: RestExchange) -> voidHTTP OPTIONS endpoint bound by path annotation
RestHandlerinterface RestHandler(exchange: RestExchange) -> voidMethod-prefixed (@"POST /users") or rest_route(method, path, annotation) handler
CliCommandinterface CliCommand(exchange: RestExchange) -> voidStateless CLI subcommand entry dispatched by rest_cli(args)
CliOptioninterface CliOption(exchange: RestExchange) -> voidStateless CLI flag or option entry dispatched before CliCommand by rest_cli(args)

Standard REST and CLI functions and methods

NameCanonical signatureDescription
rest_configfn rest_config(string, string) -> voidSet controller configuration keys such as prefix, max_body_bytes, or session before rest_serve()
rest_routefn rest_route(string, string, string) -> voidBind an HTTP method and path template (:param, :rest..., {param}, {rest...}) to a RestHandler annotation
rest_servefn rest_serve() -> voidValidate registered routes and request HTTP/1.1 stdio serving after the program body finishes
rest_stopfn rest_stop() -> voidStop stdio HTTP/1.1 serving after the active response finishes flushing
rest_clifn rest_cli(StrList) -> stringDispatch a single stateless CLI argv vector across CliOption, CliCommand, or REST routes and return the response body
RestExchange.methodmethod RestExchange.method() -> stringReturn the uppercase HTTP method verb for the active request
RestExchange.pathmethod RestExchange.path() -> stringReturn the percent-decoded request path without the query string
RestExchange.querymethod RestExchange.query(string) -> stringReturn the first value of a query key or empty string when absent
RestExchange.has_querymethod RestExchange.has_query(string) -> boolReturn true when the query key is present in the request target
RestExchange.parammethod RestExchange.param(string) -> stringReturn a matched path parameter from :param or :rest... (or {param} / {rest...})
RestExchange.headermethod RestExchange.header(string) -> stringReturn case-insensitive header value (repeated headers joined by comma-space)
RestExchange.has_headermethod RestExchange.has_header(string) -> boolReturn true when the header is present on the request
RestExchange.bodymethod RestExchange.body() -> stringReturn raw request body bytes
RestExchange.statusmethod RestExchange.status(int) -> voidSet HTTP response status code in range 200..599
RestExchange.set_headermethod RestExchange.set_header(string, string) -> voidSet or replace a response header outside managed framing headers
RestExchange.sendmethod RestExchange.send(string) -> voidReplace response body with raw bytes
RestExchange.jsonmethod RestExchange.json(string) -> voidReplace response body and set Content-Type to application/json
RestExchange.getmethod RestExchange.get(string) -> stringRead server-wide shared string state key or empty string when absent
RestExchange.setmethod RestExchange.set(string, string) -> voidWrite server-wide shared string state key
RestExchange.incrementmethod RestExchange.increment(string) -> intAtomically increment a named integer counter starting at 1

Structured error codes and exit statuses

Error codePhaseExit statusTrigger condition
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