Skip to content

Signals with struct type parameters generate invalid Java #304

@zugaldia

Description

@zugaldia

When generating Java code with InterfaceCodeGenerator version 5.2.0 on the https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.GlobalShortcuts.xml file, the following signal produces incorrect code:

<signal name="ShortcutsChanged">
  <arg type="o" name="session_handle" direction="out"/>
  <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QList&lt;QPair&lt;QString,QVariantMap&gt;&gt;"/>
  <arg type="a(sa{sv})" name="shortcuts" direction="out"/>
</signal>

Problematic generated code:

public static class ShortcutsChanged extends DBusSignal {

    private final DBusPath sessionHandle;
    private final List<org.freedesktop.dbus.Struct<String>, Map<String, Variant<?>>> shortcuts;

    public ShortcutsChanged(String path, DBusPath sessionHandle, List<org.freedesktop.dbus.Struct<String>, Map<String, Variant<?>>> shortcuts) throws DBusException {
            super(path, sessionHandle, shortcuts);        this.sessionHandle = sessionHandle;
            this.shortcuts = shortcuts;
    }

    public DBusPath getSessionHandle() {
        return sessionHandle;
    }

    public List<org.freedesktop.dbus.Struct<String>, Map<String, Variant<?>>> getShortcuts() {
        return shortcuts;
    }

}

Build error:

Execution failed for task ':sdk:compileJava'.
> Compilation failed; see the compiler output below.
  /[redacted]/stargate/sdk/src/main/generated/org/freedesktop/portal/GlobalShortcuts.java:98: error: type Struct does not take parameters
          private final List<org.freedesktop.dbus.Struct<String>, Map<String, Variant<?>>> shortcuts;
                                                        ^

I believe the same type of error happens with https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.Usb.xml in DeviceEvents.

The exact setup can be seen here (Stargate is a Kotlin library that provides JVM applications with access to XDG Desktop Portals on Linux).

I've seen other generation errors with other XDG Portals related XML files. Opening separate tickets for easier tracking. Related: #302 and #303.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions