https://github.com/caoccao/qjs4j
Native Java implementation of QuickJS
https://github.com/caoccao/qjs4j
java javascript quickjs quickjs-runtime
Last synced: about 1 month ago
JSON representation
Native Java implementation of QuickJS
- Host: GitHub
- URL: https://github.com/caoccao/qjs4j
- Owner: caoccao
- License: apache-2.0
- Created: 2025-12-24T12:04:41.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-01-02T14:40:05.000Z (about 2 months ago)
- Last Synced: 2026-01-03T01:43:53.405Z (about 2 months ago)
- Topics: java, javascript, quickjs, quickjs-runtime
- Language: Java
- Homepage:
- Size: 1.06 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# qjs4j
[](https://github.com/caoccao/qjs4j/actions) [](https://opensource.org/licenses/Apache-2.0)
qjs4j is a native Java implementation of QuickJS - a complete reimplementation of the QuickJS JavaScript engine in pure Java (JDK 17+, zero external dependencies).
## Project Status
qjs4j implements ES2024 features with full QuickJS specification compliance. See [detailed feature list](docs/migration/FEATURES.md) for comprehensive implementation status.
### Features Beyond QuickJS
qjs4j includes features not present in the original QuickJS:
- **Float16Array**: IEEE 754 half-precision (16-bit) floating point typed array support
- **ES2024 Features**: Promise.withResolvers, Object.groupBy, Map.groupBy
- **Enhanced Module System**: Complete ES6 module implementation with dynamic import()
- **Microtask Queue**: Full ES2020-compliant microtask infrastructure
### Not Yet Implemented
The following QuickJS features are planned but not yet implemented:
- **Internationalization (Intl)**: i18n support for dates, numbers, and strings
- **Top-level await**: Module-level await expressions
See [ASYNC_AWAIT_ENHANCEMENTS.md](docs/migration/ASYNC_AWAIT_ENHANCEMENTS.md) for async/await implementation details.
## Documentation
- **[Features](docs/migration/FEATURES.md)**: Complete list of implemented JavaScript features
- **[Migration Status](docs/migration/MIGRATION_STATUS.md)**: Migration progress from QuickJS C to Java
- **[Async/Await](docs/migration/ASYNC_AWAIT_ENHANCEMENTS.md)**: Async/await and iteration implementation
## Quick Start
```java
import com.caoccao.qjs4j.core.*;
// Create a JavaScript runtime and context
try (JSContext context = new JSContext(new JSRuntime())) {
// Evaluate JavaScript code
JSValue result = context.eval("2 + 2");
System.out.println(result); // 4
// Work with objects
JSValue obj = context.eval("({ name: 'qjs4j', version: '1.0' })");
if (obj instanceof JSObject jsObj) {
JSValue name = jsObj.get("name");
System.out.println(name); // qjs4j
}
// Use modern JavaScript features
JSValue promise = context.eval("Promise.resolve(42)");
// Process microtasks to settle promises
context.processMicrotasks();
}
```
## Architecture
qjs4j is organized into modular packages:
- **core**: Runtime components (JSValue types, JSContext, JSRuntime)
- **vm**: Virtual machine with bytecode execution and stack management
- **builtins**: JavaScript built-in objects and prototype methods
- **compiler**: Parser, lexer, bytecode compiler, and AST
Key technical features:
- Shape-based optimization with hidden classes
- Proper SameValueZero equality for Map/Set
- Complete iterator and async iterator protocols
- Full prototype-based inheritance
- Weak references using Java WeakHashMap
## License
Apache License 2.0 - see [LICENSE](LICENSE) file for details.