Migration from CheerpJ 2
CheerpJ 3 is a complete reimplementation of CheerpJ 2, and as such it is not fully backwards compatible.
Include CheerpJ 3 on your page with the following snippet:
When designing the new architecture we had the objective of making a drop-in replacement for CheerpJ 2.3 as much as we could. This objective has been mostly achieved, but in some cases we had to deprecate and remove functionalities in favor of much improved alternatives.
cheerpjInit is now asynchronous
The runtime API is not exposed until
cheerpjInit is called and its
Therefore, be sure to
cheerpjInit call before using any other functions.
natives option of
cheerpjInit. See the JNI guide for more information.
If you used the
com.leaningtech.client package extensively, check out the CJDom library (not maintained by Leaning Technologies).
This feature had no real use case because when using
java -jar, the JAR file is the source of all user classes, and any other class path settings are ignored.
CheerpJ can now be imported in a Web Worker without any special setup. Simply call
importScripts from a worker to load CheerpJ, then use CheerpJ as usual. The
CheerpJWorker class has been removed.
cjCall replaced with library mode API
cjCall have been removed in favour of
Other major changes
No Ahead-Of-Time compilation (
No Ahead-Of-Time compilation: To achieve good performance, CheerpJ required you to post-process JAR files with a custom binary compiler. The compiler would generate a
.jar.js files for each input JAR. CheerpJ 3 features an advanced JIT engine that can generate better-performing code than CheerpJ 2.3 ever could. Removal of
.jar.js files also significantly decreases how much data needs to be downloaded during application startup.
No downloads are provided with CheerpJ 3.
- AOT optimization: CheerpJ 3 uses a JIT compiler only, and as such it does not require any pre-processing of the JAR files, like conversion to
--natives: JNI function implementations should be passed to
nativesoption. See the JNI guide for more information.
Actual support for ClassLoaders
CheerpJ 2.3 had very limited support for ClassLoaders. As a consequence of requiring AOT compilation of
.jar.js files, it could only support the standard one provided by OpenJDK. CheerpJ 3.0 radically improves the status-quo by properly using ClassLoaders as expected by Java.
com.leaningtech.handlers HTTP handler no longer needed
Previously, CheerpJ 2 required a special Java property to be set in order for HTTP(S) requests to work. This is no longer needed.
cheerpjAddStringFile deprecated and renamed to
cheerpjAddStringFile function has been renamed to
cheerpOSAddStringFile to better reflect its behaviour and provide parity with CheerpX. The old name is still available for backwards compatibility.