Hello there!
I'm currently learning JNR by trying out various Linux libraries, most recently GTK3. I used this example as a reference and wrote the new demo that can be found here. But it crashes badly when I try to run it (using ./gradlew gtk3:run). Here's the crash log: hs_err_pid10169.log. I use GraalVM 21.3.0 as my JDK 11 on a x86_64 Linux machine (openSUSE tumbleweed). My installed GTK version is 3.24.30-2.3.
I can see that it crashes on line 31 of Gtk3App.java where I call from Java
lib.g_signal_connect_data(application, "activate", onActivate, null, null, 0);
The onActivate is a lambda looking like this:
LibGtk3.GCallback onActivate = (app, data) -> {
var window = lib.gtk_application_window_new(app);
var button = lib.gtk_button_new_wih_label("Click me");
lib.gtk_container_add(window, button);
lib.gtk_widget_show_all(window);
};
which is supposed to act like a function pointer similar to on_app_activate from my C reference:
// callback function which is called when application is first started
static void on_app_activate(GApplication *app, gpointer data) {
// create a new application window for the application
// GtkApplication is sub-class of GApplication
// downcast GApplication* to GtkApplication* with GTK_APPLICATION() macro
GtkWidget *window = gtk_application_window_new(GTK_APPLICATION(app));
// a simple push button
GtkWidget *btn = gtk_button_new_with_label("Click Me!");
// connect the event-handler for "clicked" signal of button
g_signal_connect(btn, "clicked", G_CALLBACK(on_button_clicked), NULL);
// add the button to the window
gtk_container_add(GTK_CONTAINER(window), btn);
// display the window
gtk_widget_show_all(GTK_WIDGET(window));
}
You can use https://github.com/praj-foss/jnr-demo to reproduce it using ./gradlew gtk3:run. The crash depends on the system as well: it ran perfectly fine on openSUSE leap 15.2, Mac OS, and Fedora Core 34 (verified by @headius and @enebo), but it crashed on openSUSE Tumbleweed and Ubuntu 21.10.
NOTE: This issue was earlier opened in jnr/jnr-ffi#281
Hello there!
I'm currently learning JNR by trying out various Linux libraries, most recently GTK3. I used this example as a reference and wrote the new demo that can be found here. But it crashes badly when I try to run it (using
./gradlew gtk3:run). Here's the crash log: hs_err_pid10169.log. I use GraalVM 21.3.0 as my JDK 11 on a x86_64 Linux machine (openSUSE tumbleweed). My installed GTK version is 3.24.30-2.3.I can see that it crashes on line 31 of
Gtk3App.javawhere I call from JavaThe
onActivateis a lambda looking like this:which is supposed to act like a function pointer similar to
on_app_activatefrom my C reference:You can use https://github.com/praj-foss/jnr-demo to reproduce it using
./gradlew gtk3:run. The crash depends on the system as well: it ran perfectly fine on openSUSE leap 15.2, Mac OS, and Fedora Core 34 (verified by @headius and @enebo), but it crashed on openSUSE Tumbleweed and Ubuntu 21.10.NOTE: This issue was earlier opened in jnr/jnr-ffi#281