Repository navigation
Closed
Description
Having a DBusInterface that contain multiple fields, generated automatically, like this :
import java.util.List;
import org.freedesktop.dbus.annotations.DBusBoundProperty;
import org.freedesktop.dbus.annotations.DBusInterfaceName;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.messages.DBusSignal;
import org.freedesktop.dbus.types.UInt16;
import org.freedesktop.dbus.types.UInt32;
/**
* Auto-generated class.
*/
@DBusInterfaceName("com.interface.yes")
public interface ModemManager1 extends DBusInterface {
public void ResetModem();
GetDetailsTuple GetDetails();
...And in the generated Tuple:
import org.freedesktop.dbus.Tuple;
import org.freedesktop.dbus.annotations.Position;
import org.freedesktop.dbus.types.UInt16;
import org.freedesktop.dbus.types.UInt64;
/**
* Auto-generated class.
*/
public class GetDetailsTuple extends Tuple {
@Position(0)
private byte info;
@Position(1)
private UInt16 field;
...When I try to export it:
ModemManager1 modemManager = new ModemManagerMock();
connection.requestBusName("com.interface.yes");
connection.exportObject(modemManager.getObjectPath(), modemManager);
...I have the following error:
2024-10-29 17:30:26.342 [com.interface.yes.Main.main()] INFO o.f.d.c.transports.TransportBuilder - Using transport dbus-java-transport-native-unixsocket for address unix:path=/var/run/dbus/system_bus_socket
java.lang.ClassCastException: class java.lang.Class cannot be cast to class java.lang.reflect.ParameterizedType (java.lang.Class and java.lang.reflect.ParameterizedType are in module java.base of loader 'bootstrap')
at org.freedesktop.dbus.messages.ExportedObject.generateMethodsXml(ExportedObject.java:235)
at org.freedesktop.dbus.messages.ExportedObject.generateIntrospectionXml(ExportedObject.java:368)
at org.freedesktop.dbus.messages.ExportedObject.<init>(ExportedObject.java:43)
at org.freedesktop.dbus.connections.AbstractConnection.lambda$exportObject$0(AbstractConnection.java:175)
at org.freedesktop.dbus.connections.base.AbstractConnectionBase.doWithExportedObjects(AbstractConnectionBase.java:333)
at org.freedesktop.dbus.connections.AbstractConnection.exportObject(AbstractConnection.java:171)
at com.interface.yes.Main.main(Main.java:31)
at org.codehaus.mojo.exec.ExecJavaMojo.doMain(ExecJavaMojo.java:385)
at org.codehaus.mojo.exec.ExecJavaMojo.doExec(ExecJavaMojo.java:374)
at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0(ExecJavaMojo.java:296)
at java.base/java.lang.Thread.run(Thread.java:1575)
I do not have the problem when the GetDetailsTuple extends from a Struct.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Issue #271: Support export of methods using a Tuple / Struct / Contai…
hypfvieh commentedon Oct 30, 2024
This issue should be fixed in the latest commit. Using any
Containerextending class as return type should not work as expected.bachrc commentedon Oct 30, 2024
Thanks a lot, that was quick!! Until the release of the fix, do you know how I could integrate your latest changes in my maven project?
[-]An exported DBusInterface having a method returning a Tuple [/-][+]An Tuple returned by an exported DBusInterface can't be cast to ParameterizedType[/+][-]An Tuple returned by an exported DBusInterface can't be cast to ParameterizedType[/-][+]A Tuple returned by an exported DBusInterface can't be cast to ParameterizedType[/+]hypfvieh commentedon Oct 30, 2024
I only know two options:
Variant 1 is more hacky. It requires you to ensure that your artifact is listed before dbus-java in your class path otherwise the patched class will not be loaded.
This option will also only work when your project is NOT using JPMS (Jigsaw).
Variant 2 is the more convenient one, but depends on your project policy. If your policy (or your companies policy) is to never use snapshots or pre-releases (alpha or beta versions), you may not use the snapshot.
bachrc commentedon Oct 30, 2024
(I'm sorry for being offtopic but I don't know where I can ask you this, I can delete my message afterwards)
I do not see any snapshot of yours on Maven Central though, could you help me with a link maybe?
hypfvieh commentedon Oct 30, 2024
Maven will not use the official snapshot repository by default. You have to enable it either in your Maven settings.xml or in the pom of your project.
See the first two answers in this Stackoverflow post, depending on the method you want use to enable the snapshot repo.
This will allow Maven to download the most recent snapshot from here.
bachrc commentedon Oct 30, 2024
Again, thanks a lot for your time! I'll be using the SNAPSHOT until the release because your fix works perfectly!
I will close the issue, thank you for being so reactive, please have a great day