我写了这段代码:
package sample;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusInterfaceName;
import org.freedesktop.dbus.DBusConnection;
@DBusInterfaceName("org.mpris.clementine")
interface Player extends DBusInterface, java.rmi.Remote {
void Pause();
}
class Main {
public static void main (String[] args) throws org.freedesktop.dbus.exceptions.DBusException, java.lang.InterruptedException {
DBusConnection dc = DBusConnection.getConnection(DBusConnection.SESSION);
Player player = (Player) dc.getRemoteObject("org.mpris.clementine", "/Player");
player.Pause();
dc.disconnect();
}
}
并得到一个错误的行
Player player = (Player) dc.getRemoteObject("org.mpris.clementine", "/Player");
它说
Exception in thread "main" java.lang.ClassCastException: $Proxy2 cannot be cast to sample.Player
我知道问题在于继承误解或类似的东西。我已经彻底搜索过,但找不到答案。如何正确写出这一行?什么是错误?