【发布时间】:2012-09-19 13:48:20
【问题描述】:
假设我有这些行:
Registry registry = LocateRegistry.getRegistry(2121);
RemoteObject probe = (RemoteObject)registry.lookup(REMOTE_OBJ_NAME);//this throws exception
probe.doSomething();
例外是这样的:
java.lang.ClassCastException: $Proxy1 cannot be cast to app.RemoteObject
为了清楚起见,RemoteObject 实现了一个扩展 java.rmi.Remote 的接口。
【问题讨论】:
-
registry.lookup返回什么类型? -
@Joe 只是一个 Remote,它实现了原始对象的所有接口,也扩展了 Remote
-
@Joe 在异常中:
$Proxy1。