Java RMI 与 Scala,这可能吗?
Java RMI - 远程方法调用 - 仅适用于 Java 到 Java。
在 Scala 网站上,我读到与 Java 的集成是无缝的,并且:
Scala 程序在 Java VM 上运行,字节码与 Java 兼容,因此您可以充分利用现有的 Java 库或现有的应用程序代码。您可以从 Java 调用 Scala,也可以从 Scala 调用 Java,无缝集成。
这是否意味着我可以成功使用 Java 到 Scala RMI?
有人亲自实验过吗?
编辑:
任何已知或发现的陷阱?
Java RMI -Remote Method Invocation- is Java to Java only.
On the Scala website I read that the integration with Java is seamless and that:
Scala programs run on the Java VM, are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. You can call Scala from Java and you can call Java from Scala, the integration is seamless.
Does this mean that I can successfully use a Java to Scala RMI?
Did anyone experiment this first-hand?
EDIT:
Any known or discovered gotchas??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这里有一个 链接到消息线程,其中看起来有人已经做到了。它说:
弄清楚如何让方法签名包含
抛出RemoteException
似乎是最大的障碍。Yes, here's a link to a message thread where it looks like somebody's done it. It says:
Figuring out how to get the method signatures to include
throws RemoteException
seems to have been the biggest hurdle.是的,这是可以做到的。 rmi 编译器使用 java 字节代码,因此使用的语言并不重要。我已经为一个班级项目完成了这个。
Yes, this can be done. The rmi compiler works with java byte code, so the language used really doesn't matter. I've done this for a class project.
这取决于您使用的 RMI 库,但一般来说,答案是“是”。不过,请注意,如果您编写一个返回(例如)Scala 集合(例如
scala.collections.immutable.List
)的方法,那么您的调用 Java 代码可能无法将其转换为 <代码>java.util.List。It would depend on what RMI library you are using but in general, the answer is "Yes." Although, note that if you write a method that returns (for example) a Scala collection like
scala.collections.immutable.List
, then your calling Java code will probably not be able to convert that to ajava.util.List
.