Back to blog

CheerpJ 3.0rc2 now available

CheerpJ 3.0 now available

CheerpJ 3.0 has been released. Read the release announcement for more information.

CheerpJ 3.0rc2 is out now! Thank you to the community and all pilot testers for their invaluable feedback. In this version:

  • Much improved library mode: support for object fields, arrays, instanceof, plus quality-of-life and debugging improvements
  • Web Worker support
  • Restore support for AWT to match CheerpJ 2.3
  • Support for synchronized methods in the JIT
  • Improved support for reflection, clipboard, fonts, and class loaders
  • A new loading screen animation
  • Support for ClassCastException
  • Fixed preloading support
  • Many other bug fixes and improvements

CheerpJ is a WebAssembly-based JVM that runs fully client side in the browser. Alongside this post, we’ve written a new post going into detail on CheerpJ 3.0:

Deep dive into CheerpJ 3.0

Alessandro Pignotti, Alex Bates, Stefano De Rossi

Upgrading

This is a release candidate intended for testing and feedback. You can upgrade to CheerpJ 3.0rc2 using the following script tag:

<script src="https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"></script>

If you’re coming from CheerpJ 2, please read the migration guide before upgrading.

Report any bugs or issues you encounter on GitHub or Discord.

New features in CheerpJ 3.0rc2

Improvements to library mode

Library mode is a feature in CheerpJ 3.0 that allows JavaScript to use Java classes seamlessly.

In CheerpJ 3.0rc1, library mode was limited to calling constructors and methods. We’ve expanded the feature set to include:

  • Passing JS arrays to Java arrays via copying. Standard arrays, typed arrays, and multidimensional arrays are supported.
  • Passing JS arrays to Java JSObject: The incoming value is wrapped and opaquely stored in a Java JSObject, and can be passed back to JS for further operations.
  • Passing Java object arrays to JavaScript by reference. Changes to the array on the JS side will be visible on the Java side. Uses Proxies.
  • Passing Java primitive arrays to JavaScript: efficiently supported via typed arrays.
  • Public Java fields can now be both read/written from JS with appropriate type conversion.
  • Classes in JS now support instanceof, reflecting the extends relationship in Java. Due to limitations of JS inheritance model, instanceof checks of Java interfaces will not work.

These features are available in the cheerpjRunLibrary and JNI APIs.

Web Worker support

CheerpJ 3.0rc2 adds support for Web Workers. Simply call importScripts from a worker to load CheerpJ, then use CheerpJ as usual.

importScripts("https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js");
// Use CheerpJ as usual
(async () => {
await cheerpjInit();
const lib = await cheerpjRunLibrary("/app/example.jar");
// ...
)();

Note that:

  • This replaces the CheerpJWorker API (CheerpJ 2 only).
  • Anything that requires DOM access (such as displaying a UI) is not supported in a worker.

Improved font support

CheerpJ now ships fonts for international character sets.

Try CheerpJ 3.0rc2 today

Get started Migration guide

Your feedback is invaluable in helping us identify and fix potential issues and ensure that the final release is as stable and polished as possible. Here are some ways to help:

  • Try the release candidate today.
  • Test it in your real-world scenarios.
  • Report any bugs or issues you encounter on GitHub or Discord.
  • Provide feedback on new features and improvements.
  • Join the Discord and share what you’re working on.

What’s next

We plan to fully release CheerpJ 3.0 in early 2024.

Thank you for your continued support in making CheerpJ the best it can be!

The author

Related posts