com.sun.proxy.$ Proxy1无法转换为

Ala*_*off 0 java casting rmi

GameV1游戏;

  public void connect() {
    connect("//localhost/Game");
    if (getServer() != null) {
        game= (GameV1) getServer();

    }

}
Run Code Online (Sandbox Code Playgroud)

这个方法"connect("// localhost/Game");" 只需将服务器设置在upperclase上,然后将其转换为GameV1 Game = interface GameV1 =具有实现游戏的具体类

if(getServer()!= null)这返回true但是在施放com.sun.proxy时出现此错误.$ Proxy1无法强制转换为GameV1

Rob*_*een 7

使用RMI远程对象,您无法转换为具体类.你必须转发到远程接口.