-
Notifications
You must be signed in to change notification settings - Fork 65
Debugging
If you have all compiled then you can run it in the browser. There is also a debugger support for WebAssembly code in the browser. If you build the WASM file with debugNames = true
then a source map is created. If the source map and the Java source files are accessible from the browser then you can debug through the Java code.
However, debugger support in the browser is very simple. You need first to build all, no hot code replacement and expression evaluation.
Since version 0.3 of the JWebAssembly-API there is an emulator with browser support. If you want run your web application in your Java IDE then you need to add the follow command line parameter to your Java launcher:
-javaagent:<path>/jwebassembly-api-0.3.jar
Replace <path>
with a real path. This can also be the path to the Gradle cache. Then create a launcher class in your test source folder with the follow code:
import de.inetsoftware.jwebassembly.emulator.JWebAssemblyEmulator;
public static void main( String[] args ) {
JWebAssemblyEmulator.launch( "yourHtmlPage.html", () -> YourMainClass.yourMainMethod() );
}
This will run a browser via JavaFX. Your code will run as pure Java Code in your IDE with all debug features of your Java IDE. There is no WebAssembly invoked. With the emulator you can find logical errors in your code and the jwebassembly-api code. You can't find problems that are related to WebAssembly or the JWebAssembly self.
If you use a Java version higher as Java 8 then you need to add JavaFX libraries for your platform. Suggestion for an improvement are welcome.