{"id":48141834,"url":"https://github.com/tegmentum/wasmtime4j","last_synced_at":"2026-04-04T16:53:46.858Z","repository":{"id":343125760,"uuid":"1045294959","full_name":"tegmentum/wasmtime4j","owner":"tegmentum","description":"Java bindings for the Wasmtime WebAssembly runtime","archived":false,"fork":false,"pushed_at":"2026-03-27T15:22:49.000Z","size":296888,"stargazers_count":2,"open_issues_count":198,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-27T15:53:41.642Z","etag":null,"topics":["java","wasmtime","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tegmentum.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-27T00:18:53.000Z","updated_at":"2026-03-27T15:20:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tegmentum/wasmtime4j","commit_stats":null,"previous_names":["tegmentum/wasmtime4j"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tegmentum/wasmtime4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwasmtime4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwasmtime4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwasmtime4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwasmtime4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tegmentum","download_url":"https://codeload.github.com/tegmentum/wasmtime4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwasmtime4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31406622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","wasmtime","webassembly"],"created_at":"2026-04-04T16:53:46.795Z","updated_at":"2026-04-04T16:53:46.844Z","avatar_url":"https://github.com/tegmentum.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wasmtime4j\n\n[![Build Status](https://github.com/tegmentum/wasmtime4j/actions/workflows/ci.yml/badge.svg)](https://github.com/tegmentum/wasmtime4j/actions)\n[![Maven Central](https://img.shields.io/maven-central/v/ai.tegmentum/wasmtime4j)](https://central.sonatype.com/artifact/ai.tegmentum/wasmtime4j)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n\nJava bindings for the [Wasmtime](https://wasmtime.dev/) WebAssembly runtime. Provides both JNI and Panama Foreign Function Interface implementations with automatic runtime selection based on Java version.\n\nBuilt against **Wasmtime 43.0.0**.\n\n## Features\n\n- **Dual runtime**: JNI for Java 8-22, Panama FFI for Java 23+ (auto-detected)\n- **Full Wasmtime API**: Engine, Module, Instance, Store, Linker, host functions, memory, tables, globals\n- **Component Model**: First-class support for the WebAssembly Component Model\n- **WASI**: WASI Preview 1 and Preview 2 support\n- **Typed function calls**: Zero-boxing fast paths for common signatures (`i32 -\u003e i32`, `(i32, i32) -\u003e i32`, etc.)\n- **Cross-platform**: Linux, macOS, Windows on x86_64 and ARM64\n- **Resource safety**: All resources implement `AutoCloseable` with defensive lifecycle management\n\n## Quick Start\n\nAdd the dependency:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eai.tegmentum\u003c/groupId\u003e\n    \u003cartifactId\u003ewasmtime4j\u003c/artifactId\u003e\n    \u003cversion\u003e43.0.0-1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n### Basic Usage\n\n```java\nimport ai.tegmentum.wasmtime4j.*;\nimport ai.tegmentum.wasmtime4j.factory.WasmRuntimeFactory;\n\ntry (WasmRuntime runtime = WasmRuntimeFactory.create();\n     Engine engine = runtime.createEngine();\n     Module module = engine.compileModule(wasmBytes);\n     Store store = engine.createStore();\n     Instance instance = module.instantiate(store)) {\n\n    WasmFunction add = instance.getFunction(\"add\").orElseThrow();\n\n    // Generic call with WasmValue boxing\n    WasmValue[] result = add.call(WasmValue.i32(5), WasmValue.i32(3));\n    System.out.println(result[0].asInt()); // 8\n\n    // Typed fast-path call (zero boxing overhead)\n    int sum = add.callI32I32ToI32(5, 3); // 8\n}\n```\n\n### Runtime Selection\n\n```java\n// Automatic (recommended) - picks Panama on Java 23+, JNI otherwise\nWasmRuntime runtime = WasmRuntimeFactory.create();\n\n// Manual override\nWasmRuntime jni = WasmRuntimeFactory.createJni();\nWasmRuntime panama = WasmRuntimeFactory.createPanama(); // Java 23+ only\n\n// Override via system property\n// -Dwasmtime4j.runtime=jni\n```\n\n## Host Functions\n\n```java\nLinker linker = runtime.createLinker(engine);\n\nlinker.defineFunction(\"env\", \"log\", new FunctionType(\n    new WasmValueType[]{WasmValueType.I32}, new WasmValueType[]{}),\n    (caller, args) -\u003e {\n        System.out.println(\"WASM says: \" + args[0].asInt());\n        return new WasmValue[0];\n    });\n\nInstance instance = linker.instantiate(store, module);\n```\n\n## Memory Access\n\n```java\nWasmMemory memory = instance.getMemory(\"memory\").orElseThrow();\n\nbyte[] data = memory.read(0, 1024);\nmemory.write(0, \"Hello, WASM!\".getBytes());\nmemory.grow(1); // Grow by 1 page (64KB)\n```\n\n## Engine Configuration\n\n```java\nEngineConfig config = new EngineConfig()\n    .optimizationLevel(OptimizationLevel.SPEED)\n    .consumeFuel(true)\n    .parallelCompilation(true);\n\nEngine engine = runtime.createEngine(config);\n```\n\n## WASI\n\n```java\nWasiConfig wasiConfig = new WasiConfig()\n    .inheritEnv()\n    .inheritStdin()\n    .inheritStdout()\n    .inheritStderr();\n\nStore store = engine.createStore();\nstore.setWasiConfig(wasiConfig);\n```\n\n## Project Structure\n\n```\nwasmtime4j/\n├── wasmtime4j/               # Public API interfaces and factory (users depend on this)\n├── wasmtime4j-native/        # Shared Rust library with JNI + Panama C exports\n├── wasmtime4j-jni/           # JNI runtime implementation (Java 8+)\n├── wasmtime4j-panama/        # Panama FFI runtime implementation (Java 23+)\n├── wasmtime4j-native-loader/ # Cross-platform native library extraction and loading\n├── wasmtime4j-tests/         # Integration tests and WebAssembly test suites\n└── wasmtime4j-benchmarks/    # JMH benchmarks for JNI vs Panama comparison\n```\n\nThe native library is built from Rust source in `wasmtime4j-native/` and bundled into a\nsingle JAR containing binaries for all supported platforms. At runtime, `wasmtime4j-native-loader`\ndetects the platform and extracts the correct library.\n\n## Building from Source\n\nRequires Java 23+, Rust (stable), and Maven 3.6+.\n\n```bash\n# Build\n./mvnw clean compile\n\n# Test\n./mvnw test\n\n# Package\n./mvnw clean package\n\n# Code style\n./mvnw spotless:apply\n```\n\n## Platform Support\n\n| Platform | Architecture | JNI | Panama |\n|----------|-------------|-----|--------|\n| Linux    | x86_64      | Yes | Yes    |\n| Linux    | ARM64       | Yes | Yes    |\n| macOS    | ARM64       | Yes | Yes    |\n| Windows  | x86_64      | Yes | Yes    |\n\nAdditional platforms can be added on request.\n\n## Benchmarks\n\n```bash\n# Run JNI vs Panama comparison benchmarks\njava --enable-native-access=ALL-UNNAMED \\\n  -jar wasmtime4j-benchmarks/target/wasmtime4j-benchmarks.jar \\\n  -f 1 -wi 2 -i 3 \".*PanamaVsJniBenchmark.*\"\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n```bash\n# Development workflow\ngit clone https://github.com/tegmentum/wasmtime4j.git\ncd wasmtime4j\n./mvnw test\n# Make changes, ensure tests pass\n# Submit a pull request\n```\n\nThe project follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Run `./mvnw spotless:apply` to auto-format.\n\n## License\n\nLicensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.\n\n## Acknowledgments\n\n- [Wasmtime](https://wasmtime.dev/) and the [Bytecode Alliance](https://bytecodealliance.org/) for the WebAssembly runtime\n- The Java and Rust communities\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fwasmtime4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftegmentum%2Fwasmtime4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fwasmtime4j/lists"}