Hello, I have noted several issues using a 5.0.1-SNAPSHOT (master, commit 5041727ca38e31db254d60395e898e0a0c2ac5f8) to generate the org.freedesktop.NetworkManager interface with the dbus-java-utils module.
Here are the commands. I set the --propertyMethods argument to use the new annotation @DBusBoundProperty.
The generated class AddAndActivateConnection2Tuple uses Variant but does not import it.
The gererated interface NetworkManager has property methods annotated with @DBusBoundProperty.
However the ones using a TypeRef type are not generated properly. For instance, I get:
@DBusBoundProperty
public PropertyDevicesType getDevices();
public static interface PropertyDevicesType extends TypeRef<List<DBusPath>> {
}
Whereas the expected should be:
@DBusBoundProperty(type = PropertyDevicesType.class)
public List<DBusPath> getDevices();
public static interface PropertyDevicesType extends TypeRef<List<DBusPath>> {
}
Attempting to use the first version result in a ClassCastException
> Task :MainNOK.main()
24/05/17 10:47:30 INFO transports.TransportBuilder: Using transport dbus-java-transport-native-unixsocket for address unix:path=/var/run/dbus/system_bus_socket
0 [main] INFO org.freedesktop.dbus.connections.transports.TransportBuilder - Using transport dbus-java-transport-native-unixsocket for address unix:path=/var/run/dbus/system_bus_socket
Exception in thread "main" java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class org.freedesktop.NetworkManager$PropertyDevicesType (java.util.ArrayList is in module java.base of loader 'bootstrap'; org.freedesktop.NetworkManager$PropertyDevicesType is in unnamed module of loader 'app')
at jdk.proxy2/jdk.proxy2.$Proxy6.getDevices(Unknown Source)
at dev.tutetaki.MainNOK.main(MainNOK.java:25)
Similarly, generated interface Device has property methods annotated with @DBusBoundProperty.
But for the field using a Struct type, I get:
@DBusBoundProperty
public PropertyStateReasonStruct getStateReason();
Whereas the expected should be (I'm not sure about this one. Is the intention to use PropertyStateReasonStruct?):
@DBusBoundProperty(type = PropertyStateReasonStruct.class)
public Object[] getStateReason();
Attempting to use the first version result in a ClassCastException
24/05/17 11:39:40 INFO transports.TransportBuilder: Using transport dbus-java-transport-native-unixsocket for address unix:path=/var/run/dbus/system_bus_socket
0 [main] INFO org.freedesktop.dbus.connections.transports.TransportBuilder - Using transport dbus-java-transport-native-unixsocket for address unix:path=/var/run/dbus/system_bus_socket
Exception in thread "main" java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class org.freedesktop.networkmanager.PropertyStateReasonStruct ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; org.freedesktop.networkmanager.PropertyStateReasonStruct is in unnamed module of loader 'app')
at jdk.proxy2/jdk.proxy2.$Proxy8.getStateReason(Unknown Source)
at dev.tutetaki.MainOK.main(MainOK.java:42)
I fixed the mentioned issues in the latest commits. Anyway, the InterfaceCodeGenerator is far from being perfect. It's just a helper to get started somehow...
Hello, I have noted several issues using a 5.0.1-SNAPSHOT (master, commit 5041727ca38e31db254d60395e898e0a0c2ac5f8) to generate the
org.freedesktop.NetworkManager
interface with the dbus-java-utils module.Here are the commands. I set the
--propertyMethods
argument to use the new annotation@DBusBoundProperty
.The generated class
AddAndActivateConnection2Tuple
usesVariant
but does not import it.The gererated interface
NetworkManager
has property methods annotated with@DBusBoundProperty
.However the ones using a
TypeRef
type are not generated properly. For instance, I get:Whereas the expected should be:
Attempting to use the first version result in a ClassCastException
Similarly, generated interface
Device
has property methods annotated with@DBusBoundProperty
. But for the field using aStruct
type, I get:Whereas the expected should be (I'm not sure about this one. Is the intention to use
PropertyStateReasonStruct
?):Attempting to use the first version result in a ClassCastException
Here is a sample project to reproduce https://github.com/tutetaki/sample-dbus-object/tree/master