{"id":47281983,"url":"https://github.com/tegmentum/wamr4j","last_synced_at":"2026-04-02T15:45:43.473Z","repository":{"id":343785294,"uuid":"1047866388","full_name":"tegmentum/wamr4j","owner":"tegmentum","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-27T03:11:13.000Z","size":7223,"stargazers_count":1,"open_issues_count":52,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-27T14:23:55.837Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tegmentum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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-31T12:15:32.000Z","updated_at":"2026-03-27T03:11:17.000Z","dependencies_parsed_at":"2026-03-12T00:04:10.107Z","dependency_job_id":null,"html_url":"https://github.com/tegmentum/wamr4j","commit_stats":null,"previous_names":["tegmentum/wamr4j"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tegmentum/wamr4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwamr4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwamr4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwamr4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwamr4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tegmentum","download_url":"https://codeload.github.com/tegmentum/wamr4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tegmentum%2Fwamr4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31309282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2026-03-16T01:53:03.913Z","updated_at":"2026-04-02T15:45:43.465Z","avatar_url":"https://github.com/tegmentum.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WAMR4J\n\n[![Build Status](https://github.com/tegmentum/wamr4j/actions/workflows/ci.yml/badge.svg)](https://github.com/tegmentum/wamr4j/actions)\n[![Maven Central](https://img.shields.io/maven-central/v/ai.tegmentum.wamr4j/wamr4j)](https://central.sonatype.com/artifact/ai.tegmentum.wamr4j/wamr4j)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n\n**WAMR4J** provides unified Java bindings for the [WAMR (WebAssembly Micro Runtime)](https://github.com/bytecodealliance/wamr), offering both JNI and Panama Foreign Function API implementations with a common interface that abstracts engine-specific details.\n\n## Key Features\n\n- **Unified API**: Single interface for both JNI and Panama implementations\n- **Multi-Runtime**: Automatic JNI/Panama selection based on Java version\n- **Defensive Programming**: JVM crash prevention with comprehensive validation\n- **High Performance**: Optimized native bindings with minimal overhead\n- **Cross-Platform**: Support for Linux, macOS, and Windows (x86_64, ARM64)\n- **Zero Dependencies**: No external runtime dependencies\n- **Post-MVP Features**: Bulk Memory, Reference Types, and SIMD support\n\n## Quick Start\n\n### Maven Dependency\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eai.tegmentum\u003c/groupId\u003e\n    \u003cartifactId\u003ewamr4j\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle Dependency\n\n```gradle\nimplementation 'ai.tegmentum:wamr4j:1.0.0'\n```\n\n### Basic Usage\n\n```java\nimport ai.tegmentum.wamr4j.WebAssemblyRuntime;\nimport ai.tegmentum.wamr4j.WebAssemblyModule;\nimport ai.tegmentum.wamr4j.WebAssemblyInstance;\n\n// Load WebAssembly module\nbyte[] wasmBytes = Files.readAllBytes(Paths.get(\"module.wasm\"));\n\n// Create runtime (automatically selects JNI or Panama)\ntry (WebAssemblyRuntime runtime = WebAssemblyRuntime.create()) {\n    // Compile WebAssembly module\n    try (WebAssemblyModule module = runtime.loadModule(wasmBytes)) {\n        // Create instance with imports\n        Map\u003cString, Object\u003e imports = Map.of(\n            \"env.memory\", WebAssemblyMemory.create(1, 10),\n            \"env.print\", (WebAssemblyFunction) (args) -\u003e {\n                System.out.println(\"Hello from WebAssembly: \" + args[0]);\n                return new Object[0];\n            }\n        );\n        \n        try (WebAssemblyInstance instance = module.instantiate(imports)) {\n            // Call exported function\n            WebAssemblyFunction add = instance.getFunction(\"add\");\n            Object[] result = add.call(20, 22);\n            System.out.println(\"20 + 22 = \" + result[0]); // Output: 20 + 22 = 42\n        }\n    }\n}\n```\n\n## Architecture\n\nWAMR4J follows a multi-runtime architecture with automatic runtime selection:\n\n### Module Structure\n\n- **`wamr4j`**: Public API interfaces and factory (users only interact with this)\n- **`wamr4j-jni`**: JNI implementation for Java 11-22 (internal/private)\n- **`wamr4j-panama`**: Panama FFI implementation for Java 23+ (internal/private)  \n- **`wamr4j-native`**: Shared native Rust library for both implementations\n- **`wamr4j-benchmarks`**: Performance benchmarks comparing implementations\n- **`wamr4j-tests`**: Integration tests and WebAssembly test suites\n\n### Runtime Selection\n\nWAMR4J automatically selects the optimal runtime:\n\n1. **Java 23+**: Prefers Panama Foreign Function API (if available)\n2. **Java 11-22**: Uses JNI implementation\n3. **Fallback**: Uses JNI if Panama unavailable (with warning)\n4. **Manual Override**: Use system property `-Dwamr4j.runtime=jni` to force JNI\n\n## Development Setup\n\n### Prerequisites\n\n- **Java 11+** for core development\n- **Java 23+** for Panama Foreign Function API development (optional)\n- **Maven 3.8+** or use included wrapper (`./mvnw`)\n- **Git** for version control\n\n### Quick Setup (5 minutes)\n\n```bash\n# Clone the repository\ngit clone https://github.com/tegmentum-ai/wamr4j.git\ncd wamr4j\n\n# Build the project\n./mvnw clean compile\n\n# Run tests\n./mvnw test -q\n\n# Open in your favorite IDE\n# IntelliJ IDEA: File \u003e Open \u003e Select wamr4j directory\n# Eclipse: See eclipse/ECLIPSE_SETUP.md\n```\n\n### Essential Commands\n\n```bash\n# Build all modules\n./mvnw clean compile\n\n# Run tests (quiet mode)\n./mvnw test -q\n\n# Run static analysis (code quality checks)\n./mvnw checkstyle:check spotless:check spotbugs:check\n\n# Auto-format code\n./mvnw spotless:apply\n\n# Build and package\n./mvnw clean package\n\n# Install to local Maven repository\n./mvnw clean install\n```\n\n## Code Quality\n\nWAMR4J maintains high code quality standards:\n\n- **Google Java Style Guide**: Strict adherence to formatting and conventions\n- **Checkstyle**: Automated coding standards enforcement\n- **SpotBugs**: Static analysis for bug detection\n- **Spotless**: Automated code formatting\n- **100% Javadoc Coverage**: Comprehensive API documentation\n\n### Code Quality Commands\n\n```bash\n# Check code style compliance\n./mvnw checkstyle:check\n\n# Detect potential bugs\n./mvnw spotbugs:check\n\n# Verify code formatting\n./mvnw spotless:check\n\n# Auto-fix formatting issues\n./mvnw spotless:apply\n\n# Run all quality checks\n./mvnw checkstyle:check spotless:check spotbugs:check\n```\n\n## Performance\n\nWAMR4J is optimized for high-performance WebAssembly execution:\n\n- **Minimal Native Call Overhead**: Batched operations and efficient data transfer\n- **Memory Optimization**: Smart allocation patterns and GC-friendly design\n- **Defensive Safety**: JVM crash prevention without performance compromise\n- **Benchmarking Suite**: Comprehensive performance testing and monitoring\n\n### Benchmark Categories\n\n- **Runtime Benchmarks**: Runtime creation, module compilation, function invocation\n- **Memory Operations**: Load, store, and copy throughput (1KB operations)\n- **Large Module Compilation**: Scaling behavior with 10/100/500 function modules\n- **Function Call Overhead**: Calling conventions with 0-8 parameters (JNI vs Panama)\n\n### Running Benchmarks\n\n```bash\n# Build benchmark JAR\n./mvnw clean package -pl wamr4j-benchmarks\n\n# Run all benchmarks\njava -jar wamr4j-benchmarks/target/benchmarks.jar\n\n# Run specific benchmark\njava -jar wamr4j-benchmarks/target/benchmarks.jar MemoryOperationsBenchmark\n\n# Run with custom JMH options\njava -jar wamr4j-benchmarks/target/benchmarks.jar -wi 10 -i 20 -f 3\n```\n\n## Platform Support\n\n| Platform | Architecture | JNI Support | Panama Support | Status |\n|----------|-------------|-------------|----------------|---------|\n| Linux    | x86_64      | Yes         | Yes             | Stable  |\n| Linux    | ARM64       | Yes         | Yes             | Stable  |\n| macOS    | x86_64      | Yes         | Yes             | Stable  |\n| macOS    | ARM64 (M1+) | Yes         | Yes             | Stable  |\n| Windows  | x86_64      | Yes         | Yes             | Stable  |\n\n## Testing\n\nWAMR4J includes comprehensive test coverage with **183 passing tests**:\n\n### Test Categories\n\n- **Comparison Tests** (134 tests): Verify JNI and Panama implementations produce identical results\n  - Integer operations (i32/i64): arithmetic, bitwise, shifts, comparisons\n  - Floating-point operations (f32/f64): arithmetic, division, comparisons\n  - All WebAssembly MVP numeric operations\n\n- **Integration Tests** (4 tests): Complex real-world WebAssembly programs\n  - Fibonacci with memoization (memory + globals + recursion)\n  - Circular buffer (memory + globals + arithmetic)\n  - Calculator with dispatch table (tables + indirect calls)\n  - Array sum (memory + loops + locals)\n\n- **WAMR Engine Tests** (29 tests): Validate WAMR execution through bindings\n  - Control flow: blocks, loops, branches, calls, unreachable\n  - Memory: load, store, grow, data segments, bounds checking\n  - Type conversions: wrap, extend, trunc, convert, reinterpret\n  - Tables: indirect calls, out-of-bounds, recursion\n\n- **Post-MVP Feature Tests** (16 tests): Validate post-MVP WebAssembly features\n  - Bulk Memory Operations (5 tests): memory.copy, memory.fill, overlapping regions\n  - Reference Types (6 tests): funcref, externref, ref.null, ref.is_null, ref.func\n  - SIMD Operations (5 tests): v128 load/store, i32x4 arithmetic, lane operations\n\n### Test Coverage Report\n\nSee [`wamr4j-tests/TEST_COVERAGE_REPORT.md`](wamr4j-tests/TEST_COVERAGE_REPORT.md) for detailed coverage analysis.\n\n### Running Tests\n\n```bash\n# Run all tests (183 tests)\n./mvnw test\n\n# Run specific test module\n./mvnw test -pl wamr4j-tests\n\n# Run specific test category\n./mvnw test -Dtest=*ComparisonTest     # Comparison tests\n./mvnw test -Dtest=*IntegrationTest    # Integration tests\n./mvnw test -Dtest=*SpecTest          # WAMR engine tests\n./mvnw test -Dtest=*postmvp.*         # Post-MVP feature tests\n\n# Run with coverage report\n./mvnw test jacoco:report\n```\n\n### Test Quality\n\n- **No Mocks**: All tests use real WAMR engine\n- **Deterministic**: Consistent, reproducible results\n- **Fast**: Complete suite runs in ~12 seconds\n- **Isolated**: Proper resource cleanup\n- **Comprehensive**: Happy paths, edge cases, error conditions\n\n## Documentation\n\n- **[Development Guide](DEVELOPMENT.md)**: Comprehensive development setup and workflow\n- **[Troubleshooting Guide](TROUBLESHOOTING.md)**: Solutions to common issues\n- **[Static Analysis Guide](STATIC_ANALYSIS.md)**: Code quality tooling documentation  \n- **[API Documentation](https://tegmentum-ai.github.io/wamr4j/)**: Generated Javadoc\n- **[Eclipse Setup Guide](eclipse/ECLIPSE_SETUP.md)**: Eclipse IDE configuration\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [WAMR](https://github.com/bytecodealliance/wamr) and the [Bytecode Alliance](https://bytecodealliance.org/) for the WebAssembly Micro Runtime\n- The Java and Rust communities","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fwamr4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftegmentum%2Fwamr4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegmentum%2Fwamr4j/lists"}