Rename toString_() and notify_() methods #237

Merged
jwharm merged 1 commit from stop-renaming-object-methods into main 2025-06-14 10:52:33 +02:00
jwharm commented 2025-06-14 10:52:23 +02:00 (Migrated from github.com)

Until now, Java-GI automatically renamed methods with the same name as methods in java.lang.Object. The reason for this is that default methods in Java interfaces are not allowed to override methods in Object. There were two places where this caused a compile error:

  • g_icon_to_string
  • g_socket_connectable_to_string

With the automatic renaming, these methods were available in Java-GI as Icon.toString_() and SocketConnectable.toString_(). However, the method g_object_notify was impacted too, and it was available in Java-GI as GObject.notify_().

I could have changed the automatic renaming to exclude g_object_notify but I decided to revert this entirely, and add manually rename the two to_string methods in Gio with metadata.

This is the result:

  • org.gnome.gio.Icon.toString_() is now available as serializeToString()
  • org.gnome.gio.SocketConnectable.toString_() is now available as formatAsString()
  • org.gnome.gobject.GObject.notify_() is now available as notify()
Until now, Java-GI automatically renamed methods with the same name as methods in `java.lang.Object`. The reason for this is that default methods in Java interfaces are not allowed to override methods in Object. There were two places where this caused a compile error: - `g_icon_to_string` - `g_socket_connectable_to_string` With the automatic renaming, these methods were available in Java-GI as `Icon.toString_()` and `SocketConnectable.toString_()`. However, the method `g_object_notify` was impacted too, and it was available in Java-GI as `GObject.notify_()`. I could have changed the automatic renaming to exclude `g_object_notify` but I decided to revert this entirely, and add manually rename the two `to_string` methods in Gio with metadata. This is the result: - `org.gnome.gio.Icon.toString_()` is now available as `serializeToString()` - `org.gnome.gio.SocketConnectable.toString_()` is now available as `formatAsString()` - `org.gnome.gobject.GObject.notify_()` is now available as `notify()`
Sign in to join this conversation.
No description provided.