github konsoletyper/teavm 0.16.0

4 hours ago

Improvements to C backend

This release brings the C backend much closer to the JavaScript and Wasm GC backends in terms of feature parity.

Full reflection support

Reflection refactoring, started in 0.14.0, finally reached C backend. Now it supports:

  • method and constructor reflection, including invocation;
  • annotations on methods, constructors and fields;
  • generic type information (type parameters, bounds, generic supertypes);
  • Class.forName and Class.newInstance;
  • Class.getDeclaredClasses/Class.getClasses;
  • array reflection;
  • java.lang.reflect.Proxy.

Other improvements

  • Support for synchronized methods
  • Support for String.intern
  • Support for ClassLoader.getResourceAsStream
  • Fixed several issues in coroutine transformation and generation of virtual tables

Platform support

C backend now officially supports macOS. Also, a number of issues with MSVC were fixed, so generated code compiles and runs properly on Windows.

Record-style @JSProperty accessors

Previously, JSO required getters to follow Java Beans naming convention, i.e. start with get or is prefix. Now it's possible to declare getters in record style, i.e. using property name as method name:

interface Point extends JSObject {
    @JSProperty
    double x();

    @JSProperty
    double y();
}

WebGPU API

JSO APIs now include declarations for WebGPU, available in org.teavm.jso.webgpu package. Entry point is Navigator.getGPU(); use Navigator.isWebGPUSupported() to check availability.

Maven toolchains support

compile goal of TeaVM Maven plugin now respects Maven toolchains. When a JDK toolchain is configured (either via <jdkToolchain> parameter or via maven-toolchains-plugin), TeaVM compiler runs out of process on the selected JDK. This allows to compile projects which target newer Java version than the one Maven runs on.

Class library improvements

Following APIs added:

  • System.Logger and related classes
  • Locale.of factory methods
  • ClassValue.remove
  • primitive versions of Field.get*/Field.set* methods

Also, performance of several commonly used methods was improved, for example System.arraycopy, String.replace(char, char), iteration over EnumSet, Collections.unmodifiableMap and conversion of char arrays to strings in JavaScript backend.
Wasm GC backend now intrinsifies Math.min and Math.max.

Bug fixes

Apart from the bugs mentioned above, this release fixes:

  • several cases when Wasm GC backend produced invalid modules, mostly related to type inference for arrays and nullable references, as well as to coroutines;
  • a number of issues in reflection on all backends, including invocation of methods with null arguments, Class.getSuperclass for interfaces, subtype checks in JavaScript and references to inner generic types;
  • numerous non-conformances in class library, including Set.of/Map.of and Collectors.toUnmodifiableList not rejecting nulls, NIO buffers and paths, GregorianCalendar, Character.toTitleCase, InputStreamReader, RandomAccessFile, Arrays.copyOfRange.

Other improvements

  • Add namedEither predicate to reflection policy API to select elements by one of several names.
  • Generic type information is now preserved properly in dev server cache.
  • Wasm GC backend now throws clear Java exception when a suspension point is reached outside of a thread context.
  • SecureRandom now fails with clear error when crypto object is not available in the environment.

Contributors

Sponsors

A big thank you to Oki{ine and @shannah, for sponsoring the project as well as other sponsors (see full list). You can join these people and start supporting the project.

Don't miss a new teavm release

NewReleases is sending notifications on new releases.