Repository navigation
klua 0.2.0
klua 0.2.0
Android support and a proper sandbox for untrusted Lua.
Android
- New artifact
pw.binom:klua-android— acom.android.libraryAAR (minSdk24) that ships prebuiltlibklua.soforarm64-v8aandx86_64and loads it viaSystem.loadLibrary("klua"). 32-bit ABIs are not packaged. - New Kotlin/Native targets
androidNativeArm64/androidNativeX64(removedandroidNativeArm32/androidNativeX86). - The JNI Kotlin now lives in a shared
jvmSharedMainsource set used by bothjvmMain(desktop jar loader) andandroidMain; the platform seam isexpect fun loadNativeLibrary().
Sandboxing
LuaEngine(libraries: Set<LuaLibrary> = emptySet(), ...)— per-library standard-library selection (LuaLibrary.ALL,LuaLibrary.SAFE). A fresh engine is still bare (noos/io/package/debug).- Binary chunks are rejected by default (
allowBinaryChunks = false):evalcompiles text-only and the same restriction is applied to Lua'sload/loadstring/loadfile/dofile. - Execution limits (
LuaLimits(maxInstructions, timeout, maxMemoryBytes)): instruction cap, wall-clock deadline and memory cap, enforced by a shared C core (customlua_Alloc+LUA_MASKCOUNThook) used by both the JNI and Kotlin/Native backends. Violations throwLuaLimitException(kind);pcallcannot swallow them. LuaEngine.cancel()cooperatively aborts a long-running eval from another thread (LuaLimitKind.CANCELLED).
Fixes / build
- Replaced
java.lang.ref.Cleaner(API 33+) with aPhantomReference-based cleaner plus deferred, owner-thread unref, fixing a cross-thread race and keepingminSdk24. - Untracked
build/and.gradle/outputs. - CI: release workflow now installs the Android SDK, packages the AAR, runs a bionic/glibc ABI gate (
readelf), and checks that build outputs are not tracked.
Tests
jvmTest61/61,linuxX64Test50/50 (library selection, binary-chunk rejection, execution limits).