[erlang-questions] rpc from erlang to java

Ben Hood 0x6e6562@REDACTED
Sat Aug 18 14:36:50 CEST 2007


Vlad,

On 8/15/07, Vlad Dumitrescu <vladdu55@REDACTED> wrote:
> I'm not sure how many people are interacting with Java from Erlang,
> but I am (for ErlIDE) and I just implemented a nice feature (if I may
> say so myself) that might of interest: the ability to call Java code

I'm using Hessian to achieve binary data binding between Erlang and
Java, see http://cotton.sourceforge.net/hg/cotton/file/88f45901c41f/src/integration_test.erl
for an example. In this example I using http as a transport between
the Erlang client and Java server, but Hessian is not tied to a
particular transport mechanism, it just handles binary encoding and
decoding to a language neutral data format protocol.

> The conversion layer converts between Erlang terms and Java objects,
> almost seamlessly (atoms aren't easy to translate, for example) and
> uses reflection to resolve and invoke the proper methods. Type
> translation is trying to be clever, for example strings are
> represented by native types, likewise integers. Lists correspond to
> java.util.Lists and tuples to arrays.


This example http://cotton.sourceforge.net/hg/cotton/file/88f45901c41f/src/hessian_test.erl
shows how the type mapping works. The main assumption is that in order
to serialize an Erlang record (which is just a tuple with no runtime
type information), a serializable record type should have a field
called fqn (abbreviation of fully qualified name) so that it can be
deserialized in more strongly typed languages like Java.

HTH,

Ben



More information about the erlang-questions mailing list