2018-03-24 17:58:20 +01:00
2018-06-10 21:00:51 +02:00
2017-03-20 19:55:16 +01:00
2018-05-07 18:43:45 +02:00
2017-03-20 19:55:16 +01:00
2017-03-20 19:55:16 +01:00
2017-03-20 19:55:16 +01:00
2017-03-20 22:44:38 +01:00
2018-05-20 12:51:03 +02:00

JWebAssembly

Build Status License Coverage Status

JWebAssembly is a Java to WebAssembly compiler. It uses Java class files as input. That it can compile any language that compile to Java bytecode. As output it generates the binary format (.wasm file) or the text format (.wat file).

Status of the project

Finished Components

  • Java byte code parser
  • test framework
  • Public API of the Compiler

Partially Finished

  • Binary format file writer (145 of 201 byte code instructions)
  • Text format file writer (145 of 201 byte code instructions)

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.

Required Java Version

JWebAssembly requires Java SE 8 or higher. It is tested with Java SE 8 on travis-ci.org.

Usage

Exporting functions

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;
}

Java Limits

In version 1 of WebAssembly you can only compile:

  • static methods
  • use the data types int, long float and double

Alternatives

For Tool Developer

If you want to develop some tools like plugins for a build system or an IDE, then you need

Description
Java bytecode to WebAssembly compiler
Readme 2.4 MiB
Languages
Java 99.6%
JavaScript 0.4%