i-net-software / i-net-software/JWebAssembly
@Import does't work
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
de.inetsoftware.jwebassembly.api.annotation.Import Does not include the import function definition, is it currently not supported?
demo: https://github.com/zonghaishang/wasm-java/tree/jwebassembly
```
package com.alipay.wasm;
import de.inetsoftware.jwebassembly.JWebAssembly;
import de.inetsoftware.jwebassembly.api.annotation.Export;
import de.inetsoftware.jwebassembly.api.annotation.Import;
import java.io.File;
import java.net.URL;
public class WasmFunctions {
@Export
public static int hello() {
return 43;
}
// does't work ??
@Import
public static native int max(int a, int b) ;
public static void main(String[] args) {
File file = new File("build/test.wasm");
JWebAssembly wasm = new JWebAssembly();
Class clazz = WasmFunctions.class;
URL url = clazz.getResource("/" + clazz.getName().replace(".", "/") + ".class");
wasm.addFile(url);
System.out.println(wasm.compileToText());
wasm.compileToBinary(file);
}
}
```
```
➜ build git:(jwebassembly) ✗ wasm-objdump -x test.wasm -j Import
test.wasm: file format wasm 0x1
Section Details:
Section not found: Import
```
```
➜ build git:(jwebassembly) ✗ wasm-objdump -x test.wasm
test.wasm: file format wasm 0x1
Section Details:
Type[1]:
- type[0] () -> i32
Function[1]:
- func[0] sig=0
Export[1]:
- func[0] -> "hello"
Code[1]:
- func[0] size=5
Custom:
- name: "producers"
```
```
➜ build git:(jwebassembly) ✗ wasm-objdump -x test.wasm -j Export
test.wasm: file format wasm 0x1
Section Details:
Export[1]:
- func[0] -> "hello"
```
Contributor guide
Assessment
This issue has not been assessed yet.