Marsellus Wallace
Marsellus Wallace

Reputation: 18601

Java RMI with Scala, is this possible?

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??

Upvotes: 7

Views: 2162

Answers (3)

Nathan Hughes
Nathan Hughes

Reputation: 96434

Yes, here's a link to a message thread where it looks like somebody's done it. It says:

Yes it can! Thanks for help. I now have a little RMI-based pair of Scala programs that will be performing transfers of documents from one Documentum system to another (of a previous version); the Scala code is interacting very nicely with the Documentum Java libraries.

Figuring out how to get the method signatures to include throws RemoteException seems to have been the biggest hurdle.

Upvotes: 5

Kim Stebel
Kim Stebel

Reputation: 42047

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.

Upvotes: 1

Jack Edmonds
Jack Edmonds

Reputation: 33181

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 a java.util.List.

Upvotes: 0

Related Questions