인터페이스 상속 :자바 나는이 코드를 작성했습니다
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
내가 문제가있는 것을 알고 있다고 상속의 오해 또는 그와 같은 평범함. 나는 철저히 조사했지만 대답을 찾을 수 없었다. 이 행을 올바르게 쓰는 방법? 그리고 실수는 무엇입니까?
문제가 그렇지는 플레이어/확장 구현 뭔가를 받고있을 거라 생각하지만, 개봉한다는 것입니다. 플레이어를 확장/구현하지 않는 일종의 자동 생성 프록시가 있습니다. 어쩌면 그것의 목록 ? 나는 모른다. 거기에 중단 점을 설정하고 몇 가지 instanceof 검사를 실행하여 가지고있는 것을 확인하는 것이 좋습니다. 이 연결의 다른 쪽을 게시 할 수 있습니까? "/ Player"에서 "바인딩"은 무엇입니까? –
radai