Releases: konsoletyper/teavm
0.11.0
New WebAssembly backend
This release is mostly driven by development of new WebAssembly backend. Old WebAssembly backend exists for many years and works well, however, did not see any adoption. The main reason is that it does not add significant advantages (like performance improvements), but makes development experience much worse, i.e. does not allow to easily interact with browser JS APIs and produces large binary files (times as large as JS).
With introduction of new WebAssembly GC proposal these problems were solved. However, this is not just small addition to original WebAssembly spec, but a game changer, it was impossible just to improve existing backend to support new proposal. So the decision was made to create a brand new WebAssembly backend, which would co-exist with the old one. Perhaps, at some point old WebAssembly backend will be deprecated and fully removed, but for now they will co-exist. However, WebAssembly GC will be advertised as primary WebAssembly target and the documentation will be maintained for WebAssembly GC, not for old WebAssembly.
New WebAssembly GC is a bit limited compared to JS backend, but mostly provides all features available in old WebAssembly backend. Moreover, WebAssembly GC fully supports JSO, as Java-to-JS interaction API. Hopefully, the next release will cover remaining features and WebAssembly GC backend will be on par with JS backend and the "experimental" tag will be removed from WebAssembly support.
Java class library emulation
- Fixed bugs in
BitSet
implementation - Add
ceilDiv
,ceilDivExact
,ceilMod
,floorDivExact
,absExact
toMath
class.
Support for JS APIs
- Reading files from
<input type="file">
, which includes classes likeFile
,Blob
,ReadableStream
and so on. - Binding for
HTMLElement.touch
andHTMLElement.input
events. - Binding for Popover API.
- Binding for
Navigator.sendBeacon
- Binding for
Error.cause
Other stuff
- Long emulation was removed from JS runtime. Now JS only relies on BigInt, which is supported by all browsers for more than 4 years.
Sponsorship
Worth mentioning that TeaVM evolved with the support from its sponsors. If you like this project, you can start donating.
Special thanks to @reportmill and @shannah, our permanent sponsors!
Contributors
Special thanks to @Ihromant, @lax1dude and xpenatan, who were early adopters of WebAssembly GC backend and helped to find some bugs there. Also, I want to highlight @lax1dude, who not only enabled WebAssembly GC in his project, bug managed to identify, fix and successfully sent his PR to main repository.
0.10.0
Improvements to native JavaScript interaction
Exporting declarations from Java to JavaScript
This long expected feature is finally delivered by this release. Now TeaVM can not only take standard Java main classes with main methods, but also module classes. Instead of main
method, they can declare static
methods annotated with @JSExport
.
These methods will be exported from generated TeaVM module (or rather as top-level declarations in non-module output).
Additionally, @JSExport
annotation can be used to mark methods of classes that should be available in JS. See full documentation in Creating JavaScript modules section.
Generating modules
From this release, TeaVM can produce ES2015 modules. Moreover, there's a new build parameter that allows to specify module type (CommonJS, ES2015, UMD, immediately-invoked function).
Importing constructors
Previously, to declare a constructor for a JS class, you had to define static factory method, annotated with @JSBody
and some JS within. Now, it's possible to declare a non-abstract overlay class (should be additionally annotated with @JSClass
) with constructors. To instantiate such classes, you can use new
syntax, as you used for normal Java classes.
Importing static and top-level methods
Since this release, you can define static native
methods of overlay classes without extra annotations. These methods will be automatically mapped to corresponding static JS methods.
You can also put @JSTopLevel
annotation on such methods so that they aren't mapped to static methods of containing classes, but to top-level methods.
Support instanceof
Overlay classes now properly support instanceof
and casts (in strict mode). Note that instanceof
is not available for interfaces (i.e. as previously, always produces true
). Support of instanceof
can be disabled for classes by applying @JSClass(transparent = true)
.
Importing declarations from external modules
You can also use @JSModule
annotation to import declarations from JS modules. Following cases possible:
@JSModule
on class – imports class@JSModule
and@JSTopLevel
– imports function@JSModule
,@JSTopLevel
and@JSProperty
– imports property
Support varargs
Varargs methods of overlay classes now automatically mapped to varargs methods in JS.
Improved string representation
This release has changed the way java.lang.String
represented internally. Instead of array of char
, java.lang.String
now contains field of native JS string. This can improve performance in some cases, most likely in calls to native JS methods. Previously, to convert java.lang.String
to and from JS method, a full copy should have been made. Now, TeaVM only wraps/unwraps JS string with java.lang.String
implementation, which is much faster.
This also improves debugging experience. Previously, if you open a java.lang.String
value in browser dev tools, you had a object, which has a field, which is an object in turn, which wraps UInt16Array
. Now, you only have to deal with one level of indirection (object that has a field), and an actual representation is not array of char codes, but JS string, easily readable in dev tools.
ES2015 modules
Since this release, TeaVM generates ES2015 output, not ES5. This allows not only to support ES2015 modules, but reduces output side thanks to arrow function syntax.
Class library emulation
String.toLowerCase
/toUpperCase
methods that takeLocale
parameterchars
andcodePoints
methods inCharSequence
String.format
/Formatter.format
now support more format specifiersMath
methods for arithmetic operations that throw exception on overflowOutputStream.nullOutputStream
SecureRandom
BigInteger.sqrt
WeakHashMap
CopyOnWriteArrayList
- Fair support of
ThreadLocal
in green threads - Support
@Inherited
annotations PrintStream
implementsAppendable
BufferedReader.lines
method
Gradle plugin improvements
- Improve source file resolution when generating source maps in Gradle
- Add tasks to start/update and stop development server
Other stuff
- Overlay class for JS
Promise
(JSPromise
class) - Support
@Inherited
annotations - New convention for event registration in standard overlay classes (onEventName returning
Registration
to unbind the listener, instead of listenEventName/neglectEventName).
Sponsorship
Worth mentioning that TeaVM evolved with the support from its sponsors. If you like this project, you can start donating.
Special thanks to @reportmill and @shannah, our permanent sponsors!
Contributors
0.9.2
This release contains hotfixes for release 0.9.0
- Fix Maven archetype
- Fix declaration in IndexedDB API
- Fixes for wrapping JS values into Java objects
- Fix issue in optimizing floating-point comparison operations (
fcmpg
,fcmpl
,dcmpg
,dcmpl
)
in corner-cases like NaN or negative zero - Fix bug in
LinkedHashMap
that could lead to inconsistent state in some cases - Fix boxing/unboxing arguments and return values in method references
- Widen byte/short to ints in
ObjectMethods
emulation - Fix issue in
InputStreamReader
that lead to infinite loop in some cases
Special thanks to @SquidDev who contributed commit to this release.
Note that due to mistake version 0.9.1
was published with incorrect content.
Please, ignore it.
0.9.0
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:
0.6.0
- Improve performance and stability of compiler
- Reduce size of generates JavaScript
- Support Stream API
- Generate immediately invoked function to protect global name space from pollution
- Don't generate
runtime.js
anymore, deprecate Maven and command line options related toruntime.js
generation - Drop support of old IE browsers
- New code server for fast incremental recompilation
- Add possibility to start separate TeaVM process from Maven
- Don't report compile-time error when there's possible misuse of async methods
- Support Java 13
- Experimental C code generator (Linux and Windows only)
0.5.1
- Fix build daemon hanging on closing IDEA
- Add missing files from Unicode CLDR
- Fix capacity calculation in ArrayList and StringBuilder
- Fix bugs in source map generation and debugging support in IDEA
- Fix errors not appearing in IDEA messages window when can't find corresponding location
Release 0.5.0
- Drop Eclipse support, introduce IntelliJ IDEA support
- A new metaprogramming API
- A set of new performance optimizations (inlining, escape analysis/scalar replacement, redundant
<clinit>
elimination etc) - Support for Kotlin and Scala
- Support html4j 1.4
- Experimental support for WebAssembly
- Update to the latest versions of UnicodeData, CLDR and tzdata
- Support asynchronous
<cinit>
methods - Performance improvements and bugfixes in compiler
Release 0.4.3
- Fix loop hierarchy recognition in some cases when loop nesting is at least 3
- Fix bug in base64 resource decoder
Release 0.4.1
Minor bugfixes
Release 0.4.2
- Fix missing
<clinit>
call in some circumstances (see #167) - When passing non-JS types to JSBody methods, report an error
- Avoid inlining of JSBody when one of parameters got used more than once (for example, it can cause error with script like
a.foo() + a.foo()
, whenfoo
method has side effects) - Reduce amount of exported JS methods
- Implement
ClassLoader.getResourceAsStream
by packing specified base64-encoded resources right into produced JS file.