diff --git a/README.md b/README.md index ff0c511..c5b77d9 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ JWebAssembly requires Java SE 8 or higher. It is tested with Java SE 8 on [travi ## Usage ### Exporting functions -To export a Java function to make it accessible from JavaScript you need add the annotation org.webassembly.annotation.Export +To export a Java function to make it accessible from JavaScript you need add the annotation de.inetsoftware.jwebassembly.api.annotation.Export. ```java -import org.webassembly.annotation.Export; +import de.inetsoftware.jwebassembly.api.annotation.Export; @Export public static int add( int a, int b ) { @@ -45,6 +45,20 @@ public static int add( int a, int b ) { } ``` +### importing functions +To import a JavaScript function to make it accessible from Java you need add the annotation de.inetsoftware.jwebassembly.api.annotation.Import. +The method can be declared native or can have a Java implementation which will be ignored on compiling. + +```java +import de.inetsoftware.jwebassembly.api.annotation.Import; + +@Import( module = "global.Math", name = "max" ) +static int max( int a, int b) { + return Math.max( a, b ); +} +``` + + ### Java Limits In version 1 of WebAssembly you can only compile: * static methods