Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Interface does not work #233

Open
Doomsdayrs opened this issue Sep 6, 2023 · 3 comments
Open

Kotlin Interface does not work #233

Doomsdayrs opened this issue Sep 6, 2023 · 3 comments

Comments

@Doomsdayrs
Copy link

I have the following class produced by the auto generator, then converted to Kotlin

package org.freedesktop.portal

@Suppress("FunctionName")
@DBusProperty(
	name = "version",
	type = UInt32::class,
	access = DBusProperty.Access.READ
)
actual interface Account : DBusInterface {

	actual fun GetUserInformation(
		window: String,
		options: Map<String, Variant<*>>,
	): DBusPath
}

Then I have the same class, but in original java.

package org.freedesktop.portal;

/**
 * Auto-generated class.
 */
//@Suppress("FunctionName")
@DBusProperty(
	name = "version",
	type = UInt32.class,
	access = DBusProperty.Access.READ
)
public interface Account extends DBusInterface {

	DBusPath GetUserInformation(
		String window,
		Map<String, Variant<?>> options
	);
}

Utilizing the classes, we get the following results

Language Result
Kotlin org.freedesktop.dbus.exceptions.FatalDBusException: java.io.EOFException: (1) Underlying transport returned -1
Java No error

What is going on here?

@hypfvieh
Copy link
Owner

hypfvieh commented Sep 7, 2023

I'm not familiar with Kotlin, so I don't know where to start.
Anyway, without further log, the complete stacktrace or even better a working example project, I'm really unable to help.

@Doomsdayrs
Copy link
Author

I'm not familiar with Kotlin, so I don't know where to start. Anyway, without further log, the complete stacktrace or even better a working example project, I'm really unable to help.

I'll be able to provide better details shortly~

@MMarco94
Copy link

MMarco94 commented Jan 6, 2024

I think the issue is with the Map definition. When Kotlin code is compiled into Java, Map is assumed to be read-only, so its type parameters are converted into the Java equivalent of Map<K, ? extends V>. So, in this case, the type of the value becomes ? extends org.freedesktop.dbus.types.Variant<?>, which the method recursiveGetDBusType cannot handle properly.

As a workaround, you can use MutableMap instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants