Java warning when calling DBusConnection.addSigHander in Java binding

Tim Moloney t.moloney at verizon.net
Tue Apr 25 18:59:42 PDT 2006


I get a couple of warnings when compiling the following line of Java 
code inside Eclipse.

this.connection.addSigHandler(Player.playingUriChanged.class, this);

The warnings are:
- Type safety: The expression of type RhythmboxDbusProxy needs unchecked 
conversion to conform to DBusSigHandler<T>
- Type safety: Unchecked invocation addSigHandler(Class, DBusSigHandler) 
of the generic method addSigHandler(Class<T>, DBusSigHandler<T>) of type 
DBusConnection

"Player" is the Java class generated by the CreateInterface application 
(which extends DBusSignal) and "this" refers to an instance of my 
RhythmboxDbusProxy class that implements DBusSigHandler.

Everything runs properly but I'd like to get rid of the warning.  I 
googled a bit and tried adding
  @SuppressWarnings("unchecked")
before the offending line as suggested.  Unfortunately, I then get three 
enum-related errors instead.

I realize that I don't know generics very well (at all actually since 
I'm relatively new to Java).  Can someone wiser than me in the way of 
generics provide a solution that compiles warning-free?

Thanks.

Tim Moloney



More information about the dbus mailing list