我的特质:
@remote trait Computer {
def execute(task: Task[Any]): Any
}
类的伴随对象中的主类片段,ComputerImpl
只需Computer
定义execute
为即可实现= task.execute()
。
val name = "Computer"
val engine: Computer = new ComputerImpl()
val stub = UnicastRemoteObject.exportObject(engine, 0).asInstanceOf[Computer]
我收到此错误:
system/ComputerImpl.scala:19: error: type mismatch;
found : api.Computer
required: java.rmi.Remote
val stub = UnicastRemoteObject.exportObject(engine, 0).asInstanceOf[Computer]
如果我做得更明确,它就会消失,trait Computer extends Remote
但在“Scala for Impatient”中它说“Scala 使用注释@cloneable
而@remote
不是可克隆和远程对象的Cloneable
andjava.rmi.Remote
接口。”
出了什么问题?