网页 综合 更新时间 2026-11-13 17:22:57

GraalWasm

自动蜘蛛 www.graalvm.org 正文约 2725 字
GraalWasm
Documentation Graal Projects GraalVM Graal Stack Graal Dev Kit for Micronaut GraalOS GraalJS GraalPy GraalWasm Espresso Star A high-performance embeddable WebAssembly runtime for the JVM Quickstart Demos Benefits WebAssembly on the JVM Load and use Wasm modules and functions directly in Java WebAssembly 2.0 Support Full WebAssembly 2.0 compatibility and support for many feature extensions, including WASI Portable Native Extensions Integrate C, C++, Rust, and Go libraries using Wasm as an alternative to JNI or FFM API JavaScript integration Simplifies use of WebAssembly modules with JavaScript bindings Fastest Wasm on the JVM Graal JIT compiles Wasm for native code speed 100% Java Written in pure Java with zero native dependencies How to Get Started You have the option to extend your Java application with WebAssembly, or go straight to the starter project 1. Add GraalWasm as a dependency from Maven Central 1. Add GraalWasm as a dependency from Maven Central <dependency> <groupId>org.graalvm.polyglot</groupId> <artifactId>polyglot</artifactId> <version>25.3.4.1</version> </dependency> <dependency> <groupId>org.graalvm.polyglot</groupId> <artifactId>wasm</artifactId> <version>25.3.4.1</version> <type>pom</type> </dependency> or implementation("org.graalvm.polyglot:polyglot:25.3.4.1") implementation("org.graalvm.polyglot:wasm:25.3.4.1") 2. Create a WebAssembly module, for example with wat2wasm 2. Create a WebAssembly module, for example with wat2wasm ;; wat2wasm add-two.wat -o add-two.wasm (module (func (export "addTwo") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add ) ) 3. Embed the Wasm module in Java 3. Embed the Wasm module in Java import java.net.URL; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; try (Context context = Context.create()) { URL wasmFile = Main.class.getResource("add-two.wasm"); Value mainModule = context.eval(Source.newBuilder("wasm", wasmFile).build()); Value mainInstance = mainModule.newInstance(); Value addTwo = mainInstance.getMember("exports").getMember("addTwo"); System.out.println("addTwo(40, 2) = " + addTwo.execute(40, 2)); } Demos Embed C in Java Using GraalWasm Embed Go in Java Using GraalWasm Embed Photon Image Processing Library with GraalWasm in Micronaut Embed Rust in Java Using GraalWasm Embed Photon Image Processing Library with GraalWasm in Spring Boot Learn More Video: GraalVM meets WebAssembly at Devoxx 2025 Blog: Announcing GraalWasm — a WebAssembly engine in GraalVM Video: GraalWasm at Wasm I/O 2025 Open Source Project Repository Demos and Guides Contributing Help File an issue GraalVM Slack License Copyright© 2026. Oracle and/or its affiliates. All rights reserved.
访问原文 返回搜索 https://www.graalvm.org/webassembly/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。