This release contains various bugfixes, performance improvements and new emulated Java class library
elements. Among them there are some important improvements worth mentioning.
Java 21 support
Most notable change in this release is support for Java 21 features. This includes support for Java 21 bytecode,
switch pattern matching and sequenced collections.
JavaScript interop
Another important change is JavaScript interop API. First, the gap between Java and JavaScript worlds becomes
more transparent. This means: JS overlay objects (i.e. those which implement JSObject
interface)
now behave closer to normal objects. Now it's possible to call their methods, inherited from Object
,
like equals
, hashCode
, toString
, getClass
and so on. instanceof JSObject
can also be used
to distinguish between JavaScript and Java objects, and cast to JSObject
will only succeed for JavaScript
objects.
Second, TeaVM starts producing JavaScript modules by wrapping generated code into UMD wrappers.
TeaVM now can generate imports: you can use new @JSBodyImport
annotation in addition to @JSBody
to specify calls to routines defined in external modules.
Third, it's now possible to declare parameters and return values of JavaScript methods as Object
.
This allows to pass Java objects to JavaScript methods. For example, it's possible to declare Promise
that resolves to Java type. Additionally, some existing JSO APIs were updated to have Object
instead of JSObject
in their signature, which in some cases can break existing code (though, it must be
quite easy to fix).
Finally, it's now possible to add properties to Java objects exported to JavaScript.
Now when Java class implements JSO interface, which has methods marked with @JSProperty
annotation,
they will work as expected.
Class library
ConcurrentHashMap
This long-awaited feature is at last here. There were codebases that relied on this class and did several
efforts to patch TeaVM to solve this issues. New ConcurrentHashMap
implementation is fair implementation,
which works well with TeaVM green threads. In case there are no threads at all, ConcurrentHashMap
implementation
will prevent turning Java methods into state machine, so no overhead there.
WeakReference and ReferenceQueue
These classes used to be implemented by C and WebAssembly backends, since both have their own heap.
However, for JavaScript this was not possible until all major browsers started shipping WeakRef
API.
Atomic field updaters
AtomicReferenceFieldUpdater
used by Kotlin standard library to implement lazy properties.
Instead of patching Kotlin bytecode, TeaVM comes with fair support of three classes:
AtomicReferenceFieldUpdater
, AtomicIntegerFieldUpdater
and AtomicLongFieldUpdater
.
These classes have each two implementation: efficient and generic. Efficient implementation
is only used when constants passed to newUpdater
method. Otherwise, generic implementation is used, which
uses reflection under-the-hood, so corresponding fields should be property marked as reflectable.
Other changes
- Improvements to number-to-string and string-to-number conversions
(still some inconsistencies with doubles and floats). - Improvements to support of floating points operations in
Double
,Float
andMath
. - Improvements to Streams support.
WebAssembly backend
New release provides major improvements to WebAssembly support. Not only stability is improved,
but very process has changed. From now on WebAssembly tests run as part of each release and preview build.
This was possible to run WebAssembly tests, but some were failing, and when regression occurred,
it was hard to find it. The new version allows to ignore tests for separate backends.
Failing tests were ignored for WebAssembly and remaining tests are supposed to pass on each build.
Additionally, new release introduces better support for DWARF. It's still far from perfect, but
it already works with Google Chrome C++ debugging extension.
Line numbers are generated properly in most cases, variables often point to wrong locations.
Test runner
Some old features were removed from TeaVMTestRunner
:
- It does not support parallel running anymore. Instead, developer should use JUnit built-in feature
to run test classes in parallel. - HtmlUnit was also removed.
@WholeClassCompilation
is not deprecated and all test classes compile in single executable by default.
To override this behaviour, use@EachTestCompiledSeparately
.
New release allows also to suppress tests for separate backends, use @SkipPlatform
and @OnlyPlatform
annotations.
Sponsorship
TeaVM now participates in GitHub sponsors. You can support TeaVM not only by contributing code or documentation,
but also send some money to the project.
Special thanks to @reportmill and @shannah, our permanent sponsors! Also, thanks to @aloraps, who
sponsored this particular release.
Contributors
Special thanks to @Ihromant, who contributed lot to this release! Java 21 support is there mostly because of
his efforts.
Also, thanks to: