Closed haggish closed 6 years ago
This is indeed a problem, but using Introspectable.class would not be suitable here.
The DBus spec says: "Objects instances may implement Introspect which returns an XML"... It says 'may' not 'must'.
So the best effort we can do here is to use DBusInterface.class in case no proper interface was found before. This interface must be present on all exported objects.
I changes the code in DBusConnection so it takes care of the default DBus interfaces by looking into the correct package. I hope this will fix it. If not suitable interface could be found, it will try DBusInterface. This may fail with a ClassCastException if it is not compatible (I guess all objects should be compatible, otherwise they wouldn't be published on DBus).
It would be great if you can provide a unit test cover this issue.
Is this issue resolved now?
Yes, it seems to work now without casting problems
Hi!
I have been using dbus-java 2.* and now experimenting with 3.0 SNAPSHOT. I ran to an issue with code that is getting a DBus object, calling
DBusConnection.dynamicProxy
:Cranking up the debug levels I see:
Digging into
dynamicProxy
, I see that it is getting first the object asIntrospectable
and checking if it can load any interfaces that it declares in the introspection XML, then just using the first one. But it does not take into account if someone has overridden the Java package / DBus interface sync withDBusInterfaceName
.I have these overrides in place in every DBus interface I access, and now in 3.0 also the DBus
Introspectable
Java package diverges from the DBus interface name. I guess this has previously worked becauseIntrospectable
is(?) the interface every DBus object has, and its Java package has been matching the interface name, and you can cast the proxy to another interface. But nowIntrospectable
Java package does not match the DBus interface name any more, and the whole thing fails.Does this make any sense? Should there be a mechanism that given ClassNotFoundEx for an introspected IF, tries to check if there is a class annotated with IF name override with matching value? Or in the case no classes matching the interfaces can be found (or actually in any case), just use
Introspectable
since all DBus objects should implement that?Something along the lines of (
DBusConnection.dynamicProxy:301-
) ?