-
Notifications
You must be signed in to change notification settings - Fork 64
Compiler Errors and Problems
Volker Berlin edited this page May 27, 2022
·
5 revisions
JWebAssembly can only compile pure Java code into WebAssembly code. The JDK contains a lot of native code. If you want to use this native Java code, you need a library that provides a replacement for the native methods. For the browser, you can use the jwebassembly-api library. For a WAPI target, you need a different library.
- if you have not added a library, the first step is to add one.
- if this does not help, then you can write a replacement for the method using the @Replace annotation.
- alternatively, you can analyze why this native method is needed. If you set the debug flag, the compiler will output in what order the methods were scanned. If there is a method in the scan order that you never need at runtime, then override it to stop the scan and compilation at that point.
If you find a good replacement for a native method that can also help others, make a pull request [jwebassembly-api] (https://github.com/i-net-software/JWebAssembly-API).
If the WebAssembly output file (*.wasm) is very small (about 100 bytes), then the compiler did not find an @Export annotation. The compiler compiles only the methods marked with the @Export annotation and all the referenced Java code. The cause may be:
- adding the Java sources failed. Are there compiled Java classes?
- you have not added the @Export annotation to one of your methods.