Skip to content

Releases: jwharm/java-gi

0.8.1

25 Nov 10:01
Compare
Choose a tag to compare

This is a bugfix release. In specific cases (specifically when Java-GI patches a method return type), it was impossible to chain up from a derived class to a method in a superclass. This has now been resolved. Details in PR #81.

Full Changelog: 0.8.0...0.8.1

0.8.0

19 Nov 21:31
Compare
Choose a tag to compare

This release upgrades the Java bindings to OpenJDK 21! This is an incompatible change from Java-GI 0.7.x, because the Panama FFI API changed significantly since JDK 20. The JDK 21 version (JEP 442) is the last preview version though; in JDK 22 the API will be final!

Kotlin users must upgrade to Kotlin 1.9.20 or newer if they want to use Java-GI 0.8.0, because older Kotlin releases are incompatible with JDK 21.

Notable changes:

GNOME 45

All libraries have been upgraded to the versions of the GNOME 45 SDK and Freedesktop SDK 23.08. See the README.md for the exact version numbers.

Allocate structs with an Arena

The Panama FFI in its current form heavily uses memory arenas to manage allocation lifetimes. Users can choose between different arenas, depending on your use case. Therefore, the allocate() methods generated by Java-GI for record (struct) and union types now expect an Arena as the first parameter.

Example:

try (var arena = Arena.ofConfined()) {
    var red = RGBA.allocate(arena, 1.0, 0.0, 0.0, 0.0);
    // memory is now allocated
}
// memory is now deallocated

var blue = RGBA.allocate(Arena.ofAuto(), 0.0, 0.0, 1.0, 0.0);
// memory will be deallocated when the variable is garbage collected

var green = RGBA.allocate(Arena.global(), 0.0, 1.0, 0.0, 0.0);
// memory will be allocated during the entire application runtime

Read the Arena documentation for more information.

To ease the transition, the old allocate() methods without an Arena parameter are still available. These methods use an Arena.ofAuto() behind the scenes. Dealing with native memory deallocations during GC is rather ugly, so I don't want users to think this is the default option. Therefore, these methods have been marked as deprecated, and will be removed in the next Java-GI release.

Property names will be inferred by default

In a GObject-derived class, you can define custom properties with a @Property annotation on the getter and setter methods. With Java-GI 0.8.0, the name parameter of the annotation has become optional. If you don't specify a name, it will be inferred from the getter and setter method name (converting setMyProperty to my-property).

Builder syntax has changed

The setter methods in the Builder classes now start with a set... prefix. This allows the builders to be used as Java Beans, allowing a much nicer property assignment syntax in Kotlin. The old setters are still available, but deprecated, and will be removed in the next Java-GI release.

Shorter constructor names

The new prefix in named constructors doesn't really serve a purpose in Java, and has been removed. As an example, gtk_button_new_with_label() will no longer be available as Button.newWithLabel(), but Button.withLabel(). As with the other API changes, the old syntax (Button.newWithLabel()) is still available, but deprecated, and will be removed in the next Java-GI release.

Improved HarfBuzz type names

HarfBuzz types have a "_t" postfix in C, which was previously mapped to Java classes like FontT. The trailing "T" is now gone.

Improved handling of callback memory allocations

The Panama FFI needs an explicit memory allocation to a expose Java callback method to native code. These are now deallocated automatically, as specified in scope attribute in GObject-Introspection.

Improved binding of virtual methods

In previous versions, Java-GI mapped virtual methods to regular public Java methods. This is incorrect; virtual methods are not designed as an API, but can be used to "chain up" when implementing a derived class. This is why in PyGObject for example, virtual methods have a do_ prefix to prevent confusion with regular methods. In Java-GI 0.8.0, virtual methods are now exposed with protected visibility. You can "chain up" using the asParent() API that was implemented in Java-GI 0.7.0.

Upgraded and improved Cairo bindings

Not part of Java-GI, but related: The manually developed cairo bindings have also been upgraded to JDK 21, and now also support user-defined fonts.

More details in the PRs:

Full Changelog: 0.7.2...0.8.0

0.7.2

03 Oct 19:38
Compare
Choose a tag to compare

This release fixes an issue with out-parameter handling in callback methods.
Furthermore, a toString() method has been added to the org.gnome.gobject.Value class to simplify debugging of GValues.

The release is available on Maven Central.

Full Changelog: 0.7.1...0.7.2

0.7.1

17 Sep 21:00
6428ce3
Compare
Choose a tag to compare

Release 0.7.1 brings back JPMS modules (previously removed in release 0.7). For each package, a module-info.java file is generated during build. The module names are the same as the package names. Each module "requires transitive" its dependencies.

The release is available from MavenCentral.

What's Changed

Full Changelog: 0.7...0.7.1

0.7

15 Sep 19:26
Compare
Choose a tag to compare
0.7

This release brings a number of changes:

  • The project is built using Gradle, and all artifacts are now available on Maven Central. For example, to include LibAdwaita bindings and transitively Gtk, GObject etc:
repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.jwharm.javagi:adw:0.7'
}
  • The project has become more modular. All gir files generate one jar file. All available modules are listed here.
  • As can be seen in the example above, the adwaita module has been renamed to adw. This follows the namespace declared in the GIR file.
  • The GObject class has been extended with methods that allow to easily get and set property values.
  • When creating your own GObject subclass in Java, you can now declare and emit custom signals with a convenient syntax. The old Signal class has been renamed to SignalConnection. Example usage:
@Signal
public interface LimitReached {
    public void run(int limit);
}

public void count() {
    num++;
    if (num == limit) {
        emit("limit-reached", limit);
    }
}
  • The Java-GI GClosure implementation, JavaClosure, can now also be used to wrap anonymous lambda methods.
  • The Cairo bindings have been published separately on Maven Central. They are automatically pulled as a dependency by Gdk.
  • Marshaling of arrays and out-parameters has further improved. The Pointer classes (PointerInteger, PointerString etc) are now mostly obsolete, and have been removed. In the few cases where pointers still are exposed in the Java API, a MemorySegment is used.
  • Java-9-style modules have been removed. There is only one package in most jar files.
  • The GIR parser and code generator have received performance improvements.
  • LGPL license banners have been added to all source code files.
  • Error logging when creating GObject-derived Java classes has been improved.
  • Methods with va_list parameters are marked as deprecated, in preparation for the removal of the VaList class in Java 21.
  • Marshaling of empty Strings has been fixed.
  • More unit tests have been added

The split of the glib jar into separate modules for GLib, GObject, GIO and GModule will require some changes to your import statements:

  • import io.github.jwharm.javagi.types should become import io.github.jwharm.javagi.gobject.types
  • The ListIndexModel class has moved to io.github.jwharm.javagi.gio
  • The JavaClosure and ValueUtil class has moved to io.github.jwharm.javagi.gobject

0.6.1

16 Jul 21:26
Compare
Choose a tag to compare

This release adds a complete set of java bindings for cairo. The bindings are automatically pulled as a dependency by the GTK bindings.

An example application that draws graphics with cairo in a GTK window is available here.

Full Changelog: 0.6.0...0.6.1

0.6.0

15 Jul 15:55
Compare
Choose a tag to compare

Besides bugfixes and refactorings, the real highlights of this release are:

  • New bindings for GtkSourceView
  • New bindings for WebkitGtk
  • Deprecated signals are now annotated as such
  • Static type constants were moved from org.gnome.glib.Type to io.github.jwharm.javagi.types.Types, and a lot more constants have been added.
  • Added unit tests (run with ./bld compile test)
  • UnsupportedPlatformException is now a RuntimeException. (Ignore it at your own peril.)
  • Thread-safety improvements in the type- and instance-cache tables
  • Improved loading of native libraries. The library name from the gir file for the runtime OS is now used.
  • Added a parent() method that allows to "chain up" in overrided virtual methods.
  • Several new examples have been added to the java-gi-examples repository.

Full Changelog: v0.5.1...0.6.0

Release 0.5.1

14 May 21:20
Compare
Choose a tag to compare
Release 0.5.1 Pre-release
Pre-release

With release 0.5.1, a wrong version number for gstreamer has been corrected (was 1.22, is now 1.20), and pom.xml files have been added to the repository modules to convince jitpack.io that these modules actually publish artifacts. It should now be possible to use jitpack.io to set java-gi modules as dependencies in an app's pom.xml or gradle.build without manually downloading the artifacts.

Release 0.5

12 May 20:42
Compare
Choose a tag to compare
Release 0.5 Pre-release
Pre-release

Most important changes in this release

  • Implement interfaces when registering new GTypes
  • Multi-platform jar file that can be used on Linux, Windows and MacOS
  • Memory of strings, arrays and structs is now released after use
  • Port to JEP 434 (JDK 20)
  • Added annotation to define GObject properties
  • Added allocate method that initializes struct fields
  • Build with bld
  • Added a website
  • Added a repository with some examples

Full Changelog: v0.4...v0.5

Release 0.4

05 Mar 22:45
6d41b6f
Compare
Choose a tag to compare
Release 0.4 Pre-release
Pre-release

This release introduces a number of changes and improvements:

  • Many packages have been renamed: org.gtk has been changed to org.gnome and org.gstreamer is now org.freedesktop.gstreamer.
  • The "gtk4" module has been renamed to "gtk".
  • The version numbers are now primarily based on the version of the native libraries, with the java-gi version appended at the end.
  • All Java proxy class instances are now cached, so custom fields and state is preserved as long as the native object is alive.
  • Ref-counting has been completely rewritten, and is now based on GObject toggle references (thanks to @badcel for the explanation)
  • Added support for virtual methods.
  • All typeclass definitions are now generated as nested inner classes of the type instance, and inherit from the parent typeclass.
  • Added convenience functions to easily register a Java class as a new GType.
  • Added support for composite template classes.

Full Changelog: v0.3...v0.4