You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use wasmer-java to create a sample Java application that would be able to import and execute an Open Policy Agent policy compiled to WASM. More details about Open Policy Agent can be found here: https://www.openpolicyagent.org/docs/latest/wasm/.
An Open Policy Agent compiled WASM has a couple of imports, here is an excerpt from a policy.wasm using WASM text format:
Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: 7 link errors: (1 of 7) Import not found, namespace: env, name: opa_abort (2 of 7) Import not found, namespace: env, name: opa_builtin0 (3 of 7) Import not found, namespace: env, name: opa_builtin1 (4 of 7) Import not found, namespace: env, name: opa_builtin2 (5 of 7) Import not found, namespace: env, name: opa_builtin3 (6 of 7) Import not found, namespace: env, name: opa_builtin4 (7 of 7) Import not found, namespace: env, name: memory
at org.wasmer.Instance.nativeInstantiate(Native Method)
at org.wasmer.Instance.<init>(Instance.java:45)
at com.adobe.target.gw.Application.main(Application.java:12)
Proposed solution
As far as I can tell by looking here https://github.com/wasmerio/wasmer-java/blob/master/src/instance.rs#L26, we always pass an empty imports value. It would be great if we could pass some kind of object to Instance.nativeInstantiate(...) that would allow us to populate the "imports" before passing to wasmer runtime.
In the browser when loading WASM we can pass an import object like WebAssembly.instantiate(bufferSource, importObject), so it would be nice to have something similar in wasmer-java.
Alternatives
Not sure if there are other alternatives
Additional context
None
The text was updated successfully, but these errors were encountered:
Motivation
I was trying to use
wasmer-java
to create a sample Java application that would be able to import and execute an Open Policy Agent policy compiled to WASM. More details about Open Policy Agent can be found here: https://www.openpolicyagent.org/docs/latest/wasm/.An Open Policy Agent compiled WASM has a couple of imports, here is an excerpt from a
policy.wasm
using WASM text format:When trying to load use a
policy.wasm
from a simple Java app like the one below:I get the following exception:
Proposed solution
As far as I can tell by looking here https://github.com/wasmerio/wasmer-java/blob/master/src/instance.rs#L26, we always pass an empty imports value. It would be great if we could pass some kind of object to
Instance.nativeInstantiate(...)
that would allow us to populate the "imports" before passing to wasmer runtime.In the browser when loading WASM we can pass an import object like
WebAssembly.instantiate(bufferSource, importObject)
, so it would be nice to have something similar inwasmer-java
.Alternatives
Not sure if there are other alternatives
Additional context
None
The text was updated successfully, but these errors were encountered: