2017-03-19 11:54:29 +01:00
|
|
|
JWebAssembly
|
|
|
|
======
|
|
|
|
|
2017-03-20 22:07:39 +01:00
|
|
|
[](https://travis-ci.org/i-net-software/JWebAssembly)
|
2017-03-20 20:19:47 +01:00
|
|
|
[](https://github.com/i-net-software/jwebassembly/blob/master/LICENSE.txt)
|
2017-03-19 11:54:29 +01:00
|
|
|
|
2017-03-26 11:25:02 +02:00
|
|
|
JWebAssembly is a Java to [WebAssembly](http://webassembly.org/) Compiler. It uses Java class files as input.
|
2017-03-19 11:54:29 +01:00
|
|
|
|
|
|
|
Status of the project
|
|
|
|
----
|
|
|
|
|
2018-03-28 20:09:35 +02:00
|
|
|
### Finished Components
|
|
|
|
* Java byte code parser
|
|
|
|
* test framework
|
|
|
|
* Public API of the Compiler
|
|
|
|
|
|
|
|
### Partially Finished
|
2018-04-02 19:15:42 +02:00
|
|
|
* Binary format file writer (134 of 201 byte code instructions)
|
|
|
|
* Text format file writer (134 of 201 byte code instructions)
|
2018-03-31 19:26:22 +02:00
|
|
|
|
|
|
|
### Open Features
|
|
|
|
* 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.
|
2017-03-19 11:54:29 +01:00
|
|
|
|
|
|
|
Required Java Version
|
|
|
|
----
|
|
|
|
JWebAssembly requires Java SE 8 or higher. It is tested with Java SE 8 on [travis-ci.org](https://travis-ci.org/i-net-software/jwebassembly).
|
|
|
|
|
2017-04-11 21:40:53 +02:00
|
|
|
## Usage
|
2017-03-19 11:54:29 +01:00
|
|
|
|
2017-04-11 21:40:53 +02:00
|
|
|
### Exporting functions
|
2017-04-14 11:06:57 +02:00
|
|
|
To export a Java function to make it accessible from JavaScript you need add the annotation org.webassembly.annotation.Export
|
2017-04-11 21:40:53 +02:00
|
|
|
|
|
|
|
```java
|
|
|
|
import org.webassembly.annotation.Export;
|
|
|
|
|
|
|
|
@Export
|
|
|
|
public static int add( int a, int b ) {
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Java Limits
|
2017-04-14 11:06:57 +02:00
|
|
|
In version 1 of WebAssembly you can only compile:
|
2017-04-11 21:40:53 +02:00
|
|
|
* static methods
|
|
|
|
* use the data types int, long float and double
|
2017-04-14 11:06:57 +02:00
|
|
|
|
|
|
|
### Alternatives
|
|
|
|
* [TeaVM](https://github.com/konsoletyper/teavm)
|