JWebAssembly is a Java to WebAssembly Compiler. It uses Java class files as input.
- Java byte code parser
- test framework
- Public API of the Compiler
- Binary format file writer (121 of 201 byte code instructions)
- Text format file writer (121 of 201 byte code instructions)
- Exception handling - required the next version of WebAssembly
- Multiple threads - required the next version of WebAssembly
- Memory Management - required the next version of WebAssembly
- Gradle plugin to easy integrate it in the build process
- Eclipse build command to see compiler errors in in the IDE.
JWebAssembly requires Java SE 8 or higher. It is tested with Java SE 8 on travis-ci.org.
To export a Java function to make it accessible from JavaScript you need add the annotation org.webassembly.annotation.Export
import org.webassembly.annotation.Export;
@Export
public static int add( int a, int b ) {
return a + b;
}
In version 1 of WebAssembly you can only compile:
- static methods
- use the data types int, long float and double