Annotations in Java binding

Tim Moloney t.moloney at verizon.net
Tue Apr 18 05:11:19 PDT 2006


Matthew Johnson wrote:
> On Mon, 17 Apr 2006, Tim Moloney wrote:
>
>> I'm trying to learn D-BUS and I thought it would be fun to control 
>> Rhythmbox via Java.
>>
>> I've generated a RhythmboxPlayer class by running CreateInterface on 
>> rb-shell-player.xml (which came with Rhythmbox).  The resulting Java 
>> code has undefined annotations of org.freedesktop.DBus.GLib.CSymbol.
>> Both rb-shell-player.xml and RhythmboxPlayer.java are attached.
>>
>> I see that org.freedesktop.DBus.GLib.CSymbol is defined for C in 
>> dbus-binding-tool-glib.h.  Is it available to the Java binding anywhere?
>>
>
> The CreateInterface code still needs support for auto-generating
> annotations. In general anything under org.freedesktop.DBus.GLib is only
> relevant to the glib bindings and can be removed in other bindings.
>
> Matt
>

I commented out the annotations to see what would happen.  My simple 
program to toggle the play/pause state generated the following stack trace.

Exception in thread "main" org.freedesktop.DBus$Error$UnknownMethod: 
Method "playPause" with signature "b" on interface 
"rhythmbox.RhythmboxPlayer" doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at 
org.freedesktop.dbus.DBusErrorMessage.getException(DBusErrorMessage.java:88)
    at 
org.freedesktop.dbus.DBusErrorMessage.throwException(DBusErrorMessage.java:111)
    at 
org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:96)
    at 
org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:145)
    at $Proxy1.playPause(Unknown Source)
    at rhythmbox.RhythmboxInterface.main(RhythmboxInterface.java:41)

I don't pretend to understand what annotations do in D-BUS, but it 
appears that Rhythmbox is using the annotations to map method names to 
implementations on the server side.  In other words, map the playPause 
method call on the org.gnome.Rhymbox.Player D-BUS object to the C symbol 
rb_shell_player_playpause which is the name of the function implementing 
the playPause capability in Rhythmbox.

Is Rhythmbox mis-using org.freedesktop.DBus.GLib.CSymbol or should this 
annotation not be included under org.freedesktop.DBus.GLib since we need 
to access it from Java?  Or perhaps a third option (since I am just 
learning this stuff)?

Tim Moloney



More information about the dbus mailing list