Files
luaj/README.md

102 lines
2.2 KiB
Markdown
Raw Normal View History

2026-03-03 10:55:46 +01:00
# LuaJ
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
LuaJ is a Java implementation of Lua with JSE and JME targets.
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
This fork is maintained by Open Autonomous Connection and is built with Maven only. The current codebase targets Lua 5.4 semantics in the supported runtime paths, including the recent work around `<close>`, `<const>`, updated weak-table behavior, binary chunk compatibility, and library alignment.
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
## Modules
2026-03-03 10:55:46 +01:00
- `core`: VM, compiler, standard runtime pieces
- `jse`: Java SE platform, JSR-223 integration, LuaJC support
- `jme`: Java ME platform support
2010-03-31 04:49:01 +00:00
2026-03-03 10:55:46 +01:00
## Requirements
2010-03-31 04:49:01 +00:00
2026-03-03 10:55:46 +01:00
- Java 25
- Maven 3.9+
2010-08-15 20:15:56 +00:00
2026-03-03 10:55:46 +01:00
The repository includes a Maven Wrapper:
2010-08-15 03:56:03 +00:00
2026-03-03 10:55:46 +01:00
- Windows: `mvnw.cmd`
- Unix-like shells: `./mvnw`
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
## Build
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
Build all modules:
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
```powershell
.\mvnw.cmd clean package
```
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
Run the full test suite:
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
```powershell
.\mvnw.cmd clean test
```
2026-03-03 10:55:46 +01:00
Build a single module with dependencies:
2026-03-03 10:55:46 +01:00
```powershell
.\mvnw.cmd -pl jse -am package
```
2026-03-03 10:55:46 +01:00
## Quick Start
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
Minimal JSE embedding example:
2008-12-03 01:41:21 +00:00
2026-03-03 10:55:46 +01:00
```java
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
2026-03-03 10:55:46 +01:00
import org.luaj.vm2.libs.jse.JsePlatform;
2010-05-09 05:36:03 +00:00
2026-03-03 10:55:46 +01:00
Globals globals = JsePlatform.standardGlobals();
LuaValue chunk = globals.load("print('hello, world')");
chunk.call();
```
2009-04-23 04:57:47 +00:00
2026-03-03 10:55:46 +01:00
## Maven Usage
2009-04-23 04:57:47 +00:00
2026-03-03 10:55:46 +01:00
Use the published modules directly from Maven:
2009-04-23 04:57:47 +00:00
2026-03-03 10:55:46 +01:00
```xml
<dependency>
<groupId>org.openautonomousconnection.luaj</groupId>
<artifactId>jse</artifactId>
<version>3.0.2</version>
</dependency>
```
2026-03-03 10:55:46 +01:00
For the core VM without the JSE platform layer:
2026-03-03 10:55:46 +01:00
```xml
<dependency>
<groupId>org.openautonomousconnection.luaj</groupId>
<artifactId>core</artifactId>
<version>3.0.2</version>
</dependency>
```
2026-03-03 10:55:46 +01:00
## Notable Runtime Notes
2026-03-03 10:55:46 +01:00
- LuaJ runs on the host JVM garbage collector. Resource cleanup is not equivalent to native Lua finalization.
- Explicit close is still the correct pattern for files, iterators, and host-backed resources.
- `LuaJC` is available on JSE and covered by the current Maven test path.
- JME support remains in the Maven build, with environment-specific limitations depending on available Java ME APIs.
2026-03-03 10:55:46 +01:00
## Examples
2014-01-02 15:55:36 +00:00
2026-03-03 10:55:46 +01:00
Relevant examples are in:
2026-03-03 10:55:46 +01:00
- `examples/jse`
- `examples/jme`
- `examples/lua`
- `examples/maven`
2026-03-03 10:55:46 +01:00
## Status
2026-03-03 10:55:46 +01:00
Current implementation notes for the Lua 5.4 work are tracked in `LUA54_STATUS.md`.
2026-03-03 10:55:46 +01:00
## License
2010-03-31 04:49:01 +00:00
2026-03-03 10:55:46 +01:00
This project is distributed under the terms in `LICENSE`.