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

Marshalling a Map with a generic type does not work #269

Closed
vicr123 opened this issue Oct 14, 2024 · 3 comments · Fixed by #270
Closed

Marshalling a Map with a generic type does not work #269

vicr123 opened this issue Oct 14, 2024 · 3 comments · Fixed by #270

Comments

@vicr123
Copy link
Contributor

vicr123 commented Oct 14, 2024

Example: In the following interface (in Kotlin)

@DBusInterfaceName("org.freedesktop.portal.FileChooser")
public interface DBusFileChooserInterface : DBusInterface {
    fun OpenFile(parentWindow: String, title: String, options: Map<String, Variant<*>>): ObjectPath;
}

The library marshals the options parameter as an a{s}, not an a{sv} as expected.

The root cause seems to be that the marshalling code does not handle a WildcardType:
image

@hypfvieh
Copy link
Owner

hypfvieh commented Oct 14, 2024

Could you please provide sample Java code to demonstrate this issue?

[edit]
This issues sounds a lot like #233, which is a pure kotlin problem and no library/Java issue.

@vicr123
Copy link
Contributor Author

vicr123 commented Oct 14, 2024

Yeah that seems to fix the issue. I'm wondering if maybe we can add support in for whatever Kotlin does so we don't run into this in future. I'd be willing to open a PR but for some reason I can't seem to compile the code on my setup 😅

It would probably just involve the marshaller being able to handle a WildcardType and decoding the upperBounds of that type instead.

@hypfvieh
Copy link
Owner

hypfvieh commented Oct 15, 2024

Yeah that seems to fix the issue. I'm wondering if maybe we can add support in for whatever Kotlin does so we don't run into this in future. I'd be willing to open a PR but for some reason I can't seem to compile the code on my setup

No special setup required for this project. I just use Eclipse to open/edit and Maven to build the project. Works just fine without any additional configuration.

It would probably just involve the marshaller being able to handle a WildcardType and decoding the upperBounds of that type instead.

Maybe, maybe not. Map is a parametrized type, so when improving this, it also has to work with other types used as key or value in Map.
As I'm not a Kotlin user, I can only check if there is anything I can do from the Java point of view. But I'm not sure that there is much I can do.
Parametrized types like Map and Collection is always painful to handle. Most of the time important information is missing due to type erasure.
I'll may have a look at this later, if you can provide a PR or other findings it will be much apprechiated.

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

Successfully merging a pull request may close this issue.

2 participants